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> |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 extensions::ProcessMap* process_map() { return &process_map_; } | 182 extensions::ProcessMap* process_map() { return &process_map_; } |
183 | 183 |
184 // Updates the app launcher value for the moved extension so that it is now | 184 // Updates the app launcher value for the moved extension so that it is now |
185 // located after the given predecessor and before the successor. This will | 185 // located after the given predecessor and before the successor. This will |
186 // trigger a sync if needed. Empty strings are used to indicate no successor | 186 // trigger a sync if needed. Empty strings are used to indicate no successor |
187 // or predecessor. | 187 // or predecessor. |
188 void OnExtensionMoved(const std::string& moved_extension_id, | 188 void OnExtensionMoved(const std::string& moved_extension_id, |
189 const std::string& predecessor_extension_id, | 189 const std::string& predecessor_extension_id, |
190 const std::string& successor_extension_id); | 190 const std::string& successor_extension_id); |
191 | 191 |
192 // Whether the persistent background page, if any, is ready. We don't load | |
193 // other components until then. If there is no background page, or if it is | |
194 // non-persistent (lazy), we consider it to be ready. | |
195 bool IsBackgroundPageReady(const extensions::Extension* extension) const; | |
196 void SetBackgroundPageReady(const extensions::Extension* extension); | |
197 | |
198 // Getter and setter for the flag that specifies whether the extension is | |
199 // being upgraded. | |
200 bool IsBeingUpgraded(const extensions::Extension* extension) const; | |
201 void SetBeingUpgraded(const extensions::Extension* extension, bool value); | |
202 | |
203 // Getter and setter for the flag that specifies whether the extension is | 192 // Getter and setter for the flag that specifies whether the extension is |
204 // being reloaded. | 193 // being reloaded. |
205 bool IsBeingReloaded(const std::string& extension_id) const; | 194 bool IsBeingReloaded(const std::string& extension_id) const; |
206 void SetBeingReloaded(const std::string& extension_id, bool value); | 195 void SetBeingReloaded(const std::string& extension_id, bool value); |
207 | 196 |
208 // Getter and setter for the flag that specifies if the extension has used | |
209 // the webrequest API. | |
210 // TODO(mpcomplete): remove. http://crbug.com/100411 | |
211 bool HasUsedWebRequest(const extensions::Extension* extension) const; | |
212 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value); | |
213 | |
214 // Initialize and start all installed extensions. | 197 // Initialize and start all installed extensions. |
215 void Init(); | 198 void Init(); |
216 | 199 |
217 // Attempts to verify all extensions using the InstallVerifier. | 200 // Attempts to verify all extensions using the InstallVerifier. |
218 void VerifyAllExtensions(); | 201 void VerifyAllExtensions(); |
219 | 202 |
220 // Once the verifier work is finished, we may want to re-check management | 203 // Once the verifier work is finished, we may want to re-check management |
221 // policy if |success| indicates the verifier got a new signature back. | 204 // policy if |success| indicates the verifier got a new signature back. |
222 void FinishVerifyAllExtensions(bool success); | 205 void FinishVerifyAllExtensions(bool success); |
223 | 206 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 #if defined(OS_CHROMEOS) | 594 #if defined(OS_CHROMEOS) |
612 void disable_garbage_collection() { | 595 void disable_garbage_collection() { |
613 disable_garbage_collection_ = true; | 596 disable_garbage_collection_ = true; |
614 } | 597 } |
615 void enable_garbage_collection() { | 598 void enable_garbage_collection() { |
616 disable_garbage_collection_ = false; | 599 disable_garbage_collection_ = false; |
617 } | 600 } |
618 #endif | 601 #endif |
619 | 602 |
620 private: | 603 private: |
621 // Contains Extension data that can change during the life of the process, | |
622 // but does not persist across restarts. | |
623 struct ExtensionRuntimeData { | |
624 // True if the background page is ready. | |
625 bool background_page_ready; | |
626 | |
627 // True while the extension is being upgraded. | |
628 bool being_upgraded; | |
629 | |
630 // True if the extension has used the webRequest API. | |
631 bool has_used_webrequest; | |
632 | |
633 ExtensionRuntimeData(); | |
634 ~ExtensionRuntimeData(); | |
635 }; | |
636 typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap; | |
637 | |
638 // Signals *ready_ and sends a notification to the listeners. | 604 // Signals *ready_ and sends a notification to the listeners. |
639 void SetReadyAndNotifyListeners(); | 605 void SetReadyAndNotifyListeners(); |
640 | 606 |
641 // Return true if the sync type of |extension| matches |type|. | 607 // Return true if the sync type of |extension| matches |type|. |
642 void OnExtensionInstallPrefChanged(); | 608 void OnExtensionInstallPrefChanged(); |
643 | 609 |
644 // Adds the given extension to the list of terminated extensions if | 610 // Adds the given extension to the list of terminated extensions if |
645 // it is not already there and unloads it. | 611 // it is not already there and unloads it. |
646 void TrackTerminatedExtension(const extensions::Extension* extension); | 612 void TrackTerminatedExtension(const extensions::Extension* extension); |
647 | 613 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 extensions::ExtensionRegistry* registry_; | 702 extensions::ExtensionRegistry* registry_; |
737 | 703 |
738 // The list of extension installs delayed for various reasons. The reason | 704 // The list of extension installs delayed for various reasons. The reason |
739 // for delayed install is stored in ExtensionPrefs. These are not part of | 705 // for delayed install is stored in ExtensionPrefs. These are not part of |
740 // ExtensionRegistry because they are not yet installed. | 706 // ExtensionRegistry because they are not yet installed. |
741 extensions::ExtensionSet delayed_installs_; | 707 extensions::ExtensionSet delayed_installs_; |
742 | 708 |
743 // Hold the set of pending extensions. | 709 // Hold the set of pending extensions. |
744 extensions::PendingExtensionManager pending_extension_manager_; | 710 extensions::PendingExtensionManager pending_extension_manager_; |
745 | 711 |
746 // The map of extension IDs to their runtime data. | |
747 ExtensionRuntimeDataMap extension_runtime_data_; | |
748 | |
749 // The full path to the directory where extensions are installed. | 712 // The full path to the directory where extensions are installed. |
750 base::FilePath install_directory_; | 713 base::FilePath install_directory_; |
751 | 714 |
752 // Whether or not extensions are enabled. | 715 // Whether or not extensions are enabled. |
753 bool extensions_enabled_; | 716 bool extensions_enabled_; |
754 | 717 |
755 // Whether to notify users when they attempt to install an extension. | 718 // Whether to notify users when they attempt to install an extension. |
756 bool show_extensions_prompts_; | 719 bool show_extensions_prompts_; |
757 | 720 |
758 // Whether to delay installing of extension updates until the extension is | 721 // Whether to delay installing of extension updates until the extension is |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 822 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
860 UnloadBlacklistedExtensionPolicy); | 823 UnloadBlacklistedExtensionPolicy); |
861 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 824 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
862 WillNotLoadBlacklistedExtensionsFromDirectory); | 825 WillNotLoadBlacklistedExtensionsFromDirectory); |
863 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 826 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
864 BlacklistedInPrefsFromStartup); | 827 BlacklistedInPrefsFromStartup); |
865 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 828 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
866 }; | 829 }; |
867 | 830 |
868 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 831 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |