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/observer_list.h" | |
18 #include "base/prefs/pref_change_registrar.h" | 19 #include "base/prefs/pref_change_registrar.h" |
19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
20 #include "chrome/browser/extensions/app_sync_bundle.h" | 21 #include "chrome/browser/extensions/app_sync_bundle.h" |
21 #include "chrome/browser/extensions/blacklist.h" | 22 #include "chrome/browser/extensions/blacklist.h" |
22 #include "chrome/browser/extensions/extension_function_histogram_value.h" | 23 #include "chrome/browser/extensions/extension_function_histogram_value.h" |
23 #include "chrome/browser/extensions/extension_icon_manager.h" | 24 #include "chrome/browser/extensions/extension_icon_manager.h" |
24 #include "chrome/browser/extensions/extension_prefs.h" | 25 #include "chrome/browser/extensions/extension_prefs.h" |
25 #include "chrome/browser/extensions/extension_process_manager.h" | 26 #include "chrome/browser/extensions/extension_process_manager.h" |
26 #include "chrome/browser/extensions/extension_sync_bundle.h" | 27 #include "chrome/browser/extensions/extension_sync_bundle.h" |
27 #include "chrome/browser/extensions/extension_toolbar_model.h" | 28 #include "chrome/browser/extensions/extension_toolbar_model.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; | 129 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
129 }; | 130 }; |
130 | 131 |
131 // Manages installed and running Chromium extensions. | 132 // Manages installed and running Chromium extensions. |
132 class ExtensionService | 133 class ExtensionService |
133 : public ExtensionServiceInterface, | 134 : public ExtensionServiceInterface, |
134 public extensions::ExternalProviderInterface::VisitorInterface, | 135 public extensions::ExternalProviderInterface::VisitorInterface, |
135 public content::NotificationObserver, | 136 public content::NotificationObserver, |
136 public extensions::Blacklist::Observer { | 137 public extensions::Blacklist::Observer { |
137 public: | 138 public: |
139 class DisabledExtensionObserver { | |
140 public: | |
141 // Called when an extension is removed from the disabled extensions list. | |
142 // |was_enabled| is true if it was enabled, false if it was blacklisted | |
143 // or uninstalled. | |
144 virtual void OnDisabledExtensionRemoved( | |
Matt Perry
2013/08/01 00:37:33
This seems oddly specific. I think it should be sp
Yoyo Zhou
2013/08/01 00:46:40
To be clear, there are paths which result in an Ex
| |
145 const extensions::Extension* extension, | |
146 bool was_enabled) = 0; | |
147 }; | |
148 | |
138 // If auto-updates are turned on, default to running every 5 hours. | 149 // If auto-updates are turned on, default to running every 5 hours. |
139 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 150 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
140 | 151 |
141 // The name of the directory inside the profile where per-app local settings | 152 // The name of the directory inside the profile where per-app local settings |
142 // are stored. | 153 // are stored. |
143 static const char kLocalAppSettingsDirectoryName[]; | 154 static const char kLocalAppSettingsDirectoryName[]; |
144 | 155 |
145 // The name of the directory inside the profile where per-extension local | 156 // The name of the directory inside the profile where per-extension local |
146 // settings are stored. | 157 // settings are stored. |
147 static const char kLocalExtensionSettingsDirectoryName[]; | 158 static const char kLocalExtensionSettingsDirectoryName[]; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 browser_terminating_ = value; | 689 browser_terminating_ = value; |
679 } | 690 } |
680 | 691 |
681 // By default ExtensionService will wait with installing an updated extension | 692 // By default ExtensionService will wait with installing an updated extension |
682 // until the extension is idle. Tests might not like this behavior, so you can | 693 // until the extension is idle. Tests might not like this behavior, so you can |
683 // disable it with this method. | 694 // disable it with this method. |
684 void set_install_updates_when_idle_for_test(bool value) { | 695 void set_install_updates_when_idle_for_test(bool value) { |
685 install_updates_when_idle_ = value; | 696 install_updates_when_idle_ = value; |
686 } | 697 } |
687 | 698 |
699 // Adds/Removes disabled extension observers. | |
700 void AddDisabledExtensionObserver(DisabledExtensionObserver* observer); | |
701 void RemoveDisabledExtensionObserver(DisabledExtensionObserver* observer); | |
702 | |
688 // Adds/Removes update observers. | 703 // Adds/Removes update observers. |
689 void AddUpdateObserver(extensions::UpdateObserver* observer); | 704 void AddUpdateObserver(extensions::UpdateObserver* observer); |
690 void RemoveUpdateObserver(extensions::UpdateObserver* observer); | 705 void RemoveUpdateObserver(extensions::UpdateObserver* observer); |
691 | 706 |
692 // |flare| provides a StartSyncFlare to the SyncableService. See | 707 // |flare| provides a StartSyncFlare to the SyncableService. See |
693 // sync_start_util for more. | 708 // sync_start_util for more. |
694 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare); | 709 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare); |
695 | 710 |
696 private: | 711 private: |
697 // Contains Extension data that can change during the life of the process, | 712 // Contains Extension data that can change during the life of the process, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 | 957 |
943 scoped_ptr<ExtensionErrorUI> extension_error_ui_; | 958 scoped_ptr<ExtensionErrorUI> extension_error_ui_; |
944 // Sequenced task runner for extension related file operations. | 959 // Sequenced task runner for extension related file operations. |
945 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 960 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
946 | 961 |
947 #if defined(ENABLE_EXTENSIONS) | 962 #if defined(ENABLE_EXTENSIONS) |
948 scoped_ptr<extensions::ExtensionActionStorageManager> | 963 scoped_ptr<extensions::ExtensionActionStorageManager> |
949 extension_action_storage_manager_; | 964 extension_action_storage_manager_; |
950 #endif | 965 #endif |
951 | 966 |
967 ObserverList<DisabledExtensionObserver, true> disabled_extension_observers_; | |
952 ObserverList<extensions::UpdateObserver, true> update_observers_; | 968 ObserverList<extensions::UpdateObserver, true> update_observers_; |
953 | 969 |
954 // Run()ning tells sync to try and start soon, because syncable changes | 970 // Run()ning tells sync to try and start soon, because syncable changes |
955 // have started happening. It will cause sync to call us back | 971 // have started happening. It will cause sync to call us back |
956 // asynchronously via MergeDataAndStartSyncing as soon as possible. | 972 // asynchronously via MergeDataAndStartSyncing as soon as possible. |
957 syncer::SyncableService::StartSyncFlare flare_; | 973 syncer::SyncableService::StartSyncFlare flare_; |
958 | 974 |
959 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 975 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
960 InstallAppsWithUnlimtedStorage); | 976 InstallAppsWithUnlimtedStorage); |
961 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 977 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
962 InstallAppsAndCheckStorageProtection); | 978 InstallAppsAndCheckStorageProtection); |
963 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 979 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
964 }; | 980 }; |
965 | 981 |
966 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 982 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |