summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extensions_ui.h
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 21:53:44 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 21:53:44 +0000
commit7c9493711c35829b0671696fe6c21275ad944527 (patch)
tree191baa59a9ac15cc1e9f94ea1c367e3a4ea64b75 /chrome/browser/extensions/extensions_ui.h
parentf17beb9308fd37274c7aa812a57f4083f164e4d4 (diff)
downloadchromium_src-7c9493711c35829b0671696fe6c21275ad944527.zip
chromium_src-7c9493711c35829b0671696fe6c21275ad944527.tar.gz
chromium_src-7c9493711c35829b0671696fe6c21275ad944527.tar.bz2
Fix bug where we were not displaying icons in the management
UI for disabled extensions. Also, desaturate the icons of disabled extensions to make them look more disabledy. BUG=25963 TEST=On the extensions page, disable an extension, then press reload. You should see a greyscale version of the icon. Review URL: http://codereview.chromium.org/360039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extensions_ui.h')
-rw-r--r--chrome/browser/extensions/extensions_ui.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h
index 37e73b6..6023255 100644
--- a/chrome/browser/extensions/extensions_ui.h
+++ b/chrome/browser/extensions/extensions_ui.h
@@ -12,6 +12,7 @@
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/extensions/pack_extension_job.h"
#include "chrome/browser/shell_dialogs.h"
+#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "googleurl/src/gurl.h"
@@ -57,6 +58,41 @@ class ExtensionsDOMHandler
public PackExtensionJob::Client,
public SelectFileDialog::Listener {
public:
+
+ // Helper class that loads the icons for the extensions in the management UI.
+ // We do this with native code instead of just using chrome-extension:// URLs
+ // for two reasons:
+ //
+ // 1. We need to support the disabled extensions, too, and using URLs won't
+ // work for them.
+ // 2. We want to desaturate the icons of the disabled extensions to make them
+ // look disabled.
+ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
+ public:
+ explicit IconLoader(ExtensionsDOMHandler* handler);
+
+ // Load |icons|. Will call handler->OnIconsLoaded when complete. IconLoader
+ // takes ownership of both arguments.
+ void LoadIcons(std::vector<ExtensionResource>* icons,
+ DictionaryValue* json);
+
+ // Cancel the load. IconLoader won't try to call back to the handler after
+ // this.
+ void Cancel();
+
+ private:
+ // Load the icons and call ReportResultOnUIThread when done. This method
+ // takes ownership of both arguments.
+ void LoadIconsOnFileThread(std::vector<ExtensionResource>* icons,
+ DictionaryValue* json);
+
+ // Report back to the handler. This method takes ownership of |json|.
+ void ReportResultOnUIThread(DictionaryValue* json);
+
+ // The handler we will report back to.
+ ExtensionsDOMHandler* handler_;
+ };
+
explicit ExtensionsDOMHandler(ExtensionsService* extension_service);
virtual ~ExtensionsDOMHandler();
@@ -135,6 +171,20 @@ class ExtensionsDOMHandler
std::vector<ExtensionPage> GetActivePagesForExtension(
const std::string& extension_id);
+ // Returns the best icon to display in the UI for an extension, or an empty
+ // ExtensionResource if no good icon exists.
+ ExtensionResource PickExtensionIcon(Extension* extension);
+
+ // Loads the extension resources into the json data, then calls OnIconsLoaded.
+ // Takes ownership of |icons|.
+ // Called on the file thread.
+ void LoadExtensionIcons(std::vector<ExtensionResource>* icons,
+ DictionaryValue* json_data);
+
+ // Takes ownership of |json_data| and tells HTML about it.
+ // Called on the UI thread.
+ void OnIconsLoaded(DictionaryValue* json_data);
+
// Our model.
scoped_refptr<ExtensionsService> extensions_service_;
@@ -144,6 +194,9 @@ class ExtensionsDOMHandler
// Used to package the extension.
scoped_refptr<PackExtensionJob> pack_job_;
+ // Used to load icons asynchronously on the file thread.
+ scoped_refptr<IconLoader> icon_loader_;
+
// We monitor changes to the extension system so that we can reload when
// necessary.
NotificationRegistrar registrar_;