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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 virtual ~ExternalExtensionProviderImpl(); | 43 virtual ~ExternalExtensionProviderImpl(); |
44 | 44 |
45 // Populates a list with providers for all known sources. | 45 // Populates a list with providers for all known sources. |
46 static void CreateExternalProviders( | 46 static void CreateExternalProviders( |
47 VisitorInterface* service, | 47 VisitorInterface* service, |
48 Profile* profile, | 48 Profile* profile, |
49 ProviderCollection* provider_list); | 49 ProviderCollection* provider_list); |
50 | 50 |
51 // Sets underlying prefs and notifies provider. Only to be called by the | 51 // Sets underlying prefs and notifies provider. Only to be called by the |
52 // owned ExternalExtensionLoader instance. | 52 // owned ExternalExtensionLoader instance. |
53 void SetPrefs(base::DictionaryValue* prefs); | 53 virtual void SetPrefs(base::DictionaryValue* prefs); |
54 | 54 |
55 // ExternalExtensionProvider implementation: | 55 // ExternalExtensionProvider implementation: |
56 virtual void ServiceShutdown() OVERRIDE; | 56 virtual void ServiceShutdown() OVERRIDE; |
57 virtual void VisitRegisteredExtension() const OVERRIDE; | 57 virtual void VisitRegisteredExtension() const OVERRIDE; |
58 virtual bool HasExtension(const std::string& id) const OVERRIDE; | 58 virtual bool HasExtension(const std::string& id) const OVERRIDE; |
59 virtual bool GetExtensionDetails(const std::string& id, | 59 virtual bool GetExtensionDetails(const std::string& id, |
60 Extension::Location* location, | 60 Extension::Location* location, |
61 scoped_ptr<Version>* version) const OVERRIDE; | 61 scoped_ptr<Version>* version) const OVERRIDE; |
62 | 62 |
63 virtual bool IsReady(); | 63 virtual bool IsReady(); |
64 | 64 |
65 static const char kLocation[]; | 65 static const char kLocation[]; |
66 static const char kState[]; | 66 static const char kState[]; |
67 static const char kExternalCrx[]; | 67 static const char kExternalCrx[]; |
68 static const char kExternalVersion[]; | 68 static const char kExternalVersion[]; |
69 static const char kExternalUpdateUrl[]; | 69 static const char kExternalUpdateUrl[]; |
70 static const char kSupportedLocales[]; | 70 static const char kSupportedLocales[]; |
71 | 71 |
72 // Used only for testing. | |
73 const std::set<std::string>& invalid_extensions() const { | |
74 return invalid_extensions_; | |
75 } | |
76 | |
72 protected: | 77 protected: |
73 VisitorInterface* service() const { return service_; } | 78 VisitorInterface* service() const { return service_; } |
74 | 79 |
80 base::DictionaryValue* prefs() const { return prefs_.get(); } | |
81 | |
75 private: | 82 private: |
76 // Location for external extensions that are provided by this provider from | 83 // Location for external extensions that are provided by this provider from |
77 // local crx files. | 84 // local crx files. |
78 const Extension::Location crx_location_; | 85 const Extension::Location crx_location_; |
79 | 86 |
80 // Location for external extensions that are provided by this provider from | 87 // Location for external extensions that are provided by this provider from |
81 // update URLs. | 88 // update URLs. |
82 const Extension::Location download_location_; | 89 const Extension::Location download_location_; |
83 | 90 |
84 // Weak pointer to the object that consumes the external extensions. | 91 // Weak pointer to the object that consumes the external extensions. |
85 // This is zeroed out by: ServiceShutdown() | 92 // This is zeroed out by: ServiceShutdown() |
86 VisitorInterface* service_; // weak | 93 VisitorInterface* service_; // weak |
87 | 94 |
88 // Dictionary of the external extensions that are provided by this provider. | 95 // Dictionary of the external extensions that are provided by this provider. |
89 scoped_ptr<base::DictionaryValue> prefs_; | 96 scoped_ptr<base::DictionaryValue> prefs_; |
90 | 97 |
91 // Indicates that the extensions provided by this provider are loaded | 98 // Indicates that the extensions provided by this provider are loaded |
92 // entirely. | 99 // entirely. |
93 bool ready_; | 100 bool ready_; |
94 | 101 |
95 // The loader that loads the list of external extensions and reports them | 102 // The loader that loads the list of external extensions and reports them |
96 // via |SetPrefs|. | 103 // via |SetPrefs|. |
97 scoped_refptr<ExternalExtensionLoader> loader_; | 104 scoped_refptr<ExternalExtensionLoader> loader_; |
98 | 105 |
106 // Extensions that were found to be invalid while processing the prefs_ | |
107 // dictionary. These are extensions that this provider did not even attempt | |
108 // to install because they failed one or more of the checks in SetPrefs(). | |
109 // | |
110 // TODO(mihai): It would be nice to simply remove these extensions from | |
111 // prefs_, but for now, there is code that depends on these invalid extensions | |
Mihai Parparita -not on Chrome
2011/10/20 02:30:25
I didn't mean that there was code that relies on t
Roger Tawa OOO till Jul 10th
2011/10/20 14:31:15
OK. I think it would be better to have the commen
| |
112 // still being available to HasExtension(). See how to fix this. | |
113 std::set<std::string> invalid_extensions_; | |
114 | |
99 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); | 115 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); |
100 }; | 116 }; |
101 | 117 |
102 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ | 118 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_ |
OLD | NEW |