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/callback_forward.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.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" |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 689 } |
689 | 690 |
690 // Adds/Removes update observers. | 691 // Adds/Removes update observers. |
691 void AddUpdateObserver(extensions::UpdateObserver* observer); | 692 void AddUpdateObserver(extensions::UpdateObserver* observer); |
692 void RemoveUpdateObserver(extensions::UpdateObserver* observer); | 693 void RemoveUpdateObserver(extensions::UpdateObserver* observer); |
693 | 694 |
694 // |flare| provides a StartSyncFlare to the SyncableService. See | 695 // |flare| provides a StartSyncFlare to the SyncableService. See |
695 // sync_start_util for more. | 696 // sync_start_util for more. |
696 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare); | 697 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare); |
697 | 698 |
| 699 // Register and remove callbacks to be notified when an extension is removed. |
| 700 void RegisterExtensionRemovedCallback( |
| 701 const base::Callback<void(const extensions::Extension*)>& callback); |
| 702 void RemoveExtensionRemovedCallback( |
| 703 const base::Callback<void(const extensions::Extension*)>& callback); |
| 704 |
698 private: | 705 private: |
699 // Contains Extension data that can change during the life of the process, | 706 // Contains Extension data that can change during the life of the process, |
700 // but does not persist across restarts. | 707 // but does not persist across restarts. |
701 struct ExtensionRuntimeData { | 708 struct ExtensionRuntimeData { |
702 // True if the background page is ready. | 709 // True if the background page is ready. |
703 bool background_page_ready; | 710 bool background_page_ready; |
704 | 711 |
705 // True while the extension is being upgraded. | 712 // True while the extension is being upgraded. |
706 bool being_upgraded; | 713 bool being_upgraded; |
707 | 714 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 extensions::Blacklist::BlacklistState blacklist_state, | 756 extensions::Blacklist::BlacklistState blacklist_state, |
750 const syncer::StringOrdinal& page_ordinal); | 757 const syncer::StringOrdinal& page_ordinal); |
751 | 758 |
752 // Handles sending notification that |extension| was loaded. | 759 // Handles sending notification that |extension| was loaded. |
753 void NotifyExtensionLoaded(const extensions::Extension* extension); | 760 void NotifyExtensionLoaded(const extensions::Extension* extension); |
754 | 761 |
755 // Handles sending notification that |extension| was unloaded. | 762 // Handles sending notification that |extension| was unloaded. |
756 void NotifyExtensionUnloaded(const extensions::Extension* extension, | 763 void NotifyExtensionUnloaded(const extensions::Extension* extension, |
757 extension_misc::UnloadedExtensionReason reason); | 764 extension_misc::UnloadedExtensionReason reason); |
758 | 765 |
| 766 // Handles sending notification that |extension| was removed. |
| 767 void NotifyExtensionRemoved(const extensions::Extension* extension); |
| 768 |
759 // Common helper to finish installing the given extension. | 769 // Common helper to finish installing the given extension. |
760 void FinishInstallation(const extensions::Extension* extension); | 770 void FinishInstallation(const extensions::Extension* extension); |
761 | 771 |
762 // Updates the |extension|'s active permission set to include only permissions | 772 // Updates the |extension|'s active permission set to include only permissions |
763 // currently requested by the extension and all the permissions required by | 773 // currently requested by the extension and all the permissions required by |
764 // the extension. | 774 // the extension. |
765 void UpdateActivePermissions(const extensions::Extension* extension); | 775 void UpdateActivePermissions(const extensions::Extension* extension); |
766 | 776 |
767 // Disables the extension if the privilege level has increased | 777 // Disables the extension if the privilege level has increased |
768 // (e.g., due to an upgrade). | 778 // (e.g., due to an upgrade). |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 scoped_ptr<extensions::ManagementPolicy::Provider> | 963 scoped_ptr<extensions::ManagementPolicy::Provider> |
954 shared_module_policy_provider_; | 964 shared_module_policy_provider_; |
955 | 965 |
956 ObserverList<extensions::UpdateObserver, true> update_observers_; | 966 ObserverList<extensions::UpdateObserver, true> update_observers_; |
957 | 967 |
958 // Run()ning tells sync to try and start soon, because syncable changes | 968 // Run()ning tells sync to try and start soon, because syncable changes |
959 // have started happening. It will cause sync to call us back | 969 // have started happening. It will cause sync to call us back |
960 // asynchronously via MergeDataAndStartSyncing as soon as possible. | 970 // asynchronously via MergeDataAndStartSyncing as soon as possible. |
961 syncer::SyncableService::StartSyncFlare flare_; | 971 syncer::SyncableService::StartSyncFlare flare_; |
962 | 972 |
| 973 std::vector<base::Callback<void(const extensions::Extension*)> > |
| 974 extension_removed_callbacks_; |
| 975 |
963 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 976 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
964 InstallAppsWithUnlimtedStorage); | 977 InstallAppsWithUnlimtedStorage); |
965 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 978 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
966 InstallAppsAndCheckStorageProtection); | 979 InstallAppsAndCheckStorageProtection); |
967 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 980 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
968 }; | 981 }; |
969 | 982 |
970 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 983 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |