Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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.h" | |
| 10 | |
| 11 #include "base/lock.h" | |
| 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 leave their entire life on the UI thread. | |
|
Sam Kerner (Chrome)
2011/01/04 14:06:00
leave -> live
gfeher
2011/01/04 23:37:09
Done.
| |
| 25 class ExternalExtensionProviderImpl : public ExternalExtensionProvider { | |
| 26 public: | |
| 27 // The constructed provider will provide the extensions loaded from |loader| | |
| 28 // to |service|, that will deal with the installation. The location | |
| 29 // attributes of the provided extensions are also specified here: | |
| 30 // |crx_location|: extensions originating from crx files | |
| 31 // |download_location|: extensions originating from update URLs | |
| 32 // If either of the origins is not supported by this provider, then it should | |
| 33 // be initialized as Extensions::INVALID. | |
| 34 ExternalExtensionProviderImpl( | |
| 35 Visitor* service, | |
| 36 ExternalExtensionLoader* loader, | |
| 37 Extension::Location crx_location, | |
| 38 Extension::Location download_location); | |
| 39 | |
| 40 virtual ~ExternalExtensionProviderImpl(); | |
| 41 | |
| 42 // Populates a list with providers for all known sources. | |
| 43 static void CreateExternalProviders( | |
| 44 Visitor* service, | |
| 45 Profile* profile, | |
| 46 ProviderCollection* provider_list); | |
| 47 | |
| 48 // Sets underlying prefs and notifies provider. Only to be called by the | |
| 49 // owned ExternalExtensionLoader instance. | |
| 50 void SetPrefs(DictionaryValue* prefs); | |
| 51 | |
| 52 // ExternalExtensionProvider implementation: | |
| 53 virtual void VisitRegisteredExtension() const; | |
| 54 | |
| 55 virtual bool HasExtension(const std::string& id) const; | |
| 56 | |
| 57 virtual bool GetExtensionDetails(const std::string& id, | |
| 58 Extension::Location* location, | |
| 59 scoped_ptr<Version>* version) const; | |
| 60 | |
| 61 virtual void ServiceShutdown(); | |
| 62 | |
| 63 virtual bool IsReady(); | |
| 64 | |
| 65 static const char kLocation[]; | |
| 66 static const char kState[]; | |
| 67 static const char kExternalCrx[]; | |
| 68 static const char kExternalVersion[]; | |
| 69 static const char kExternalUpdateUrl[]; | |
| 70 | |
| 71 private: | |
| 72 // Location for external extensions that are provided by this provider from | |
| 73 // local crx files. | |
| 74 const Extension::Location crx_location_; | |
| 75 // Location for external extensions that are provided by this provider from | |
| 76 // update URLs. | |
| 77 const Extension::Location download_location_; | |
| 78 | |
| 79 private: | |
| 80 // Weak pointer to the object that consumes the external extensions. | |
| 81 // This is zeroed out by: ServiceShutdown() | |
| 82 Visitor* service_; // weak | |
| 83 | |
| 84 // Dictionary of the external extensions that are provided by this provider. | |
| 85 scoped_ptr<DictionaryValue> prefs_; | |
| 86 | |
| 87 // Indicates that the extensions provided by this provider are loaded | |
| 88 // entirely. | |
| 89 bool ready_; | |
| 90 | |
| 91 // The loader that loads the list of external extensions and reports them | |
| 92 // via |SetPrefs|. | |
| 93 scoped_refptr<ExternalExtensionLoader> loader_; | |
| 94 }; | |
|
jochen (gone - plz use gerrit)
2011/01/04 12:38:01
disallow copy and assign?
gfeher
2011/01/04 23:37:09
Done.
| |
| 95 | |
| 96 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | |
| OLD | NEW |