| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 virtual void SyncExtensionChangeIfNeeded( | 132 virtual void SyncExtensionChangeIfNeeded( |
| 134 const extensions::Extension& extension) = 0; | 133 const extensions::Extension& extension) = 0; |
| 135 | 134 |
| 136 virtual bool is_ready() = 0; | 135 virtual bool is_ready() = 0; |
| 137 }; | 136 }; |
| 138 | 137 |
| 139 // Manages installed and running Chromium extensions. | 138 // Manages installed and running Chromium extensions. |
| 140 class ExtensionService | 139 class ExtensionService |
| 141 : public ExtensionServiceInterface, | 140 : public ExtensionServiceInterface, |
| 142 public extensions::ExternalProviderInterface::VisitorInterface, | 141 public extensions::ExternalProviderInterface::VisitorInterface, |
| 143 public content::NotificationObserver, | 142 public content::NotificationObserver { |
| 144 public PrefObserver { | |
| 145 public: | 143 public: |
| 146 // The name of the directory inside the profile where extensions are | 144 // The name of the directory inside the profile where extensions are |
| 147 // installed to. | 145 // installed to. |
| 148 static const char kInstallDirectoryName[]; | 146 static const char kInstallDirectoryName[]; |
| 149 | 147 |
| 150 // If auto-updates are turned on, default to running every 5 hours. | 148 // If auto-updates are turned on, default to running every 5 hours. |
| 151 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 149 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
| 152 | 150 |
| 153 // The name of the directory inside the profile where per-app local settings | 151 // The name of the directory inside the profile where per-app local settings |
| 154 // are stored. | 152 // are stored. |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 624 |
| 627 // Marks alertable extensions as acknowledged, after the user presses the | 625 // Marks alertable extensions as acknowledged, after the user presses the |
| 628 // accept button. | 626 // accept button. |
| 629 void HandleExtensionAlertAccept(); | 627 void HandleExtensionAlertAccept(); |
| 630 | 628 |
| 631 // content::NotificationObserver | 629 // content::NotificationObserver |
| 632 virtual void Observe(int type, | 630 virtual void Observe(int type, |
| 633 const content::NotificationSource& source, | 631 const content::NotificationSource& source, |
| 634 const content::NotificationDetails& details) OVERRIDE; | 632 const content::NotificationDetails& details) OVERRIDE; |
| 635 | 633 |
| 636 // PrefObserver | |
| 637 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
| 638 const std::string& pref_name) OVERRIDE; | |
| 639 | |
| 640 // Whether there are any apps installed. Component apps are not included. | 634 // Whether there are any apps installed. Component apps are not included. |
| 641 bool HasApps() const; | 635 bool HasApps() const; |
| 642 | 636 |
| 643 // Gets the set of loaded app ids. Component apps are not included. | 637 // Gets the set of loaded app ids. Component apps are not included. |
| 644 extensions::ExtensionIdSet GetAppIds() const; | 638 extensions::ExtensionIdSet GetAppIds() const; |
| 645 | 639 |
| 646 // Record a histogram using the PermissionMessage enum values for each | 640 // Record a histogram using the PermissionMessage enum values for each |
| 647 // permission in |e|. | 641 // permission in |e|. |
| 648 // NOTE: If this is ever called with high frequency, the implementation may | 642 // NOTE: If this is ever called with high frequency, the implementation may |
| 649 // need to be made more efficient. | 643 // need to be made more efficient. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 GURL url; | 697 GURL url; |
| 704 std::string mime_type; | 698 std::string mime_type; |
| 705 }; | 699 }; |
| 706 typedef std::list<NaClModuleInfo> NaClModuleInfoList; | 700 typedef std::list<NaClModuleInfo> NaClModuleInfoList; |
| 707 | 701 |
| 708 // Return true if the sync type of |extension| matches |type|. | 702 // Return true if the sync type of |extension| matches |type|. |
| 709 bool IsCorrectSyncType(const extensions::Extension& extension, | 703 bool IsCorrectSyncType(const extensions::Extension& extension, |
| 710 syncer::ModelType type) | 704 syncer::ModelType type) |
| 711 const; | 705 const; |
| 712 | 706 |
| 707 void OnExtensionInstallPrefChanged(); |
| 708 |
| 713 // Handles setting the extension specific values in |extension_sync_data| to | 709 // Handles setting the extension specific values in |extension_sync_data| to |
| 714 // the current system. | 710 // the current system. |
| 715 // Returns false if the changes were not completely applied and need to be | 711 // Returns false if the changes were not completely applied and need to be |
| 716 // tried again later. | 712 // tried again later. |
| 717 bool ProcessExtensionSyncDataHelper( | 713 bool ProcessExtensionSyncDataHelper( |
| 718 const extensions::ExtensionSyncData& extension_sync_data, | 714 const extensions::ExtensionSyncData& extension_sync_data, |
| 719 syncer::ModelType type); | 715 syncer::ModelType type); |
| 720 | 716 |
| 721 enum IncludeFlag { | 717 enum IncludeFlag { |
| 722 INCLUDE_NONE = 0, | 718 INCLUDE_NONE = 0, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 #endif | 959 #endif |
| 964 | 960 |
| 965 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 961 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 966 InstallAppsWithUnlimtedStorage); | 962 InstallAppsWithUnlimtedStorage); |
| 967 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 963 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 968 InstallAppsAndCheckStorageProtection); | 964 InstallAppsAndCheckStorageProtection); |
| 969 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 965 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 970 }; | 966 }; |
| 971 | 967 |
| 972 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 968 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |