Chromium Code Reviews| Index: chrome/browser/extensions/extensions_ui.h |
| diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h |
| index 37e73b62ed1e574ae3a139eafef4fc07a37dd489..b2b82c2211aa4cb1fb58c0c6d802713e2aca0c07 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 more disabled. |
| + class IconLoader : public base::RefCountedThreadSafe<IconLoader> { |
| + public: |
| + 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,21 @@ class ExtensionsDOMHandler |
| std::vector<ExtensionPage> GetActivePagesForExtension( |
| const std::string& extension_id); |
| + // Returns the best icon to display in the UI for an extension, or NULL 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); |
| + |
| + // Tells the HTML about |json_data|. |
| + // Takes ownership of |json_data|. |
| + // Called on the UI thread. |
| + void OnIconsLoaded(DictionaryValue* json_data); |
| + |
| // Our model. |
| scoped_refptr<ExtensionsService> extensions_service_; |
| @@ -144,6 +195,9 @@ class ExtensionsDOMHandler |
| // Used to package the extension. |
| scoped_refptr<PackExtensionJob> pack_job_; |
| + // Used to load icons. |
|
Finnur
2009/11/05 03:55:08
nit: This comment is a bit scarce. Can you add: "a
|
| + scoped_refptr<IconLoader> icon_loader_; |
| + |
| // We monitor changes to the extension system so that we can reload when |
| // necessary. |
| NotificationRegistrar registrar_; |