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_PROVIDER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_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_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_loader.h" | 13 #include "chrome/browser/extensions/external_loader.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 class Version; | 16 class Version; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 class Extension; | |
24 class ExternalLoader; | 23 class ExternalLoader; |
24 class Manifest; | |
Jeffrey Yasskin
2013/01/29 22:54:07
If you're using Manifest::anything, a forward decl
Yoyo Zhou
2013/01/30 01:16:01
Done.
| |
25 | 25 |
26 // A specialization of the ExternalProvider that uses an instance of | 26 // A specialization of the ExternalProvider that uses an instance of |
27 // ExternalLoader to provide external extensions. This class can be seen as a | 27 // ExternalLoader to provide external extensions. This class can be seen as a |
28 // bridge between the extension system and an ExternalLoader. Instances live | 28 // bridge between the extension system and an ExternalLoader. Instances live |
29 // their entire life on the UI thread. | 29 // their entire life on the UI thread. |
30 class ExternalProviderImpl : public ExternalProviderInterface { | 30 class ExternalProviderImpl : public ExternalProviderInterface { |
31 public: | 31 public: |
32 // The constructed provider will provide the extensions loaded from |loader| | 32 // The constructed provider will provide the extensions loaded from |loader| |
33 // to |service|, that will deal with the installation. The location | 33 // to |service|, that will deal with the installation. The location |
34 // attributes of the provided extensions are also specified here: | 34 // attributes of the provided extensions are also specified here: |
35 // |crx_location|: extensions originating from crx files | 35 // |crx_location|: extensions originating from crx files |
36 // |download_location|: extensions originating from update URLs | 36 // |download_location|: extensions originating from update URLs |
37 // 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 |
38 // be initialized as Extensions::INVALID. | 38 // be initialized as Manifest::INVALID_LOCATION. |
39 ExternalProviderImpl(VisitorInterface* service, | 39 ExternalProviderImpl(VisitorInterface* service, |
40 ExternalLoader* loader, | 40 ExternalLoader* loader, |
41 Extension::Location crx_location, | 41 Manifest::Location crx_location, |
42 Extension::Location download_location, | 42 Manifest::Location download_location, |
43 int creation_flags); | 43 int creation_flags); |
44 | 44 |
45 virtual ~ExternalProviderImpl(); | 45 virtual ~ExternalProviderImpl(); |
46 | 46 |
47 // Populates a list with providers for all known sources. | 47 // Populates a list with providers for all known sources. |
48 static void CreateExternalProviders( | 48 static void CreateExternalProviders( |
49 VisitorInterface* service, | 49 VisitorInterface* service, |
50 Profile* profile, | 50 Profile* profile, |
51 ProviderCollection* provider_list); | 51 ProviderCollection* provider_list); |
52 | 52 |
53 // 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 |
54 // owned ExternalLoader instance. | 54 // owned ExternalLoader instance. |
55 virtual void SetPrefs(base::DictionaryValue* prefs); | 55 virtual void SetPrefs(base::DictionaryValue* prefs); |
56 | 56 |
57 // ExternalProvider implementation: | 57 // ExternalProvider implementation: |
58 virtual void ServiceShutdown() OVERRIDE; | 58 virtual void ServiceShutdown() OVERRIDE; |
59 virtual void VisitRegisteredExtension() OVERRIDE; | 59 virtual void VisitRegisteredExtension() OVERRIDE; |
60 virtual bool HasExtension(const std::string& id) const OVERRIDE; | 60 virtual bool HasExtension(const std::string& id) const OVERRIDE; |
61 virtual bool GetExtensionDetails(const std::string& id, | 61 virtual bool GetExtensionDetails(const std::string& id, |
62 Extension::Location* location, | 62 Manifest::Location* location, |
63 scoped_ptr<Version>* version) const OVERRIDE; | 63 scoped_ptr<Version>* version) const OVERRIDE; |
64 | 64 |
65 virtual bool IsReady() const OVERRIDE; | 65 virtual bool IsReady() const OVERRIDE; |
66 | 66 |
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 static const char kIsBookmarkApp[]; | 71 static const char kIsBookmarkApp[]; |
72 static const char kIsFromWebstore[]; | 72 static const char kIsFromWebstore[]; |
73 | 73 |
74 void set_auto_acknowledge(bool auto_acknowledge) { | 74 void set_auto_acknowledge(bool auto_acknowledge) { |
75 auto_acknowledge_ = auto_acknowledge; | 75 auto_acknowledge_ = auto_acknowledge; |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 // Location for external extensions that are provided by this provider from | 79 // Location for external extensions that are provided by this provider from |
80 // local crx files. | 80 // local crx files. |
81 const Extension::Location crx_location_; | 81 const Manifest::Location crx_location_; |
82 | 82 |
83 // Location for external extensions that are provided by this provider from | 83 // Location for external extensions that are provided by this provider from |
84 // update URLs. | 84 // update URLs. |
85 const Extension::Location download_location_; | 85 const Manifest::Location download_location_; |
86 | 86 |
87 // Weak pointer to the object that consumes the external extensions. | 87 // Weak pointer to the object that consumes the external extensions. |
88 // This is zeroed out by: ServiceShutdown() | 88 // This is zeroed out by: ServiceShutdown() |
89 VisitorInterface* service_; // weak | 89 VisitorInterface* service_; // weak |
90 | 90 |
91 // Dictionary of the external extensions that are provided by this provider. | 91 // Dictionary of the external extensions that are provided by this provider. |
92 scoped_ptr<base::DictionaryValue> prefs_; | 92 scoped_ptr<base::DictionaryValue> prefs_; |
93 | 93 |
94 // Indicates that the extensions provided by this provider are loaded | 94 // Indicates that the extensions provided by this provider are loaded |
95 // entirely. | 95 // entirely. |
(...skipping 10 matching lines...) Expand all Loading... | |
106 // Whether loaded extensions should be automatically acknowledged, so that | 106 // Whether loaded extensions should be automatically acknowledged, so that |
107 // the user doesn't see an alert about them. | 107 // the user doesn't see an alert about them. |
108 bool auto_acknowledge_; | 108 bool auto_acknowledge_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl); | 110 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl); |
111 }; | 111 }; |
112 | 112 |
113 } // namespace extensions | 113 } // namespace extensions |
114 | 114 |
115 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_ | 115 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_ |
OLD | NEW |