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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/prefs/pref_change_registrar.h" | 19 #include "base/prefs/pref_change_registrar.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "chrome/browser/extensions/blacklist.h" | 21 #include "chrome/browser/extensions/blacklist.h" |
22 #include "chrome/browser/extensions/extension_sync_service.h" | 22 #include "chrome/browser/extensions/extension_sync_service.h" |
23 #include "chrome/browser/extensions/pending_extension_manager.h" | 23 #include "chrome/browser/extensions/pending_extension_manager.h" |
24 #include "content/public/browser/devtools_agent_host.h" | 24 #include "content/public/browser/devtools_agent_host.h" |
25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "extensions/browser/content_verifier.h" |
27 #include "extensions/browser/extension_function_histogram_value.h" | 28 #include "extensions/browser/extension_function_histogram_value.h" |
28 #include "extensions/browser/extension_prefs.h" | 29 #include "extensions/browser/extension_prefs.h" |
29 #include "extensions/browser/external_provider_interface.h" | 30 #include "extensions/browser/external_provider_interface.h" |
30 #include "extensions/browser/management_policy.h" | 31 #include "extensions/browser/management_policy.h" |
31 #include "extensions/browser/process_manager.h" | 32 #include "extensions/browser/process_manager.h" |
32 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
33 #include "extensions/common/extension_set.h" | 34 #include "extensions/common/extension_set.h" |
34 #include "extensions/common/manifest.h" | 35 #include "extensions/common/manifest.h" |
35 #include "extensions/common/one_shot_event.h" | 36 #include "extensions/common/one_shot_event.h" |
36 | 37 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Returns task runner for crx installation file I/O operations. | 120 // Returns task runner for crx installation file I/O operations. |
120 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; | 121 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
121 }; | 122 }; |
122 | 123 |
123 // Manages installed and running Chromium extensions. An instance is shared | 124 // Manages installed and running Chromium extensions. An instance is shared |
124 // between normal and incognito profiles. | 125 // between normal and incognito profiles. |
125 class ExtensionService | 126 class ExtensionService |
126 : public ExtensionServiceInterface, | 127 : public ExtensionServiceInterface, |
127 public extensions::ExternalProviderInterface::VisitorInterface, | 128 public extensions::ExternalProviderInterface::VisitorInterface, |
128 public content::NotificationObserver, | 129 public content::NotificationObserver, |
129 public extensions::Blacklist::Observer { | 130 public extensions::Blacklist::Observer, |
| 131 public extensions::ContentVerifierObserver { |
130 public: | 132 public: |
131 // Attempts to uninstall an extension from a given ExtensionService. Returns | 133 // Attempts to uninstall an extension from a given ExtensionService. Returns |
132 // true iff the target extension exists. | 134 // true iff the target extension exists. |
133 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 135 static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
134 const std::string& extension_id); | 136 const std::string& extension_id); |
135 | 137 |
136 // Constructor stores pointers to |profile| and |extension_prefs| but | 138 // Constructor stores pointers to |profile| and |extension_prefs| but |
137 // ownership remains at caller. | 139 // ownership remains at caller. |
138 ExtensionService(Profile* profile, | 140 ExtensionService(Profile* profile, |
139 const base::CommandLine* command_line, | 141 const base::CommandLine* command_line, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 install_updates_when_idle_ = value; | 466 install_updates_when_idle_ = value; |
465 } | 467 } |
466 | 468 |
467 // Set a callback to be called when all external providers are ready and their | 469 // Set a callback to be called when all external providers are ready and their |
468 // extensions have been installed. | 470 // extensions have been installed. |
469 void set_external_updates_finished_callback_for_test( | 471 void set_external_updates_finished_callback_for_test( |
470 const base::Closure& callback) { | 472 const base::Closure& callback) { |
471 external_updates_finished_callback_ = callback; | 473 external_updates_finished_callback_ = callback; |
472 } | 474 } |
473 | 475 |
| 476 // ContentVerifierObserver implementation. |
| 477 virtual void ContentVerifyFailed(const std::string& extension_id) OVERRIDE; |
| 478 |
474 // Adds/Removes update observers. | 479 // Adds/Removes update observers. |
475 void AddUpdateObserver(extensions::UpdateObserver* observer); | 480 void AddUpdateObserver(extensions::UpdateObserver* observer); |
476 void RemoveUpdateObserver(extensions::UpdateObserver* observer); | 481 void RemoveUpdateObserver(extensions::UpdateObserver* observer); |
477 | 482 |
478 private: | 483 private: |
479 // Populates greylist_. | 484 // Populates greylist_. |
480 void LoadGreylistFromPrefs(); | 485 void LoadGreylistFromPrefs(); |
481 | 486 |
482 // Signals *ready_ and sends a notification to the listeners. | 487 // Signals *ready_ and sends a notification to the listeners. |
483 void SetReadyAndNotifyListeners(); | 488 void SetReadyAndNotifyListeners(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 712 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
708 GreylistedExtensionDisabled); | 713 GreylistedExtensionDisabled); |
709 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 714 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
710 GreylistDontEnableManuallyDisabled); | 715 GreylistDontEnableManuallyDisabled); |
711 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 716 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
712 GreylistUnknownDontChange); | 717 GreylistUnknownDontChange); |
713 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 718 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
714 }; | 719 }; |
715 | 720 |
716 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 721 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |