Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "chrome/browser/extensions/external_extension_provider_interface.h" | |
| 10 | |
| 11 #include "base/lock.h" | |
|
Aaron Boodman
2011/01/06 18:54:40
Doesn't appear to be used?
gfeher
2011/01/07 00:10:01
Done.
| |
| 12 #include "base/ref_counted.h" | |
| 13 #include "chrome/browser/extensions/external_extension_loader.h" | |
| 14 | |
| 15 class DictionaryValue; | |
| 16 class ExternalExtensionLoader; | |
| 17 class Profile; | |
| 18 class ValueSerializer; | |
| 19 class Version; | |
| 20 | |
| 21 // A specialization of the ExternalExtensionProvider that uses an instance | |
| 22 // of ExternalExtensionLoader to provide external extensions. This class | |
| 23 // can be seen as a bridge between the extension system and an | |
| 24 // ExternalExtensionLoader. Instances live their entire life on the UI thread. | |
| 25 class ExternalExtensionProviderImpl | |
| 26 : public ExternalExtensionProviderInterface { | |
| 27 public: | |
| 28 // The constructed provider will provide the extensions loaded from |loader| | |
| 29 // to |service|, that will deal with the installation. The location | |
| 30 // attributes of the provided extensions are also specified here: | |
| 31 // |crx_location|: extensions originating from crx files | |
| 32 // |download_location|: extensions originating from update URLs | |
| 33 // If either of the origins is not supported by this provider, then it should | |
| 34 // be initialized as Extensions::INVALID. | |
| 35 ExternalExtensionProviderImpl( | |
| 36 VisitorInterface* service, | |
| 37 ExternalExtensionLoader* loader, | |
| 38 Extension::Location crx_location, | |
| 39 Extension::Location download_location); | |
| 40 | |
| 41 virtual ~ExternalExtensionProviderImpl(); | |
| 42 | |
| 43 // Populates a list with providers for all known sources. | |
| 44 static void CreateExternalProviders( | |
| 45 VisitorInterface* service, | |
| 46 Profile* profile, | |
| 47 ProviderCollection* provider_list); | |
| 48 | |
| 49 // Sets underlying prefs and notifies provider. Only to be called by the | |
| 50 // owned ExternalExtensionLoader instance. | |
| 51 void SetPrefs(DictionaryValue* prefs); | |
| 52 | |
| 53 // ExternalExtensionProvider implementation: | |
| 54 virtual void VisitRegisteredExtension() const; | |
| 55 | |
| 56 virtual bool HasExtension(const std::string& id) const; | |
| 57 | |
| 58 virtual bool GetExtensionDetails(const std::string& id, | |
| 59 Extension::Location* location, | |
| 60 scoped_ptr<Version>* version) const; | |
| 61 | |
| 62 virtual void ServiceShutdown(); | |
| 63 | |
| 64 virtual bool IsReady(); | |
| 65 | |
| 66 static const char kLocation[]; | |
| 67 static const char kState[]; | |
| 68 static const char kExternalCrx[]; | |
| 69 static const char kExternalVersion[]; | |
| 70 static const char kExternalUpdateUrl[]; | |
| 71 | |
| 72 private: | |
| 73 // Location for external extensions that are provided by this provider from | |
| 74 // local crx files. | |
| 75 const Extension::Location crx_location_; | |
| 76 // Location for external extensions that are provided by this provider from | |
|
Aaron Boodman
2011/01/06 18:54:40
Add a blank line above here.
gfeher
2011/01/07 00:10:01
Done.
| |
| 77 // update URLs. | |
| 78 const Extension::Location download_location_; | |
| 79 | |
| 80 private: | |
| 81 // Weak pointer to the object that consumes the external extensions. | |
| 82 // This is zeroed out by: ServiceShutdown() | |
| 83 VisitorInterface* service_; // weak | |
| 84 | |
| 85 // Dictionary of the external extensions that are provided by this provider. | |
| 86 scoped_ptr<DictionaryValue> prefs_; | |
| 87 | |
| 88 // Indicates that the extensions provided by this provider are loaded | |
| 89 // entirely. | |
| 90 bool ready_; | |
| 91 | |
| 92 // The loader that loads the list of external extensions and reports them | |
| 93 // via |SetPrefs|. | |
| 94 scoped_refptr<ExternalExtensionLoader> loader_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); | |
| 97 }; | |
| 98 | |
| 99 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | |
| OLD | NEW |