Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Unified Diff: chrome/browser/extensions/extension_disabled_ui.cc

Issue 264763002: Support remote installation of extensions and apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_disabled_ui.cc
diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc
index 8626b11c378fbbfbe2801a0f86e1891e814087f6..ebdd08702097a1b942fe151c5b925dd1f3d4e0ab 100644
--- a/chrome/browser/extensions/extension_disabled_ui.cc
+++ b/chrome/browser/extensions/extension_disabled_ui.cc
@@ -141,6 +141,7 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
public:
ExtensionDisabledGlobalError(ExtensionService* service,
const Extension* extension,
+ int disable_reasons,
Yoyo Zhou 2014/05/01 22:53:44 Why not make this a bool is_remote_install?
Marijn Kruisselbrink 2014/05/05 20:45:36 Done.
const gfx::Image& icon);
virtual ~ExtensionDisabledGlobalError();
@@ -171,6 +172,7 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
private:
ExtensionService* service_;
const Extension* extension_;
+ int disable_reasons_;
gfx::Image icon_;
// How the user responded to the error; used for metrics.
@@ -194,9 +196,11 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
ExtensionService* service,
const Extension* extension,
+ int disable_reasons,
const gfx::Image& icon)
: service_(service),
extension_(extension),
+ disable_reasons_(disable_reasons),
icon_(icon),
user_response_(IGNORED),
menu_command_id_(GetMenuCommandID()) {
@@ -218,9 +222,14 @@ ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {
ReleaseMenuCommandID(menu_command_id_);
- UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse",
- user_response_,
- EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
+ if (disable_reasons_ & Extension::DISABLE_REMOTE_INSTALL)
Yoyo Zhou 2014/05/01 22:53:44 braces for more than one line if statements
Marijn Kruisselbrink 2014/05/05 20:45:36 Done.
+ UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall",
+ user_response_,
+ EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
+ else
+ UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse",
+ user_response_,
+ EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
}
GlobalError::Severity ExtensionDisabledGlobalError::GetSeverity() {
@@ -236,8 +245,13 @@ int ExtensionDisabledGlobalError::MenuItemCommandID() {
}
base::string16 ExtensionDisabledGlobalError::MenuItemLabel() {
- return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE,
- base::UTF8ToUTF16(extension_->name()));
+ if (disable_reasons_ & Extension::DISABLE_REMOTE_INSTALL)
+ return l10n_util::GetStringFUTF16(
+ IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_TITLE,
+ base::UTF8ToUTF16(extension_->name()));
+ else
+ return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE,
+ base::UTF8ToUTF16(extension_->name()));
}
void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) {
@@ -249,22 +263,38 @@ gfx::Image ExtensionDisabledGlobalError::GetBubbleViewIcon() {
}
base::string16 ExtensionDisabledGlobalError::GetBubbleViewTitle() {
- return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE,
- base::UTF8ToUTF16(extension_->name()));
+ if (disable_reasons_ & Extension::DISABLE_REMOTE_INSTALL)
+ return l10n_util::GetStringFUTF16(
+ IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_TITLE,
+ base::UTF8ToUTF16(extension_->name()));
+ else
+ return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE,
+ base::UTF8ToUTF16(extension_->name()));
}
std::vector<base::string16>
ExtensionDisabledGlobalError::GetBubbleViewMessages() {
std::vector<base::string16> messages;
- messages.push_back(l10n_util::GetStringFUTF16(
- extension_->is_app() ?
- IDS_APP_DISABLED_ERROR_LABEL : IDS_EXTENSION_DISABLED_ERROR_LABEL,
- base::UTF8ToUTF16(extension_->name())));
- messages.push_back(l10n_util::GetStringUTF16(
- IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO));
std::vector<base::string16> permission_warnings =
extensions::PermissionMessageProvider::Get()->GetWarningMessages(
extension_->GetActivePermissions(), extension_->GetType());
+ if (disable_reasons_ & Extension::DISABLE_REMOTE_INSTALL) {
+ messages.push_back(l10n_util::GetStringFUTF16(
+ extension_->is_app()
+ ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL
+ : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL,
+ base::UTF8ToUTF16(extension_->name())));
+ if (!permission_warnings.empty())
+ messages.push_back(
+ l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO));
+ } else {
+ messages.push_back(l10n_util::GetStringFUTF16(
Yoyo Zhou 2014/05/01 22:53:44 There is some redundancy here. Consider making it
Marijn Kruisselbrink 2014/05/05 20:45:36 I'm not sure what redundancy there is? Even Extens
Yoyo Zhou 2014/05/05 22:35:17 Ah, I misread. These are not the same strings. Sor
+ extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL
+ : IDS_EXTENSION_DISABLED_ERROR_LABEL,
+ base::UTF8ToUTF16(extension_->name())));
+ messages.push_back(l10n_util::GetStringUTF16(
+ IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO));
+ }
for (size_t i = 0; i < permission_warnings.size(); ++i) {
messages.push_back(l10n_util::GetStringFUTF16(
IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i]));
@@ -273,7 +303,11 @@ ExtensionDisabledGlobalError::GetBubbleViewMessages() {
}
base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() {
- return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON);
+ if (disable_reasons_ & Extension::DISABLE_REMOTE_INSTALL)
+ return l10n_util::GetStringUTF16(
+ IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON);
+ else
+ return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON);
}
base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() {
@@ -338,19 +372,21 @@ namespace extensions {
void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
const std::string& extension_id,
+ int disable_reasons,
const gfx::Image& icon) {
if (!service.get())
return;
const Extension* extension = service->GetInstalledExtension(extension_id);
if (extension) {
GlobalErrorServiceFactory::GetForProfile(service->profile())
- ->AddGlobalError(
- new ExtensionDisabledGlobalError(service.get(), extension, icon));
+ ->AddGlobalError(new ExtensionDisabledGlobalError(
+ service.get(), extension, disable_reasons, icon));
}
}
void AddExtensionDisabledError(ExtensionService* service,
- const Extension* extension) {
+ const Extension* extension,
+ int disable_reasons) {
// Do not display notifications for ephemeral apps that have been disabled.
// Instead, a prompt will be shown the next time the app is launched.
if (extension->is_ephemeral())
@@ -359,10 +395,14 @@ void AddExtensionDisabledError(ExtensionService* service,
extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
gfx::Size size(kIconSize, kIconSize);
- ImageLoader::Get(service->profile())->LoadImageAsync(
- extension, image, size,
- base::Bind(&AddExtensionDisabledErrorWithIcon,
- service->AsWeakPtr(), extension->id()));
+ ImageLoader::Get(service->profile())
+ ->LoadImageAsync(extension,
+ image,
+ size,
+ base::Bind(&AddExtensionDisabledErrorWithIcon,
+ service->AsWeakPtr(),
+ extension->id(),
+ disable_reasons));
}
void ShowExtensionDisabledDialog(ExtensionService* service,

Powered by Google App Engine
This is Rietveld 408576698