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_EXTENSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/prefs/pref_change_registrar.h" | |
19 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
20 #include "chrome/browser/extensions/blacklist.h" | 19 #include "chrome/browser/extensions/blacklist.h" |
| 20 #include "chrome/browser/extensions/extension_management.h" |
21 #include "chrome/browser/extensions/pending_extension_manager.h" | 21 #include "chrome/browser/extensions/pending_extension_manager.h" |
22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 #include "extensions/browser/external_provider_interface.h" | 24 #include "extensions/browser/external_provider_interface.h" |
25 #include "extensions/browser/install_flag.h" | 25 #include "extensions/browser/install_flag.h" |
26 #include "extensions/browser/management_policy.h" | 26 #include "extensions/browser/management_policy.h" |
27 #include "extensions/browser/process_manager.h" | 27 #include "extensions/browser/process_manager.h" |
28 #include "extensions/browser/uninstall_reason.h" | 28 #include "extensions/browser/uninstall_reason.h" |
29 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
30 #include "extensions/common/extension_set.h" | 30 #include "extensions/common/extension_set.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Returns task runner for crx installation file I/O operations. | 168 // Returns task runner for crx installation file I/O operations. |
169 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; | 169 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
170 }; | 170 }; |
171 | 171 |
172 // Manages installed and running Chromium extensions. An instance is shared | 172 // Manages installed and running Chromium extensions. An instance is shared |
173 // between normal and incognito profiles. | 173 // between normal and incognito profiles. |
174 class ExtensionService | 174 class ExtensionService |
175 : public ExtensionServiceInterface, | 175 : public ExtensionServiceInterface, |
176 public extensions::ExternalProviderInterface::VisitorInterface, | 176 public extensions::ExternalProviderInterface::VisitorInterface, |
177 public content::NotificationObserver, | 177 public content::NotificationObserver, |
178 public extensions::Blacklist::Observer { | 178 public extensions::Blacklist::Observer, |
| 179 public extensions::ExtensionManagement::Observer { |
179 public: | 180 public: |
180 // Attempts to uninstall an extension from a given ExtensionService. Returns | 181 // Attempts to uninstall an extension from a given ExtensionService. Returns |
181 // true iff the target extension exists. | 182 // true iff the target extension exists. |
182 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 183 static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
183 const std::string& extension_id, | 184 const std::string& extension_id, |
184 extensions::UninstallReason reason); | 185 extensions::UninstallReason reason); |
185 | 186 |
186 // Constructor stores pointers to |profile| and |extension_prefs| but | 187 // Constructor stores pointers to |profile| and |extension_prefs| but |
187 // ownership remains at caller. | 188 // ownership remains at caller. |
188 ExtensionService(Profile* profile, | 189 ExtensionService(Profile* profile, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 virtual bool OnExternalExtensionUpdateUrlFound( | 243 virtual bool OnExternalExtensionUpdateUrlFound( |
243 const std::string& id, | 244 const std::string& id, |
244 const std::string& install_parameter, | 245 const std::string& install_parameter, |
245 const GURL& update_url, | 246 const GURL& update_url, |
246 extensions::Manifest::Location location, | 247 extensions::Manifest::Location location, |
247 int creation_flags, | 248 int creation_flags, |
248 bool mark_acknowledged) OVERRIDE; | 249 bool mark_acknowledged) OVERRIDE; |
249 virtual void OnExternalProviderReady( | 250 virtual void OnExternalProviderReady( |
250 const extensions::ExternalProviderInterface* provider) OVERRIDE; | 251 const extensions::ExternalProviderInterface* provider) OVERRIDE; |
251 | 252 |
| 253 // ExtensionManagement::Observer implementation: |
| 254 virtual void OnExtensionManagementSettingsChanged() OVERRIDE; |
| 255 |
252 // Initialize and start all installed extensions. | 256 // Initialize and start all installed extensions. |
253 void Init(); | 257 void Init(); |
254 | 258 |
255 // Called when the associated Profile is going to be destroyed. | 259 // Called when the associated Profile is going to be destroyed. |
256 void Shutdown(); | 260 void Shutdown(); |
257 | 261 |
258 // Reloads the specified extension, sending the onLaunched() event to it if it | 262 // Reloads the specified extension, sending the onLaunched() event to it if it |
259 // currently has any window showing. | 263 // currently has any window showing. |
260 // Allows noisy failures. | 264 // Allows noisy failures. |
261 void ReloadExtension(const std::string& extension_id); | 265 void ReloadExtension(const std::string& extension_id); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // Signals *ready_ and sends a notification to the listeners. | 494 // Signals *ready_ and sends a notification to the listeners. |
491 void SetReadyAndNotifyListeners(); | 495 void SetReadyAndNotifyListeners(); |
492 | 496 |
493 // Returns true if all the external extension providers are ready. | 497 // Returns true if all the external extension providers are ready. |
494 bool AreAllExternalProvidersReady() const; | 498 bool AreAllExternalProvidersReady() const; |
495 | 499 |
496 // Called once all external providers are ready. Checks for unclaimed | 500 // Called once all external providers are ready. Checks for unclaimed |
497 // external extensions. | 501 // external extensions. |
498 void OnAllExternalProvidersReady(); | 502 void OnAllExternalProvidersReady(); |
499 | 503 |
500 // Return true if the sync type of |extension| matches |type|. | |
501 void OnExtensionInstallPrefChanged(); | |
502 | |
503 // Adds the given extension to the list of terminated extensions if | 504 // Adds the given extension to the list of terminated extensions if |
504 // it is not already there and unloads it. | 505 // it is not already there and unloads it. |
505 void TrackTerminatedExtension(const extensions::Extension* extension); | 506 void TrackTerminatedExtension(const extensions::Extension* extension); |
506 | 507 |
507 // Removes the extension with the given id from the list of | 508 // Removes the extension with the given id from the list of |
508 // terminated extensions if it is there. | 509 // terminated extensions if it is there. |
509 void UntrackTerminatedExtension(const std::string& id); | 510 void UntrackTerminatedExtension(const std::string& id); |
510 | 511 |
511 // Update preferences for a new or updated extension; notify observers that | 512 // Update preferences for a new or updated extension; notify observers that |
512 // the extension is installed, e.g., to update event handlers on background | 513 // the extension is installed, e.g., to update event handlers on background |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; | 639 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; |
639 UnloadedExtensionPathMap unloaded_extension_paths_; | 640 UnloadedExtensionPathMap unloaded_extension_paths_; |
640 | 641 |
641 // Map of DevToolsAgentHost instances that are detached, | 642 // Map of DevToolsAgentHost instances that are detached, |
642 // waiting for an extension to be reloaded. | 643 // waiting for an extension to be reloaded. |
643 typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> > | 644 typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> > |
644 OrphanedDevTools; | 645 OrphanedDevTools; |
645 OrphanedDevTools orphaned_dev_tools_; | 646 OrphanedDevTools orphaned_dev_tools_; |
646 | 647 |
647 content::NotificationRegistrar registrar_; | 648 content::NotificationRegistrar registrar_; |
648 PrefChangeRegistrar pref_change_registrar_; | |
649 | 649 |
650 // Keeps track of loading and unloading component extensions. | 650 // Keeps track of loading and unloading component extensions. |
651 scoped_ptr<extensions::ComponentLoader> component_loader_; | 651 scoped_ptr<extensions::ComponentLoader> component_loader_; |
652 | 652 |
653 // A collection of external extension providers. Each provider reads | 653 // A collection of external extension providers. Each provider reads |
654 // a source of external extension information. Examples include the | 654 // a source of external extension information. Examples include the |
655 // windows registry and external_extensions.json. | 655 // windows registry and external_extensions.json. |
656 extensions::ProviderCollection external_extension_providers_; | 656 extensions::ProviderCollection external_extension_providers_; |
657 | 657 |
658 // Set to true by OnExternalExtensionUpdateUrlFound() when an external | 658 // Set to true by OnExternalExtensionUpdateUrlFound() when an external |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 GreylistedExtensionDisabled); | 727 GreylistedExtensionDisabled); |
728 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 728 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
729 GreylistDontEnableManuallyDisabled); | 729 GreylistDontEnableManuallyDisabled); |
730 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 730 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
731 GreylistUnknownDontChange); | 731 GreylistUnknownDontChange); |
732 | 732 |
733 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 733 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
734 }; | 734 }; |
735 | 735 |
736 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 736 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |