Chromium Code Reviews| 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 a39a0b5486255d7812c247460927d4efe3d69d2f..8183c0797f1514db1235c8c34d9f8dd5086fa680 100644 |
| --- a/chrome/browser/extensions/extension_disabled_ui.cc |
| +++ b/chrome/browser/extensions/extension_disabled_ui.cc |
| @@ -18,6 +18,7 @@ |
| #include "chrome/browser/extensions/extension_install_ui.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| +#include "chrome/browser/extensions/image_loader.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/global_error/global_error.h" |
| @@ -26,6 +27,8 @@ |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/extensions/extension.h" |
| +#include "chrome/common/extensions/extension_icon_set.h" |
| +#include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| #include "chrome/common/extensions/permissions/permission_set.h" |
| #include "content/public/browser/notification_details.h" |
| #include "content/public/browser/notification_observer.h" |
| @@ -35,6 +38,8 @@ |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#include "ui/gfx/image/image.h" |
| +#include "ui/gfx/size.h" |
| using extensions::Extension; |
| @@ -131,7 +136,8 @@ class ExtensionDisabledGlobalError : public GlobalError, |
| public ExtensionUninstallDialog::Delegate { |
| public: |
| ExtensionDisabledGlobalError(ExtensionService* service, |
| - const Extension* extension); |
| + const Extension* extension, |
| + const gfx::Image& icon); |
| virtual ~ExtensionDisabledGlobalError(); |
| // GlobalError implementation. |
| @@ -141,6 +147,7 @@ class ExtensionDisabledGlobalError : public GlobalError, |
| virtual string16 MenuItemLabel() OVERRIDE; |
| virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
| virtual bool HasBubbleView() OVERRIDE; |
| + virtual gfx::Image* GetBubbleViewCustomIcon() OVERRIDE; |
| virtual string16 GetBubbleViewTitle() OVERRIDE; |
| virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; |
| virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
| @@ -161,6 +168,7 @@ class ExtensionDisabledGlobalError : public GlobalError, |
| private: |
| ExtensionService* service_; |
| const Extension* extension_; |
| + gfx::Image icon_; |
| // How the user responded to the error; used for metrics. |
| enum UserResponse { |
| @@ -182,9 +190,11 @@ class ExtensionDisabledGlobalError : public GlobalError, |
| // TODO(yoz): create error at startup for disabled extensions. |
| ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( |
| ExtensionService* service, |
| - const Extension* extension) |
| + const Extension* extension, |
| + const gfx::Image& icon) |
| : service_(service), |
| extension_(extension), |
| + icon_(icon), |
| user_response_(IGNORED), |
| menu_command_id_(GetMenuCommandID()) { |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| @@ -225,6 +235,12 @@ bool ExtensionDisabledGlobalError::HasBubbleView() { |
| return true; |
| } |
| +gfx::Image* ExtensionDisabledGlobalError::GetBubbleViewCustomIcon() { |
| + if (icon_.IsEmpty()) |
| + return NULL; |
| + return &icon_; |
| +} |
| + |
| string16 ExtensionDisabledGlobalError::GetBubbleViewTitle() { |
| return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, |
| UTF8ToUTF16(extension_->name())); |
| @@ -319,10 +335,31 @@ void ExtensionDisabledGlobalError::Observe( |
| namespace extensions { |
| +void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, |
|
Matt Perry
2013/05/24 00:54:44
Is Bind smart enough to handle WeakPtrs as argumen
|
| + const std::string& extension_id, |
| + 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, extension, icon)); |
| + } |
| +} |
| + |
| void AddExtensionDisabledError(ExtensionService* service, |
| const Extension* extension) { |
| - GlobalErrorServiceFactory::GetForProfile(service->profile())-> |
| - AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); |
| + extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( |
| + extension, |
| + extension_misc::EXTENSION_ICON_SMALL, |
| + ExtensionIconSet::MATCH_BIGGER); |
| + gfx::Size size(extension_misc::EXTENSION_ICON_SMALL, |
| + extension_misc::EXTENSION_ICON_SMALL); |
| + ImageLoader::Get(service->profile())->LoadImageAsync( |
| + extension, image, size, |
| + base::Bind(&AddExtensionDisabledErrorWithIcon, |
| + service->AsWeakPtr(), extension->id())); |
| } |
| void ShowExtensionDisabledDialog(ExtensionService* service, |