| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_EXTENSIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/prefs/pref_change_registrar.h" | 32 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 33 #include "chrome/common/notification_observer.h" | 33 #include "chrome/common/notification_observer.h" |
| 34 #include "chrome/common/notification_registrar.h" | 34 #include "chrome/common/notification_registrar.h" |
| 35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 36 #include "chrome/common/property_bag.h" | 36 #include "chrome/common/property_bag.h" |
| 37 | 37 |
| 38 class ExtensionsServiceBackend; | 38 class ExtensionsServiceBackend; |
| 39 class ExtensionToolbarModel; | 39 class ExtensionToolbarModel; |
| 40 class ExtensionUpdater; | 40 class ExtensionUpdater; |
| 41 class GURL; | 41 class GURL; |
| 42 class PrefService; | |
| 43 class Profile; | 42 class Profile; |
| 44 class Version; | 43 class Version; |
| 45 | 44 |
| 46 // A pending extension is an extension that hasn't been installed yet | 45 // A pending extension is an extension that hasn't been installed yet |
| 47 // and is intended to be installed in the next auto-update cycle. The | 46 // and is intended to be installed in the next auto-update cycle. The |
| 48 // update URL of a pending extension may be blank, in which case a | 47 // update URL of a pending extension may be blank, in which case a |
| 49 // default one is assumed. | 48 // default one is assumed. |
| 50 struct PendingExtensionInfo { | 49 struct PendingExtensionInfo { |
| 51 // TODO(skerner): Consider merging ExpectedCrxType with | 50 // TODO(skerner): Consider merging ExpectedCrxType with |
| 52 // browser_sync::ExtensionType. | 51 // browser_sync::ExtensionType. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 140 |
| 142 // Determine if the downloaded extension came from the theme mini-gallery, | 141 // Determine if the downloaded extension came from the theme mini-gallery, |
| 143 // Used to test if we need to show the "Loading" dialog for themes. | 142 // Used to test if we need to show the "Loading" dialog for themes. |
| 144 static bool IsDownloadFromMiniGallery(const GURL& download_url); | 143 static bool IsDownloadFromMiniGallery(const GURL& download_url); |
| 145 | 144 |
| 146 // Attempts to uninstall an extension from a given ExtensionService. Returns | 145 // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 147 // true iff the target extension exists. | 146 // true iff the target extension exists. |
| 148 static bool UninstallExtensionHelper(ExtensionsService* extensions_service, | 147 static bool UninstallExtensionHelper(ExtensionsService* extensions_service, |
| 149 const std::string& extension_id); | 148 const std::string& extension_id); |
| 150 | 149 |
| 150 // Constructor stores pointers to |profile| and |extension_prefs| but |
| 151 // ownership remains at caller. |
| 151 ExtensionsService(Profile* profile, | 152 ExtensionsService(Profile* profile, |
| 152 const CommandLine* command_line, | 153 const CommandLine* command_line, |
| 153 const FilePath& install_directory, | 154 const FilePath& install_directory, |
| 155 ExtensionPrefs* extension_prefs, |
| 154 bool autoupdate_enabled); | 156 bool autoupdate_enabled); |
| 155 | 157 |
| 156 // Gets the list of currently installed extensions. | 158 // Gets the list of currently installed extensions. |
| 157 virtual const ExtensionList* extensions() const { return &extensions_; } | 159 virtual const ExtensionList* extensions() const { return &extensions_; } |
| 158 virtual const ExtensionList* disabled_extensions() const { | 160 virtual const ExtensionList* disabled_extensions() const { |
| 159 return &disabled_extensions_; | 161 return &disabled_extensions_; |
| 160 } | 162 } |
| 161 | 163 |
| 162 // Gets the set of pending extensions. | 164 // Gets the set of pending extensions. |
| 163 virtual const PendingExtensionMap& pending_extensions() const { | 165 virtual const PendingExtensionMap& pending_extensions() const { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 bool show_extensions_prompts() { | 397 bool show_extensions_prompts() { |
| 396 return show_extensions_prompts_; | 398 return show_extensions_prompts_; |
| 397 } | 399 } |
| 398 | 400 |
| 399 Profile* profile() { return profile_; } | 401 Profile* profile() { return profile_; } |
| 400 | 402 |
| 401 // Profile calls this when it is being destroyed so that we know not to call | 403 // Profile calls this when it is being destroyed so that we know not to call |
| 402 // it. | 404 // it. |
| 403 void DestroyingProfile(); | 405 void DestroyingProfile(); |
| 404 | 406 |
| 405 ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); } | 407 ExtensionPrefs* extension_prefs() { return extension_prefs_; } |
| 406 | 408 |
| 407 // Whether the extension service is ready. | 409 // Whether the extension service is ready. |
| 408 // TODO(skerner): Get rid of this method. crbug.com/63756 | 410 // TODO(skerner): Get rid of this method. crbug.com/63756 |
| 409 bool is_ready() { return ready_; } | 411 bool is_ready() { return ready_; } |
| 410 | 412 |
| 411 // Note that this may return NULL if autoupdate is not turned on. | 413 // Note that this may return NULL if autoupdate is not turned on. |
| 412 ExtensionUpdater* updater() { return updater_.get(); } | 414 ExtensionUpdater* updater() { return updater_.get(); } |
| 413 | 415 |
| 414 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } | 416 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } |
| 415 | 417 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 500 |
| 499 // Helper methods to configure the storage services accordingly. | 501 // Helper methods to configure the storage services accordingly. |
| 500 void GrantProtectedStorage(const Extension* extension); | 502 void GrantProtectedStorage(const Extension* extension); |
| 501 void RevokeProtectedStorage(const Extension* extension); | 503 void RevokeProtectedStorage(const Extension* extension); |
| 502 void GrantUnlimitedStorage(const Extension* extension); | 504 void GrantUnlimitedStorage(const Extension* extension); |
| 503 void RevokeUnlimitedStorage(const Extension* extension); | 505 void RevokeUnlimitedStorage(const Extension* extension); |
| 504 | 506 |
| 505 // The profile this ExtensionsService is part of. | 507 // The profile this ExtensionsService is part of. |
| 506 Profile* profile_; | 508 Profile* profile_; |
| 507 | 509 |
| 508 // Preferences for the owning profile. | 510 // Preferences for the owning profile (weak reference). |
| 509 scoped_ptr<ExtensionPrefs> extension_prefs_; | 511 ExtensionPrefs* extension_prefs_; |
| 510 | 512 |
| 511 // The current list of installed extensions. | 513 // The current list of installed extensions. |
| 512 ExtensionList extensions_; | 514 ExtensionList extensions_; |
| 513 | 515 |
| 514 // The list of installed extensions that have been disabled. | 516 // The list of installed extensions that have been disabled. |
| 515 ExtensionList disabled_extensions_; | 517 ExtensionList disabled_extensions_; |
| 516 | 518 |
| 517 // The set of pending extensions. | 519 // The set of pending extensions. |
| 518 PendingExtensionMap pending_extensions_; | 520 PendingExtensionMap pending_extensions_; |
| 519 | 521 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 600 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 599 UpdatePendingExtensionAlreadyInstalled); | 601 UpdatePendingExtensionAlreadyInstalled); |
| 600 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 602 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 601 InstallAppsWithUnlimtedStorage); | 603 InstallAppsWithUnlimtedStorage); |
| 602 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 604 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 603 InstallAppsAndCheckStorageProtection); | 605 InstallAppsAndCheckStorageProtection); |
| 604 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); | 606 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); |
| 605 }; | 607 }; |
| 606 | 608 |
| 607 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 609 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| OLD | NEW |