| 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/file_path.h" | 15 #include "base/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/public/pref_change_registrar.h" | 19 #include "base/prefs/public/pref_change_registrar.h" |
| 20 #include "base/prefs/public/pref_observer.h" | |
| 21 #include "base/string16.h" | 20 #include "base/string16.h" |
| 22 #include "chrome/browser/extensions/app_shortcut_manager.h" | 21 #include "chrome/browser/extensions/app_shortcut_manager.h" |
| 23 #include "chrome/browser/extensions/app_sync_bundle.h" | 22 #include "chrome/browser/extensions/app_sync_bundle.h" |
| 24 #include "chrome/browser/extensions/extension_icon_manager.h" | 23 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 25 #include "chrome/browser/extensions/extension_prefs.h" | 24 #include "chrome/browser/extensions/extension_prefs.h" |
| 26 #include "chrome/browser/extensions/extension_process_manager.h" | 25 #include "chrome/browser/extensions/extension_process_manager.h" |
| 27 #include "chrome/browser/extensions/extension_sync_bundle.h" | 26 #include "chrome/browser/extensions/extension_sync_bundle.h" |
| 28 #include "chrome/browser/extensions/extension_toolbar_model.h" | 27 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 29 #include "chrome/browser/extensions/extension_warning_set.h" | 28 #include "chrome/browser/extensions/extension_warning_set.h" |
| 30 #include "chrome/browser/extensions/extensions_quota_service.h" | 29 #include "chrome/browser/extensions/extensions_quota_service.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 virtual void SyncExtensionChangeIfNeeded( | 133 virtual void SyncExtensionChangeIfNeeded( |
| 135 const extensions::Extension& extension) = 0; | 134 const extensions::Extension& extension) = 0; |
| 136 | 135 |
| 137 virtual bool is_ready() = 0; | 136 virtual bool is_ready() = 0; |
| 138 }; | 137 }; |
| 139 | 138 |
| 140 // Manages installed and running Chromium extensions. | 139 // Manages installed and running Chromium extensions. |
| 141 class ExtensionService | 140 class ExtensionService |
| 142 : public ExtensionServiceInterface, | 141 : public ExtensionServiceInterface, |
| 143 public extensions::ExternalProviderInterface::VisitorInterface, | 142 public extensions::ExternalProviderInterface::VisitorInterface, |
| 144 public content::NotificationObserver, | 143 public content::NotificationObserver { |
| 145 public PrefObserver { | |
| 146 public: | 144 public: |
| 147 // The name of the directory inside the profile where extensions are | 145 // The name of the directory inside the profile where extensions are |
| 148 // installed to. | 146 // installed to. |
| 149 static const char kInstallDirectoryName[]; | 147 static const char kInstallDirectoryName[]; |
| 150 | 148 |
| 151 // 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. |
| 152 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 150 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
| 153 | 151 |
| 154 // 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 |
| 155 // are stored. | 153 // are stored. |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 629 |
| 632 // Marks alertable extensions as acknowledged, after the user presses the | 630 // Marks alertable extensions as acknowledged, after the user presses the |
| 633 // accept button. | 631 // accept button. |
| 634 void HandleExtensionAlertAccept(); | 632 void HandleExtensionAlertAccept(); |
| 635 | 633 |
| 636 // content::NotificationObserver | 634 // content::NotificationObserver |
| 637 virtual void Observe(int type, | 635 virtual void Observe(int type, |
| 638 const content::NotificationSource& source, | 636 const content::NotificationSource& source, |
| 639 const content::NotificationDetails& details) OVERRIDE; | 637 const content::NotificationDetails& details) OVERRIDE; |
| 640 | 638 |
| 641 // PrefObserver | |
| 642 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
| 643 const std::string& pref_name) OVERRIDE; | |
| 644 | |
| 645 // Whether there are any apps installed. Component apps are not included. | 639 // Whether there are any apps installed. Component apps are not included. |
| 646 bool HasApps() const; | 640 bool HasApps() const; |
| 647 | 641 |
| 648 // Gets the set of loaded app ids. Component apps are not included. | 642 // Gets the set of loaded app ids. Component apps are not included. |
| 649 extensions::ExtensionIdSet GetAppIds() const; | 643 extensions::ExtensionIdSet GetAppIds() const; |
| 650 | 644 |
| 651 // Record a histogram using the PermissionMessage enum values for each | 645 // Record a histogram using the PermissionMessage enum values for each |
| 652 // permission in |e|. | 646 // permission in |e|. |
| 653 // NOTE: If this is ever called with high frequency, the implementation may | 647 // NOTE: If this is ever called with high frequency, the implementation may |
| 654 // need to be made more efficient. | 648 // need to be made more efficient. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 GURL url; | 702 GURL url; |
| 709 std::string mime_type; | 703 std::string mime_type; |
| 710 }; | 704 }; |
| 711 typedef std::list<NaClModuleInfo> NaClModuleInfoList; | 705 typedef std::list<NaClModuleInfo> NaClModuleInfoList; |
| 712 | 706 |
| 713 // Return true if the sync type of |extension| matches |type|. | 707 // Return true if the sync type of |extension| matches |type|. |
| 714 bool IsCorrectSyncType(const extensions::Extension& extension, | 708 bool IsCorrectSyncType(const extensions::Extension& extension, |
| 715 syncer::ModelType type) | 709 syncer::ModelType type) |
| 716 const; | 710 const; |
| 717 | 711 |
| 712 void OnExtensionInstallPrefChanged(); |
| 713 |
| 718 // Handles setting the extension specific values in |extension_sync_data| to | 714 // Handles setting the extension specific values in |extension_sync_data| to |
| 719 // the current system. | 715 // the current system. |
| 720 // Returns false if the changes were not completely applied and need to be | 716 // Returns false if the changes were not completely applied and need to be |
| 721 // tried again later. | 717 // tried again later. |
| 722 bool ProcessExtensionSyncDataHelper( | 718 bool ProcessExtensionSyncDataHelper( |
| 723 const extensions::ExtensionSyncData& extension_sync_data, | 719 const extensions::ExtensionSyncData& extension_sync_data, |
| 724 syncer::ModelType type); | 720 syncer::ModelType type); |
| 725 | 721 |
| 726 enum IncludeFlag { | 722 enum IncludeFlag { |
| 727 INCLUDE_NONE = 0, | 723 INCLUDE_NONE = 0, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 #endif | 966 #endif |
| 971 | 967 |
| 972 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 968 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 973 InstallAppsWithUnlimtedStorage); | 969 InstallAppsWithUnlimtedStorage); |
| 974 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 970 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 975 InstallAppsAndCheckStorageProtection); | 971 InstallAppsAndCheckStorageProtection); |
| 976 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 972 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 977 }; | 973 }; |
| 978 | 974 |
| 979 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 975 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |