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_COMPONENT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/prefs/pref_change_registrar.h" | |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 | 14 |
16 class ExtensionServiceInterface; | 15 class ExtensionServiceInterface; |
17 class PrefService; | 16 class PrefService; |
18 | 17 |
19 namespace user_prefs { | |
20 class PrefRegistrySyncable; | |
21 } | |
22 | |
23 namespace extensions { | 18 namespace extensions { |
24 | 19 |
25 class Extension; | 20 class Extension; |
26 | 21 |
27 // For registering, loading, and unloading component extensions. | 22 // For registering, loading, and unloading component extensions. |
28 class ComponentLoader { | 23 class ComponentLoader { |
29 public: | 24 public: |
30 ComponentLoader(ExtensionServiceInterface* extension_service, | 25 ComponentLoader(ExtensionServiceInterface* extension_service, |
31 PrefService* prefs, | 26 PrefService* prefs, |
32 PrefService* local_state); | 27 PrefService* local_state); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Call this during test setup to load component extensions that have | 71 // Call this during test setup to load component extensions that have |
77 // background pages for testing, which could otherwise interfere with tests. | 72 // background pages for testing, which could otherwise interfere with tests. |
78 static void EnableBackgroundExtensionsForTesting(); | 73 static void EnableBackgroundExtensionsForTesting(); |
79 | 74 |
80 // Adds the default component extensions. If |skip_session_components| | 75 // Adds the default component extensions. If |skip_session_components| |
81 // the loader will skip loading component extensions that weren't supposed to | 76 // the loader will skip loading component extensions that weren't supposed to |
82 // be loaded unless we are in signed user session (ChromeOS). For all other | 77 // be loaded unless we are in signed user session (ChromeOS). For all other |
83 // platforms this |skip_session_components| is expected to be unset. | 78 // platforms this |skip_session_components| is expected to be unset. |
84 void AddDefaultComponentExtensions(bool skip_session_components); | 79 void AddDefaultComponentExtensions(bool skip_session_components); |
85 | 80 |
86 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | |
87 | |
88 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if | 81 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if |
89 // if the result is not a DictionaryValue. | 82 // if the result is not a DictionaryValue. |
90 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; | 83 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; |
91 | 84 |
92 // Clear the list of registered extensions. | 85 // Clear the list of registered extensions. |
93 void ClearAllRegistered(); | 86 void ClearAllRegistered(); |
94 | 87 |
95 // Reloads a registered component extension. | 88 // Reloads a registered component extension. |
96 void Reload(const std::string& extension_id); | 89 void Reload(const std::string& extension_id); |
97 | 90 |
(...skipping 17 matching lines...) Expand all Loading... |
115 const base::FilePath& root_directory); | 108 const base::FilePath& root_directory); |
116 | 109 |
117 // Loads a registered component extension. | 110 // Loads a registered component extension. |
118 void Load(const ComponentExtensionInfo& info); | 111 void Load(const ComponentExtensionInfo& info); |
119 | 112 |
120 void AddDefaultComponentExtensionsWithBackgroundPages( | 113 void AddDefaultComponentExtensionsWithBackgroundPages( |
121 bool skip_session_components); | 114 bool skip_session_components); |
122 void AddFileManagerExtension(); | 115 void AddFileManagerExtension(); |
123 void AddImageLoaderExtension(); | 116 void AddImageLoaderExtension(); |
124 | 117 |
125 // Add the enterprise webstore extension, or reload it if already loaded. | |
126 void AddOrReloadEnterpriseWebStore(); | |
127 | |
128 void AddChromeApp(); | 118 void AddChromeApp(); |
129 void AddKeyboardApp(); | 119 void AddKeyboardApp(); |
130 | 120 |
131 // Unloads |component| from the memory. | 121 // Unloads |component| from the memory. |
132 void UnloadComponent(ComponentExtensionInfo* component); | 122 void UnloadComponent(ComponentExtensionInfo* component); |
133 | 123 |
134 PrefService* profile_prefs_; | 124 PrefService* profile_prefs_; |
135 PrefService* local_state_; | 125 PrefService* local_state_; |
136 | 126 |
137 ExtensionServiceInterface* extension_service_; | 127 ExtensionServiceInterface* extension_service_; |
138 | 128 |
139 // List of registered component extensions (see Manifest::Location). | 129 // List of registered component extensions (see Manifest::Location). |
140 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; | 130 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
141 RegisteredComponentExtensions component_extensions_; | 131 RegisteredComponentExtensions component_extensions_; |
142 | 132 |
143 PrefChangeRegistrar pref_change_registrar_; | |
144 | |
145 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); | 133 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); |
146 }; | 134 }; |
147 | 135 |
148 } // namespace extensions | 136 } // namespace extensions |
149 | 137 |
150 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 138 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
OLD | NEW |