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

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

Issue 15745022: Add custom icon support to GlobalError. Show extension icon in permissions increase bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/global_error_bubble_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..afd1ee9cf299c15b2fbf1b755a995444441a3d7e 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,25 @@ void ExtensionDisabledGlobalError::Observe(
namespace extensions {
+void AddExtensionDisabledErrorWithIcon(ExtensionService* service,
+ const Extension* extension,
+ const gfx::Image& icon) {
+ 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, extension));
Matt Perry 2013/05/24 00:24:04 What happens if |service| or |extension| get delet
Yoyo Zhou 2013/05/24 00:47:11 Done.
}
void ShowExtensionDisabledDialog(ExtensionService* service,
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/global_error_bubble_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698