Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 9 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/extensions/external_extension_loader.h" | 12 #include "chrome/browser/extensions/external_extension_loader.h" |
| 13 #include "content/common/notification_observer.h" | |
| 14 #include "content/common/notification_registrar.h" | |
| 13 | 15 |
| 14 class ExternalExtensionLoader; | 16 class ExternalExtensionLoader; |
| 15 class Profile; | 17 class Profile; |
| 16 class Version; | 18 class Version; |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class DictionaryValue; | 21 class DictionaryValue; |
| 20 class ValueSerializer; | 22 class ValueSerializer; |
| 21 } | 23 } |
| 22 | 24 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 43 virtual ~ExternalExtensionProviderImpl(); | 45 virtual ~ExternalExtensionProviderImpl(); |
| 44 | 46 |
| 45 // Populates a list with providers for all known sources. | 47 // Populates a list with providers for all known sources. |
| 46 static void CreateExternalProviders( | 48 static void CreateExternalProviders( |
| 47 VisitorInterface* service, | 49 VisitorInterface* service, |
| 48 Profile* profile, | 50 Profile* profile, |
| 49 ProviderCollection* provider_list); | 51 ProviderCollection* provider_list); |
| 50 | 52 |
| 51 // Sets underlying prefs and notifies provider. Only to be called by the | 53 // Sets underlying prefs and notifies provider. Only to be called by the |
| 52 // owned ExternalExtensionLoader instance. | 54 // owned ExternalExtensionLoader instance. |
| 53 void SetPrefs(base::DictionaryValue* prefs); | 55 virtual void SetPrefs(base::DictionaryValue* prefs); |
|
Mihai Parparita -not on Chrome
2011/10/19 07:31:36
I'm getting uncomfortable with the increased overr
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
I could create a separate implementation of Extern
| |
| 54 | 56 |
| 55 // ExternalExtensionProvider implementation: | 57 // ExternalExtensionProvider implementation: |
| 56 virtual void ServiceShutdown() OVERRIDE; | 58 virtual void ServiceShutdown() OVERRIDE; |
| 57 virtual void VisitRegisteredExtension() const OVERRIDE; | 59 virtual void VisitRegisteredExtension() const OVERRIDE; |
| 58 virtual bool HasExtension(const std::string& id) const OVERRIDE; | 60 virtual bool HasExtension(const std::string& id) const OVERRIDE; |
| 59 virtual bool GetExtensionDetails(const std::string& id, | 61 virtual bool GetExtensionDetails(const std::string& id, |
| 60 Extension::Location* location, | 62 Extension::Location* location, |
| 61 scoped_ptr<Version>* version) const OVERRIDE; | 63 scoped_ptr<Version>* version) const OVERRIDE; |
| 62 | 64 |
| 63 virtual bool IsReady(); | 65 virtual bool IsReady(); |
| 64 | 66 |
| 65 static const char kLocation[]; | 67 static const char kLocation[]; |
| 66 static const char kState[]; | 68 static const char kState[]; |
| 67 static const char kExternalCrx[]; | 69 static const char kExternalCrx[]; |
| 68 static const char kExternalVersion[]; | 70 static const char kExternalVersion[]; |
| 69 static const char kExternalUpdateUrl[]; | 71 static const char kExternalUpdateUrl[]; |
| 70 static const char kSupportedLocales[]; | 72 static const char kSupportedLocales[]; |
| 71 | 73 |
| 74 // Used only for testing. | |
| 75 const std::set<std::string>& invalid_extensions() const { | |
| 76 return invalid_extensions_; | |
| 77 } | |
| 78 | |
| 72 protected: | 79 protected: |
| 73 VisitorInterface* service() const { return service_; } | 80 VisitorInterface* service() const { return service_; } |
| 74 | 81 |
| 82 base::DictionaryValue* prefs() const { return prefs_.get(); } | |
| 83 | |
| 75 private: | 84 private: |
| 76 // Location for external extensions that are provided by this provider from | 85 // Location for external extensions that are provided by this provider from |
| 77 // local crx files. | 86 // local crx files. |
| 78 const Extension::Location crx_location_; | 87 const Extension::Location crx_location_; |
| 79 | 88 |
| 80 // Location for external extensions that are provided by this provider from | 89 // Location for external extensions that are provided by this provider from |
| 81 // update URLs. | 90 // update URLs. |
| 82 const Extension::Location download_location_; | 91 const Extension::Location download_location_; |
| 83 | 92 |
| 84 // Weak pointer to the object that consumes the external extensions. | 93 // Weak pointer to the object that consumes the external extensions. |
| 85 // This is zeroed out by: ServiceShutdown() | 94 // This is zeroed out by: ServiceShutdown() |
| 86 VisitorInterface* service_; // weak | 95 VisitorInterface* service_; // weak |
| 87 | 96 |
| 88 // Dictionary of the external extensions that are provided by this provider. | 97 // Dictionary of the external extensions that are provided by this provider. |
| 89 scoped_ptr<base::DictionaryValue> prefs_; | 98 scoped_ptr<base::DictionaryValue> prefs_; |
| 90 | 99 |
| 91 // Indicates that the extensions provided by this provider are loaded | 100 // Indicates that the extensions provided by this provider are loaded |
| 92 // entirely. | 101 // entirely. |
| 93 bool ready_; | 102 bool ready_; |
| 94 | 103 |
| 95 // The loader that loads the list of external extensions and reports them | 104 // The loader that loads the list of external extensions and reports them |
| 96 // via |SetPrefs|. | 105 // via |SetPrefs|. |
| 97 scoped_refptr<ExternalExtensionLoader> loader_; | 106 scoped_refptr<ExternalExtensionLoader> loader_; |
| 98 | 107 |
| 108 // Extensions that were found to be invalid while processing the prefs_ | |
| 109 // dictionary. These are extensions that this provider did not even attempt | |
| 110 // to install because they failed one or more of the checks in SetPrefs(). | |
| 111 // | |
| 112 // TODO(mihai): It would be nice to simply remove these extensions from | |
| 113 // prefs_, but for now, there is code that depends on these invalid extensions | |
|
Mihai Parparita -not on Chrome
2011/10/19 07:31:36
What code are you referring to here?
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
If you look at patch set #1 of this CL, I was addi
| |
| 114 // still being available to HasExtension(). See how to fix this. | |
| 115 std::set<std::string> invalid_extensions_; | |
| 116 | |
| 99 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); | 117 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); |
| 100 }; | 118 }; |
| 101 | 119 |
| 120 #if !defined(OS_CHROMEOS) | |
| 121 class DefaultAppsProvider : public ExternalExtensionProviderImpl, | |
|
Mihai Parparita -not on Chrome
2011/10/19 07:31:36
Now that you're exposing this class in the header
Finnur
2011/10/19 10:01:29
+1
On 2011/10/19 07:31:36, Mihai Parparita wrote:
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
Done.
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
Done.
| |
| 122 public NotificationObserver { | |
| 123 public: | |
| 124 DefaultAppsProvider(VisitorInterface* service, | |
| 125 ExternalExtensionLoader* loader, | |
| 126 Profile* profile); | |
| 127 virtual ~DefaultAppsProvider(); | |
| 128 | |
| 129 // ExternalExtensionProviderImpl overrides: | |
| 130 virtual void SetPrefs(base::DictionaryValue* prefs) OVERRIDE; | |
| 131 virtual void ServiceShutdown() OVERRIDE; | |
| 132 virtual void VisitRegisteredExtension() const OVERRIDE; | |
| 133 | |
| 134 // Implementation of NotificationObserver: | |
| 135 virtual void Observe(int type, | |
| 136 const NotificationSource& source, | |
| 137 const NotificationDetails& details) OVERRIDE; | |
| 138 | |
| 139 // Used only for testing. | |
| 140 const std::set<std::string>& install_error_extensions() const { | |
| 141 return install_error_extensions_; | |
| 142 } | |
| 143 | |
| 144 enum InstallState { | |
|
Finnur
2011/10/19 10:01:29
Perhaps document that the values of these enums ar
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
Done.
| |
| 145 kInstallNotStarted, | |
| 146 kInstalling, | |
| 147 kInstallDone | |
| 148 }; | |
|
Finnur
2011/10/19 10:01:29
nit: enum should be at the top of the public secti
Roger Tawa OOO till Jul 10th
2011/10/19 20:48:25
Done.
| |
| 149 | |
| 150 private: | |
| 151 Profile* profile_; | |
| 152 NotificationRegistrar registrar_; | |
| 153 | |
| 154 // Set of extensions that failed to install for some reason. | |
| 155 std::set<std::string> install_error_extensions_; | |
| 156 | |
| 157 DISALLOW_COPY_AND_ASSIGN(DefaultAppsProvider); | |
| 158 }; | |
| 159 #endif | |
| 160 | |
| 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 161 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ |
| OLD | NEW |