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> |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // cannot be disabled, does nothing. | 282 // cannot be disabled, does nothing. |
283 virtual void DisableExtension( | 283 virtual void DisableExtension( |
284 const std::string& extension_id, | 284 const std::string& extension_id, |
285 extensions::Extension::DisableReason disable_reason); | 285 extensions::Extension::DisableReason disable_reason); |
286 | 286 |
287 // Disable non-default and non-managed extensions with ids not in | 287 // Disable non-default and non-managed extensions with ids not in |
288 // |except_ids|. Default extensions are those from the Web Store with | 288 // |except_ids|. Default extensions are those from the Web Store with |
289 // |was_installed_by_default| flag. | 289 // |was_installed_by_default| flag. |
290 void DisableUserExtensions(const std::vector<std::string>& except_ids); | 290 void DisableUserExtensions(const std::vector<std::string>& except_ids); |
291 | 291 |
| 292 // Puts all extensions in a blocked state: Unloading every extension, and |
| 293 // preventing them from ever loading until UnblockAllExtensions is called. |
| 294 // This state is stored in preferences, so persists until Chrome restarts. |
| 295 // |
| 296 // Component, external component and whitelisted policy installed extensions |
| 297 // are exempt from being Blocked (see CanBlockExtension). |
| 298 void BlockAllExtensions(); |
| 299 |
| 300 // All blocked extensions are reverted to their previous state, and are |
| 301 // reloaded. Newly added extensions are no longer automatically blocked. |
| 302 void UnblockAllExtensions(); |
| 303 |
292 // Updates the |extension|'s granted permissions lists to include all | 304 // Updates the |extension|'s granted permissions lists to include all |
293 // permissions in the |extension|'s manifest and re-enables the | 305 // permissions in the |extension|'s manifest and re-enables the |
294 // extension. | 306 // extension. |
295 void GrantPermissionsAndEnableExtension( | 307 void GrantPermissionsAndEnableExtension( |
296 const extensions::Extension* extension); | 308 const extensions::Extension* extension); |
297 | 309 |
298 // Updates the |extension|'s granted permissions lists to include all | 310 // Updates the |extension|'s granted permissions lists to include all |
299 // permissions in the |extensions|'s manifest. | 311 // permissions in the |extensions|'s manifest. |
300 void GrantPermissions(const extensions::Extension* extension); | 312 void GrantPermissions(const extensions::Extension* extension); |
301 | 313 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 bool is_extension_installed); | 551 bool is_extension_installed); |
540 | 552 |
541 // Helper that updates the active extension list used for crash reporting. | 553 // Helper that updates the active extension list used for crash reporting. |
542 void UpdateActiveExtensionsInCrashReporter(); | 554 void UpdateActiveExtensionsInCrashReporter(); |
543 | 555 |
544 // Helper to get the disable reasons for an installed (or upgraded) extension. | 556 // Helper to get the disable reasons for an installed (or upgraded) extension. |
545 // A return value of Extension::DISABLE_NONE indicates that we should enable | 557 // A return value of Extension::DISABLE_NONE indicates that we should enable |
546 // this extension initially. | 558 // this extension initially. |
547 int GetDisableReasonsOnInstalled(const extensions::Extension* extension); | 559 int GetDisableReasonsOnInstalled(const extensions::Extension* extension); |
548 | 560 |
| 561 // Helper method to determine if an extension can be blocked. |
| 562 bool CanBlockExtension(const extensions::Extension* extension) const; |
| 563 |
549 // Helper to determine if updating an extensions should proceed immediately, | 564 // Helper to determine if updating an extensions should proceed immediately, |
550 // or if we should delay the update until further notice. | 565 // or if we should delay the update until further notice. |
551 bool ShouldDelayExtensionUpdate(const std::string& extension_id, | 566 bool ShouldDelayExtensionUpdate(const std::string& extension_id, |
552 bool install_immediately) const; | 567 bool install_immediately) const; |
553 | 568 |
554 // Manages the blacklisted extensions, intended as callback from | 569 // Manages the blacklisted extensions, intended as callback from |
555 // Blacklist::GetBlacklistedIDs. | 570 // Blacklist::GetBlacklistedIDs. |
556 void ManageBlacklist( | 571 void ManageBlacklist( |
557 const extensions::Blacklist::BlacklistStateMap& blacklisted_ids); | 572 const extensions::Blacklist::BlacklistStateMap& blacklisted_ids); |
558 | 573 |
559 // Add extensions in |blocked| to blacklisted_extensions, remove extensions | 574 // Add extensions in |blacklisted| to blacklisted_extensions, remove |
560 // that are neither in |blocked|, nor in |unchanged|. | 575 // extensions that are neither in |blacklisted|, nor in |unchanged|. |
561 void UpdateBlockedExtensions(const extensions::ExtensionIdSet& blocked, | 576 void UpdateBlacklistedExtensions( |
562 const extensions::ExtensionIdSet& unchanged); | 577 const extensions::ExtensionIdSet& to_blacklist, |
| 578 const extensions::ExtensionIdSet& unchanged); |
563 | 579 |
564 void UpdateGreylistedExtensions( | 580 void UpdateGreylistedExtensions( |
565 const extensions::ExtensionIdSet& greylist, | 581 const extensions::ExtensionIdSet& greylist, |
566 const extensions::ExtensionIdSet& unchanged, | 582 const extensions::ExtensionIdSet& unchanged, |
567 const extensions::Blacklist::BlacklistStateMap& state_map); | 583 const extensions::Blacklist::BlacklistStateMap& state_map); |
568 | 584 |
569 // Used only by test code. | 585 // Used only by test code. |
570 void UnloadAllExtensionsInternal(); | 586 void UnloadAllExtensionsInternal(); |
571 | 587 |
572 // Disable apps & extensions now to stop them from running after a profile | 588 // Disable apps & extensions now to stop them from running after a profile |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 // allow background processing of garbage collection of on-disk state without | 693 // allow background processing of garbage collection of on-disk state without |
678 // needing to worry about race conditions caused by extension installation and | 694 // needing to worry about race conditions caused by extension installation and |
679 // reinstallation. | 695 // reinstallation. |
680 bool installs_delayed_for_gc_; | 696 bool installs_delayed_for_gc_; |
681 | 697 |
682 // Set to true if this is the first time this ExtensionService has run. | 698 // Set to true if this is the first time this ExtensionService has run. |
683 // Used for specially handling external extensions that are installed the | 699 // Used for specially handling external extensions that are installed the |
684 // first time. | 700 // first time. |
685 bool is_first_run_; | 701 bool is_first_run_; |
686 | 702 |
| 703 // Set to true if extensions are all to be blocked. |
| 704 bool block_extensions_; |
| 705 |
687 // Store the ids of reloading extensions. We use this to re-enable extensions | 706 // Store the ids of reloading extensions. We use this to re-enable extensions |
688 // which were disabled for a reload. | 707 // which were disabled for a reload. |
689 std::set<std::string> reloading_extensions_; | 708 std::set<std::string> reloading_extensions_; |
690 | 709 |
691 // A set of the extension ids currently being terminated. We use this to | 710 // A set of the extension ids currently being terminated. We use this to |
692 // avoid trying to unload the same extension twice. | 711 // avoid trying to unload the same extension twice. |
693 std::set<std::string> extensions_being_terminated_; | 712 std::set<std::string> extensions_being_terminated_; |
694 | 713 |
695 // The controller for the UI that alerts the user about any blacklisted | 714 // The controller for the UI that alerts the user about any blacklisted |
696 // extensions. | 715 // extensions. |
(...skipping 28 matching lines...) Expand all Loading... |
725 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ReloadBlacklistedExtension); | 744 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ReloadBlacklistedExtension); |
726 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, BlacklistedInPrefsFromStartup); | 745 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, BlacklistedInPrefsFromStartup); |
727 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 746 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
728 GreylistedExtensionDisabled); | 747 GreylistedExtensionDisabled); |
729 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 748 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
730 GreylistDontEnableManuallyDisabled); | 749 GreylistDontEnableManuallyDisabled); |
731 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 750 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
732 GreylistUnknownDontChange); | 751 GreylistUnknownDontChange); |
733 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 752 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
734 ManagementPolicyProhibitsEnableOnInstalled); | 753 ManagementPolicyProhibitsEnableOnInstalled); |
| 754 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 755 BlockAndUnblockBlacklistedExtension); |
735 | 756 |
736 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 757 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
737 }; | 758 }; |
738 | 759 |
739 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 760 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |