| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PROVIDER_IMPL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 10 #include "chrome/browser/extensions/external_provider_interface.h" |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/extensions/external_extension_loader.h" | 13 #include "chrome/browser/extensions/external_loader.h" |
| 14 | 14 |
| 15 class ExternalExtensionLoader; | |
| 16 class Profile; | 15 class Profile; |
| 17 class Version; | 16 class Version; |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class DictionaryValue; | 19 class DictionaryValue; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace extensions { | 22 namespace extensions { |
| 24 class Extension; | 23 class Extension; |
| 25 } | 24 class ExternalLoader; |
| 26 | 25 |
| 27 // A specialization of the ExternalExtensionProvider that uses an instance | 26 // A specialization of the ExternalProvider that uses an instance of |
| 28 // of ExternalExtensionLoader to provide external extensions. This class | 27 // ExternalLoader to provide external extensions. This class can be seen as a |
| 29 // can be seen as a bridge between the extension system and an | 28 // bridge between the extension system and an ExternalLoader. Instances live |
| 30 // ExternalExtensionLoader. Instances live their entire life on the UI thread. | 29 // their entire life on the UI thread. |
| 31 class ExternalExtensionProviderImpl | 30 class ExternalProviderImpl : public ExternalProviderInterface { |
| 32 : public ExternalExtensionProviderInterface { | |
| 33 public: | 31 public: |
| 34 // The constructed provider will provide the extensions loaded from |loader| | 32 // The constructed provider will provide the extensions loaded from |loader| |
| 35 // to |service|, that will deal with the installation. The location | 33 // to |service|, that will deal with the installation. The location |
| 36 // attributes of the provided extensions are also specified here: | 34 // attributes of the provided extensions are also specified here: |
| 37 // |crx_location|: extensions originating from crx files | 35 // |crx_location|: extensions originating from crx files |
| 38 // |download_location|: extensions originating from update URLs | 36 // |download_location|: extensions originating from update URLs |
| 39 // If either of the origins is not supported by this provider, then it should | 37 // If either of the origins is not supported by this provider, then it should |
| 40 // be initialized as Extensions::INVALID. | 38 // be initialized as Extensions::INVALID. |
| 41 ExternalExtensionProviderImpl( | 39 ExternalProviderImpl(VisitorInterface* service, |
| 42 VisitorInterface* service, | 40 ExternalLoader* loader, |
| 43 ExternalExtensionLoader* loader, | 41 Extension::Location crx_location, |
| 44 extensions::Extension::Location crx_location, | 42 Extension::Location download_location, |
| 45 extensions::Extension::Location download_location, | 43 int creation_flags); |
| 46 int creation_flags); | |
| 47 | 44 |
| 48 virtual ~ExternalExtensionProviderImpl(); | 45 virtual ~ExternalProviderImpl(); |
| 49 | 46 |
| 50 // Populates a list with providers for all known sources. | 47 // Populates a list with providers for all known sources. |
| 51 static void CreateExternalProviders( | 48 static void CreateExternalProviders( |
| 52 VisitorInterface* service, | 49 VisitorInterface* service, |
| 53 Profile* profile, | 50 Profile* profile, |
| 54 ProviderCollection* provider_list); | 51 ProviderCollection* provider_list); |
| 55 | 52 |
| 56 // 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 |
| 57 // owned ExternalExtensionLoader instance. | 54 // owned ExternalLoader instance. |
| 58 void SetPrefs(base::DictionaryValue* prefs); | 55 void SetPrefs(base::DictionaryValue* prefs); |
| 59 | 56 |
| 60 // ExternalExtensionProvider implementation: | 57 // ExternalProvider implementation: |
| 61 virtual void ServiceShutdown() OVERRIDE; | 58 virtual void ServiceShutdown() OVERRIDE; |
| 62 virtual void VisitRegisteredExtension() OVERRIDE; | 59 virtual void VisitRegisteredExtension() OVERRIDE; |
| 63 virtual bool HasExtension(const std::string& id) const OVERRIDE; | 60 virtual bool HasExtension(const std::string& id) const OVERRIDE; |
| 64 virtual bool GetExtensionDetails(const std::string& id, | 61 virtual bool GetExtensionDetails(const std::string& id, |
| 65 extensions::Extension::Location* location, | 62 Extension::Location* location, |
| 66 scoped_ptr<Version>* version) const OVERRIDE; | 63 scoped_ptr<Version>* version) const OVERRIDE; |
| 67 | 64 |
| 68 virtual bool IsReady() const OVERRIDE; | 65 virtual bool IsReady() const OVERRIDE; |
| 69 | 66 |
| 70 static const char kExternalCrx[]; | 67 static const char kExternalCrx[]; |
| 71 static const char kExternalVersion[]; | 68 static const char kExternalVersion[]; |
| 72 static const char kExternalUpdateUrl[]; | 69 static const char kExternalUpdateUrl[]; |
| 73 static const char kSupportedLocales[]; | 70 static const char kSupportedLocales[]; |
| 74 static const char kIsBookmarkApp[]; | 71 static const char kIsBookmarkApp[]; |
| 75 | 72 |
| 76 void set_auto_acknowledge(bool auto_acknowledge) { | 73 void set_auto_acknowledge(bool auto_acknowledge) { |
| 77 auto_acknowledge_ = auto_acknowledge; | 74 auto_acknowledge_ = auto_acknowledge; |
| 78 } | 75 } |
| 79 | 76 |
| 80 private: | 77 private: |
| 81 // Location for external extensions that are provided by this provider from | 78 // Location for external extensions that are provided by this provider from |
| 82 // local crx files. | 79 // local crx files. |
| 83 const extensions::Extension::Location crx_location_; | 80 const Extension::Location crx_location_; |
| 84 | 81 |
| 85 // Location for external extensions that are provided by this provider from | 82 // Location for external extensions that are provided by this provider from |
| 86 // update URLs. | 83 // update URLs. |
| 87 const extensions::Extension::Location download_location_; | 84 const Extension::Location download_location_; |
| 88 | 85 |
| 89 // Weak pointer to the object that consumes the external extensions. | 86 // Weak pointer to the object that consumes the external extensions. |
| 90 // This is zeroed out by: ServiceShutdown() | 87 // This is zeroed out by: ServiceShutdown() |
| 91 VisitorInterface* service_; // weak | 88 VisitorInterface* service_; // weak |
| 92 | 89 |
| 93 // Dictionary of the external extensions that are provided by this provider. | 90 // Dictionary of the external extensions that are provided by this provider. |
| 94 scoped_ptr<base::DictionaryValue> prefs_; | 91 scoped_ptr<base::DictionaryValue> prefs_; |
| 95 | 92 |
| 96 // Indicates that the extensions provided by this provider are loaded | 93 // Indicates that the extensions provided by this provider are loaded |
| 97 // entirely. | 94 // entirely. |
| 98 bool ready_; | 95 bool ready_; |
| 99 | 96 |
| 100 // The loader that loads the list of external extensions and reports them | 97 // The loader that loads the list of external extensions and reports them |
| 101 // via |SetPrefs|. | 98 // via |SetPrefs|. |
| 102 scoped_refptr<ExternalExtensionLoader> loader_; | 99 scoped_refptr<ExternalLoader> loader_; |
| 103 | 100 |
| 104 // Creation flags to use for the extension. These flags will be used | 101 // Creation flags to use for the extension. These flags will be used |
| 105 // when calling Extenion::Create() by the crx installer. | 102 // when calling Extenion::Create() by the crx installer. |
| 106 int creation_flags_; | 103 int creation_flags_; |
| 107 | 104 |
| 108 // Whether loaded extensions should be automatically acknowledged, so that | 105 // Whether loaded extensions should be automatically acknowledged, so that |
| 109 // the user doesn't see an alert about them. | 106 // the user doesn't see an alert about them. |
| 110 bool auto_acknowledge_; | 107 bool auto_acknowledge_; |
| 111 | 108 |
| 112 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); | 109 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl); |
| 113 }; | 110 }; |
| 114 | 111 |
| 115 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 112 } // namespace extensions |
| 113 |
| 114 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_ |
| OLD | NEW |