Commit 0094cacb authored by tsergeant's avatar tsergeant Committed by Commit bot

Replace Webstore link with app info dialog link in chrome://apps

This brings the context menu options closer to what is in the App
Launcher, and hides the webstore link in cases where it shouldn't be
shown to the user. This change is ignored on Mac.

BUG=449095

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

Cr-Commit-Position: refs/heads/master@{#318163}
parent b1754c5c
......@@ -64,12 +64,20 @@ cr.define('ntp', function() {
this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator();
menu.appendChild(this.launchTypeMenuSeparator_);
this.options_ = this.appendMenuItem_('appoptions');
this.details_ = this.appendMenuItem_('appdetails');
this.uninstall_ = this.appendMenuItem_('appuninstall');
if (loadTimeData.getBoolean('canShowAppInfoDialog')) {
this.appinfo_ = this.appendMenuItem_('appinfodialog');
this.appinfo_.addEventListener('activate',
this.onShowAppInfo_.bind(this));
} else {
this.details_ = this.appendMenuItem_('appdetails');
this.details_.addEventListener('activate',
this.onShowDetails_.bind(this));
}
this.options_.addEventListener('activate',
this.onShowOptions_.bind(this));
this.details_.addEventListener('activate',
this.onShowDetails_.bind(this));
this.uninstall_.addEventListener('activate',
this.onUninstall_.bind(this));
......@@ -141,7 +149,8 @@ cr.define('ntp', function() {
this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp;
this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled;
this.details_.disabled = !app.appData.detailsUrl;
if (this.details_)
this.details_.disabled = !app.appData.detailsUrl;
this.uninstall_.disabled = !app.appData.mayDisable;
if (cr.isMac) {
......@@ -194,6 +203,9 @@ cr.define('ntp', function() {
onCreateShortcut_: function(e) {
chrome.send('createAppShortcut', [this.app_.appData.id]);
},
onShowAppInfo_: function(e) {
chrome.send('showAppInfo', [this.app_.appData.id]);
}
};
/**
......
......@@ -25,7 +25,6 @@
#include "ui/app_list/app_list_folder_item.h"
#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/gfx/geometry/rect.h"
#if defined(ENABLE_RLZ)
......@@ -87,7 +86,7 @@ bool AppListControllerDelegate::UserMayModifySettings(
}
bool AppListControllerDelegate::CanDoShowAppInfoFlow() {
return app_list::switches::IsAppInfoEnabled();
return CanShowAppInfoDialog();
}
void AppListControllerDelegate::DoShowAppInfoFlow(
......
......@@ -23,9 +23,17 @@ class Size;
enum AppInfoLaunchSource {
FROM_APP_LIST, // Launched from the app list context menu.
FROM_EXTENSIONS_PAGE, // Launched from the chrome://extensions page.
FROM_APPS_PAGE, // Launched from chrome://apps context menu.
NUM_LAUNCH_SOURCES,
};
// TODO(tsergeant): Move these methods into a class
// Returns true if the app info dialog is available on the current platform.
bool CanShowAppInfoDialog();
// Returns the size of the native window container for the app info dialog.
gfx::Size GetAppInfoNativeDialogSize();
// Shows the chrome app information as a frameless window for the given |app|
// and |profile| at the given |app_list_bounds|. Appears 'inside' the app list.
void ShowAppInfoInAppList(gfx::NativeWindow parent,
......
......@@ -4,6 +4,15 @@
#include "base/logging.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "ui/gfx/geometry/size.h"
bool CanShowAppInfoDialog() {
return false;
}
gfx::Size GetAppInfoNativeDialogSize() {
return gfx::Size();
}
void ShowAppInfoInAppList(gfx::NativeWindow parent,
const gfx::Rect& app_list_bounds,
......
......@@ -20,6 +20,7 @@
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/border.h"
......@@ -29,6 +30,18 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
bool CanShowAppInfoDialog() {
#if defined(OS_MACOSX)
return app_list::switches::IsMacViewsAppListListEnabled();
#else
return true;
#endif
}
gfx::Size GetAppInfoNativeDialogSize() {
return gfx::Size(380, 490);
}
void ShowAppInfoInAppList(gfx::NativeWindow parent,
const gfx::Rect& app_list_bounds,
Profile* profile,
......
......@@ -109,16 +109,6 @@ namespace {
const char kAppsDeveloperToolsExtensionId[] =
"ohmmkhmmmpcnpikjeljgnaoabkaalbgc";
// Returns true if the extensions page should display the new-style extension
// info dialog. If false, display the old permissions dialog.
bool ShouldDisplayExtensionInfoDialog() {
#if defined(OS_MACOSX)
return false;
#else
return true;
#endif
}
} // namespace
namespace extensions {
......@@ -316,7 +306,7 @@ base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue(
extension_data->SetString("optionsPageHref",
OptionsPageInfo::GetOptionsPage(extension).spec());
extension_data->SetBoolean("enableExtensionInfoDialog",
ShouldDisplayExtensionInfoDialog());
CanShowAppInfoDialog());
// Add dependent extensions.
base::ListValue* dependents_list = new base::ListValue;
......@@ -573,7 +563,7 @@ void ExtensionSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED));
source->AddString("extensionSettingsOptions",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK));
if (ShouldDisplayExtensionInfoDialog()) {
if (CanShowAppInfoDialog()) {
source->AddString("extensionSettingsPermissions",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK));
} else {
......@@ -1196,20 +1186,17 @@ void ExtensionSettingsHandler::HandlePermissionsMessage(
// The BrokerDelegate manages its own lifetime.
BrokerDelegate* broker_delegate = new BrokerDelegate(AsWeakPtr());
// Show the new-style extensions dialog when the flag is set. The flag cannot
// be set on Mac platforms.
if (ShouldDisplayExtensionInfoDialog()) {
// Show the new-style extensions dialog when it is available. It is currently
// unavailable by default on Mac.
if (CanShowAppInfoDialog()) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches",
AppInfoLaunchSource::FROM_EXTENSIONS_PAGE,
AppInfoLaunchSource::NUM_LAUNCH_SOURCES);
// Display the dialog at a size similar to the app list.
const int kAppInfoDialogWidth = 380;
const int kAppInfoDialogHeight = 490;
ShowAppInfoInNativeDialog(
web_contents()->GetTopLevelNativeWindow(),
gfx::Size(kAppInfoDialogWidth, kAppInfoDialogHeight),
GetAppInfoNativeDialogSize(),
Profile::FromWebUI(web_ui()), extension,
base::Bind(&BrokerDelegate::AppInfoDialogClosed,
base::Unretained(broker_delegate)));
......
......@@ -26,6 +26,7 @@
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
......@@ -222,6 +223,9 @@ void AppLauncherHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("createAppShortcut",
base::Bind(&AppLauncherHandler::HandleCreateAppShortcut,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("showAppInfo",
base::Bind(&AppLauncherHandler::HandleShowAppInfo,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("reorderApps",
base::Bind(&AppLauncherHandler::HandleReorderApps,
base::Unretained(this)));
......@@ -614,6 +618,25 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
base::Callback<void(bool)>());
}
void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
std::string extension_id;
CHECK(args->GetString(0, &extension_id));
const Extension* extension =
extension_service_->GetExtensionById(extension_id, true);
if (!extension)
return;
UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches",
AppInfoLaunchSource::FROM_APPS_PAGE,
AppInfoLaunchSource::NUM_LAUNCH_SOURCES);
ShowAppInfoInNativeDialog(
web_ui()->GetWebContents()->GetTopLevelNativeWindow(),
GetAppInfoNativeDialogSize(), Profile::FromWebUI(web_ui()), extension,
base::Closure());
}
void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) {
CHECK(args->GetSize() == 2);
......
......@@ -87,6 +87,9 @@ class AppLauncherHandler
// [extension_id].
void HandleCreateAppShortcut(const base::ListValue* args);
// Handles the "showAppInfo" message with |args| containing [extension_id].
void HandleShowAppInfo(const base::ListValue* args);
// Handles the "reorderApps" message with |args| containing [dragged_app_id,
// app_order].
void HandleReorderApps(const base::ListValue* args);
......
......@@ -28,6 +28,7 @@
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
......@@ -439,6 +440,8 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_OPTIONS));
load_time_data.SetString("appdetails",
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_DETAILS));
load_time_data.SetString("appinfodialog",
l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_SHOW_INFO));
load_time_data.SetString("appcreateshortcut",
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
load_time_data.SetString("appDefaultPageName",
......@@ -502,6 +505,9 @@ void NTPResourceCache::CreateNewTabHTML() {
bool bookmark_apps_enabled = extensions::util::IsNewBookmarkAppsEnabled();
load_time_data.SetBoolean("enableNewBookmarkApps", bookmark_apps_enabled);
load_time_data.SetBoolean("canShowAppInfoDialog",
CanShowAppInfoDialog());
#if defined(OS_CHROMEOS)
load_time_data.SetString("expandMenu",
l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND));
......
......@@ -43831,6 +43831,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<enum name="AppInfoDialogLaunchOrigin" type="int">
<int value="0" label="App List context menu"/>
<int value="1" label="Extensions page"/>
<int value="2" label="Apps Page context menu"/>
</enum>
<enum name="AppLaunch" type="int">
......@@ -67,13 +67,6 @@ bool IsVoiceSearchEnabled() {
#endif
}
bool IsAppInfoEnabled() {
#if defined(OS_MACOSX)
return IsMacViewsAppListListEnabled();
#endif
return true;
}
bool IsExperimentalAppListEnabled() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
kEnableExperimentalAppList))
......
......@@ -31,8 +31,6 @@ bool APP_LIST_EXPORT IsFolderUIEnabled();
bool APP_LIST_EXPORT IsVoiceSearchEnabled();
bool APP_LIST_EXPORT IsAppInfoEnabled();
bool APP_LIST_EXPORT IsExperimentalAppListEnabled();
// Determines whether either command-line switch was given for enabling the
......
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