Commit 2a36a8d7 authored by sashab@chromium.org's avatar sashab@chromium.org

Added tabs to the App Info dialog, and removed the title.

Removed the title to make the tabs start at the very top of the dialog.

Has 3 tabs: Summary, Permissions and Manage
- The Summary tab displays the app's icon, name, version and description.
- The Permissions tab displays the app's permissions as a scrollable list
- The Manage tab is currently empty.

BUG=266739

Review URL: https://codereview.chromium.org/180723010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255880 0039d316-1c4b-4281-b951-d872f2087c98
parent 372ba214
...@@ -2208,20 +2208,32 @@ Even if you have downloaded files from this website before, the website might ha ...@@ -2208,20 +2208,32 @@ Even if you have downloaded files from this website before, the website might ha
<!-- "Application Information" dialog --> <!-- "Application Information" dialog -->
<if expr="not use_titlecase"> <if expr="not use_titlecase">
<message name="IDS_APPLICATION_INFO_TITLE" desc="Title of the dialog that contains information about the current application.">
Application information
</message>
<message name="IDS_APPLICATION_INFO_CLOSE_BUTTON" desc="Button in the Application Information Dialog that closes the dialog"> <message name="IDS_APPLICATION_INFO_CLOSE_BUTTON" desc="Button in the Application Information Dialog that closes the dialog">
Close Close
</message> </message>
<message name="IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE" desc="Title of the first tab in the dialog, which displays general summary information about the app. ">
Summary
</message>
<message name="IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE" desc="Title of the second tab in the dialog, which lists the specific permissions that the app has.">
Permissions
</message>
<message name="IDS_APPLICATION_INFO_MANAGE_TAB_TITLE" desc="Title of the third tab in the dialog, which displays the app's usage information and some tools for managing the app's status.">
Manage
</message>
</if> </if>
<if expr="use_titlecase"> <if expr="use_titlecase">
<message name="IDS_APPLICATION_INFO_TITLE" desc="In Title Case: title of the dialog that contains information about the current application.">
Application Information
</message>
<message name="IDS_APPLICATION_INFO_CLOSE_BUTTON" desc="In Title Case: Button in the Application Information Dialog that closes the dialog"> <message name="IDS_APPLICATION_INFO_CLOSE_BUTTON" desc="In Title Case: Button in the Application Information Dialog that closes the dialog">
Close Close
</message> </message>
<message name="IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE" desc="In Title Case: Title of the first tab in the dialog, which displays general summary information about the app. ">
Summary
</message>
<message name="IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE" desc="In Title Case: Title of the second tab in the dialog, which lists the specific permissions that the app has.">
Permissions
</message>
<message name="IDS_APPLICATION_INFO_MANAGE_TAB_TITLE" desc="In Title Case: Title of the third tab in the dialog, which displays the app's usage information and some tools for managing the app's status.">
Manage
</message>
</if> </if>
<!-- "Create application shortcuts" dialog --> <!-- "Create application shortcuts" dialog -->
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h"
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_manage_tab.h"
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.h"
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.h"
#include "chrome/browser/ui/views/constrained_window_views.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/tabbed_pane/tabbed_pane.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
void ShowChromeAppInfoDialog(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback) {
CreateBrowserModalDialogViews(
new AppInfoDialog(parent_window, profile, app, close_callback),
parent_window)->Show();
}
AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback)
: parent_window_(parent_window),
profile_(profile),
app_(app),
close_callback_(close_callback) {
SetLayoutManager(new views::FillLayout());
views::TabbedPane* tabbed_pane = new views::TabbedPane();
AddChildView(tabbed_pane);
tabbed_pane->AddTab(
l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE),
new AppInfoSummaryTab(parent_window_, profile_, app_, close_callback_));
tabbed_pane->AddTab(
l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE),
new AppInfoPermissionsTab(
parent_window_, profile_, app_, close_callback_));
tabbed_pane->AddTab(
l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_MANAGE_TAB_TITLE),
new AppInfoManageTab(parent_window_, profile_, app_, close_callback_));
}
AppInfoDialog::~AppInfoDialog() {}
bool AppInfoDialog::Cancel() {
if (!close_callback_.is_null())
close_callback_.Run();
return true;
}
gfx::Size AppInfoDialog::GetPreferredSize() {
static const int kDialogWidth = 360;
int height =
GetLayoutManager()->GetPreferredHeightForWidth(this, kDialogWidth);
return gfx::Size(kDialogWidth, height);
}
base::string16 AppInfoDialog::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_CANCEL) {
return l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_CLOSE_BUTTON);
}
return views::DialogDelegateView::GetDialogButtonLabel(button);
}
int AppInfoDialog::GetDialogButtons() const { return ui::DIALOG_BUTTON_CANCEL; }
bool AppInfoDialog::IsDialogButtonEnabled(ui::DialogButton button) const {
return true;
}
ui::ModalType AppInfoDialog::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_VIEWS_H_ #ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_DIALOG_VIEWS_H_
#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_VIEWS_H_ #define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_DIALOG_VIEWS_H_
#include "base/compiler_specific.h" #include "ui/gfx/native_widget_types.h"
#include "chrome/browser/shell_integration.h"
#include "ui/message_center/views/bounded_scroll_view.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
class Profile; class Profile;
...@@ -16,69 +13,40 @@ class Profile; ...@@ -16,69 +13,40 @@ class Profile;
namespace extensions { namespace extensions {
class Extension; class Extension;
} }
namespace views { namespace views {
class Label; class TabbedPane;
} }
// A scrollable list of permissions for the given app.
class PermissionsScrollView : public message_center::BoundedScrollView {
public:
PermissionsScrollView(int min_height,
int max_height,
const extensions::Extension* app);
private:
virtual ~PermissionsScrollView();
views::View* inner_scrollable_view;
};
// View the information about a particular chrome application. // View the information about a particular chrome application.
class AppInfoView : public views::DialogDelegateView, class AppInfoDialog : public views::DialogDelegateView {
public base::SupportsWeakPtr<AppInfoView> {
public: public:
AppInfoView(Profile* profile, AppInfoDialog(gfx::NativeWindow parent_window,
const extensions::Extension* app, Profile* profile,
const base::Closure& close_callback); const extensions::Extension* app,
const base::Closure& close_callback);
private: virtual ~AppInfoDialog();
virtual ~AppInfoView();
private:
// Overridden from views::View: // Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE;
// Overridden from views::DialogDelegate: // Overridden from views::DialogDelegate:
virtual bool Cancel() OVERRIDE; virtual bool Cancel() OVERRIDE;
virtual base::string16 GetDialogButtonLabel(ui::DialogButton button) virtual base::string16 GetDialogButtonLabel(ui::DialogButton button) const
const OVERRIDE; OVERRIDE;
virtual int GetDialogButtons() const OVERRIDE; virtual int GetDialogButtons() const OVERRIDE;
virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
// Overridden from views::WidgetDelegate: // Overridden from views::WidgetDelegate:
virtual ui::ModalType GetModalType() const OVERRIDE; virtual ui::ModalType GetModalType() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
// Called when the app's icon is loaded.
void OnAppImageLoaded(const gfx::Image& image);
// Profile in which the shortcuts will be created. gfx::NativeWindow parent_window_;
Profile* profile_; Profile* profile_;
// UI elements on the dialog.
views::Label* app_name_label;
views::Label* app_description_label;
views::Label* app_version_label;
views::ImageView* app_icon;
views::Label* permission_list_heading;
PermissionsScrollView* permissions_scroll_view;
const extensions::Extension* app_; const extensions::Extension* app_;
base::Closure close_callback_; base::Closure close_callback_;
base::WeakPtrFactory<AppInfoView> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(AppInfoDialog);
DISALLOW_COPY_AND_ASSIGN(AppInfoView);
}; };
#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_VIEWS_H_ #endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_DIALOG_VIEWS_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_manage_tab.h"
#include "ui/gfx/native_widget_types.h"
AppInfoManageTab::AppInfoManageTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback)
: AppInfoTab(parent_window, profile, app, close_callback) {
// TODO(sashab): Populate this tab.
}
AppInfoManageTab::~AppInfoManageTab() {}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_MANAGE_TAB_H_
#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_MANAGE_TAB_H_
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
namespace extensions {
class Extension;
}
// The Manage tab of the app info dialog, which provides insight and control
// over the app's state and usage.
class AppInfoManageTab : public AppInfoTab {
public:
AppInfoManageTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback);
virtual ~AppInfoManageTab();
private:
DISALLOW_COPY_AND_ASSIGN(AppInfoManageTab);
};
#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_MANAGE_TAB_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_PERMISSIONS_TAB_H_
#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_PERMISSIONS_TAB_H_
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
namespace extensions {
class Extension;
}
// The Permissions tab of the app info dialog, which provides insight and
// control over the app's various permissions.
class AppInfoPermissionsTab : public AppInfoTab {
public:
AppInfoPermissionsTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback);
virtual ~AppInfoPermissionsTab();
DISALLOW_COPY_AND_ASSIGN(AppInfoPermissionsTab);
};
#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_PERMISSIONS_TAB_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.h"
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/image_loader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
#include "extensions/common/extension.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
// Size of extension icon in top left of dialog.
const int kIconSize = 64;
AppInfoSummaryTab::AppInfoSummaryTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback)
: AppInfoTab(parent_window, profile, app, close_callback),
app_icon_(NULL),
weak_ptr_factory_(this) {
// Create UI elements.
views::Label* app_name_label =
new views::Label(base::UTF8ToUTF16(app_->name()));
app_name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
views::Label* app_description_label =
new views::Label(base::UTF8ToUTF16(app_->description()));
app_description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
views::Label* app_version_label =
new views::Label(base::UTF8ToUTF16(app_->VersionString()));
app_version_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
app_icon_ = new views::ImageView();
app_icon_->SetImageSize(gfx::Size(kIconSize, kIconSize));
LoadAppImageAsync();
// Create the layout.
views::GridLayout* layout = views::GridLayout::CreatePanel(this);
SetLayoutManager(layout);
// Create a Header column set with app icon and information.
static const int kHeaderColumnSetId = 0;
views::ColumnSet* header_column_set =
layout->AddColumnSet(kHeaderColumnSetId);
header_column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::CENTER,
0,
views::GridLayout::FIXED,
kIconSize,
0);
header_column_set->AddPaddingColumn(0,
views::kRelatedControlHorizontalSpacing);
header_column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::CENTER,
100.0f,
views::GridLayout::FIXED,
0,
0);
// The app icon takes up 3 rows.
layout->StartRow(0, kHeaderColumnSetId);
layout->AddView(app_icon_, 1, 3);
// The app information fills up the right side of the icon.
layout->AddView(app_name_label);
layout->StartRow(0, kHeaderColumnSetId);
layout->SkipColumns(1);
layout->AddView(app_version_label);
layout->StartRow(0, kHeaderColumnSetId);
layout->SkipColumns(1);
layout->AddView(app_description_label);
}
AppInfoSummaryTab::~AppInfoSummaryTab() {}
void AppInfoSummaryTab::LoadAppImageAsync() {
extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
app_,
extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_BIGGER);
int pixel_size =
static_cast<int>(kIconSize * gfx::ImageSkia::GetMaxSupportedScale());
extensions::ImageLoader::Get(profile_)->LoadImageAsync(
app_,
image,
gfx::Size(pixel_size, pixel_size),
base::Bind(&AppInfoSummaryTab::OnAppImageLoaded, AsWeakPtr()));
}
void AppInfoSummaryTab::OnAppImageLoaded(const gfx::Image& image) {
const SkBitmap* bitmap;
if (image.IsEmpty()) {
bitmap = &extensions::IconsInfo::GetDefaultAppIcon()
.GetRepresentation(gfx::ImageSkia::GetMaxSupportedScale())
.sk_bitmap();
} else {
bitmap = image.ToSkBitmap();
}
app_icon_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(*bitmap));
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_SUMMARY_TAB_H_
#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_SUMMARY_TAB_H_
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
namespace extensions {
class Extension;
}
namespace gfx {
class Image;
}
namespace views {
class ImageView;
}
// The Summary tab of the app info dialog, which provides basic information and
// controls related to the app.
class AppInfoSummaryTab : public AppInfoTab,
public base::SupportsWeakPtr<AppInfoSummaryTab> {
public:
AppInfoSummaryTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback);
virtual ~AppInfoSummaryTab();
private:
// Load the app icon asynchronously. For the response, check OnAppImageLoaded.
virtual void LoadAppImageAsync();
// Called when the app's icon is loaded.
virtual void OnAppImageLoaded(const gfx::Image& image);
// UI elements on the dialog.
views::ImageView* app_icon_;
base::WeakPtrFactory<AppInfoSummaryTab> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AppInfoSummaryTab);
};
#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_SUMMARY_TAB_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab.h"
AppInfoTab::AppInfoTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback)
: parent_window_(parent_window),
profile_(profile),
app_(app),
close_callback_(close_callback) {}
AppInfoTab::~AppInfoTab() {}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_TAB_H_
#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_TAB_H_
#include "ui/gfx/native_widget_types.h"
#include "ui/views/view.h"
class AppInfoView;
class Profile;
namespace extensions {
class Extension;
}
namespace views {
class View;
}
// A tab in the App Info dialog that displays information for a particular
// profile and app. Tabs in the App Info dialog extend this class.
class AppInfoTab : public views::View {
public:
AppInfoTab(gfx::NativeWindow parent_window,
Profile* profile,
const extensions::Extension* app,
const base::Closure& close_callback);
virtual ~AppInfoTab();
protected:
gfx::NativeWindow parent_window_;
Profile* profile_;
const extensions::Extension* app_;
const base::Closure& close_callback_;
private:
DISALLOW_COPY_AND_ASSIGN(AppInfoTab);
};
#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_TAB_H_
...@@ -1713,8 +1713,16 @@ ...@@ -1713,8 +1713,16 @@
'browser/ui/views/app_list/win/app_list_service_win.h', 'browser/ui/views/app_list/win/app_list_service_win.h',
'browser/ui/views/app_list/win/app_list_win.cc', 'browser/ui/views/app_list/win/app_list_win.cc',
'browser/ui/views/app_list/win/app_list_win.h', 'browser/ui/views/app_list/win/app_list_win.h',
'browser/ui/views/apps/app_info_dialog_views.cc', 'browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc',
'browser/ui/views/apps/app_info_dialog_views.h', 'browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h',
'browser/ui/views/apps/app_info_dialog/app_info_manage_tab.cc',
'browser/ui/views/apps/app_info_dialog/app_info_manage_tab.h',
'browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc',
'browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.h',
'browser/ui/views/apps/app_info_dialog/app_info_summary_tab.cc',
'browser/ui/views/apps/app_info_dialog/app_info_summary_tab.h',
'browser/ui/views/apps/app_info_dialog/app_info_tab.cc',
'browser/ui/views/apps/app_info_dialog/app_info_tab.h',
'browser/ui/views/apps/chrome_app_window_delegate_views.cc', 'browser/ui/views/apps/chrome_app_window_delegate_views.cc',
'browser/ui/views/apps/chrome_app_window_delegate_views_win.cc', 'browser/ui/views/apps/chrome_app_window_delegate_views_win.cc',
'browser/ui/views/apps/chrome_native_app_window_views.cc', 'browser/ui/views/apps/chrome_native_app_window_views.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment