| 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_PENDING_EXTENSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/extensions/pending_extension_info.h" | 11 #include "chrome/browser/extensions/pending_extension_info.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/manifest.h" |
| 13 | 14 |
| 14 class ExtensionServiceInterface; | 15 class ExtensionServiceInterface; |
| 15 class GURL; | 16 class GURL; |
| 16 class PendingExtensionManager; | 17 class PendingExtensionManager; |
| 17 class Version; | 18 class Version; |
| 18 | 19 |
| 19 FORWARD_DECLARE_TEST(ExtensionServiceTest, | 20 FORWARD_DECLARE_TEST(ExtensionServiceTest, |
| 20 UpdatePendingExtensionAlreadyInstalled); | 21 UpdatePendingExtensionAlreadyInstalled); |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool AddFromSync( | 74 bool AddFromSync( |
| 74 const std::string& id, | 75 const std::string& id, |
| 75 const GURL& update_url, | 76 const GURL& update_url, |
| 76 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 77 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
| 77 bool install_silently); | 78 bool install_silently); |
| 78 | 79 |
| 79 // Given an extension id and an update URL, schedule the extension | 80 // Given an extension id and an update URL, schedule the extension |
| 80 // to be fetched, installed, and activated. | 81 // to be fetched, installed, and activated. |
| 81 bool AddFromExternalUpdateUrl(const std::string& id, | 82 bool AddFromExternalUpdateUrl(const std::string& id, |
| 82 const GURL& update_url, | 83 const GURL& update_url, |
| 83 Extension::Location location); | 84 Manifest::Location location); |
| 84 | 85 |
| 85 // Add a pending extension record for an external CRX file. | 86 // Add a pending extension record for an external CRX file. |
| 86 // Return true if the CRX should be installed, false if an existing | 87 // Return true if the CRX should be installed, false if an existing |
| 87 // pending record overrides it. | 88 // pending record overrides it. |
| 88 bool AddFromExternalFile( | 89 bool AddFromExternalFile( |
| 89 const std::string& id, | 90 const std::string& id, |
| 90 Extension::Location location, | 91 Manifest::Location location, |
| 91 const Version& version); | 92 const Version& version); |
| 92 | 93 |
| 93 // Get the list of pending IDs that should be installed from an update URL. | 94 // Get the list of pending IDs that should be installed from an update URL. |
| 94 // Pending extensions that will be installed from local files will not be | 95 // Pending extensions that will be installed from local files will not be |
| 95 // included in the set. | 96 // included in the set. |
| 96 void GetPendingIdsForUpdateCheck( | 97 void GetPendingIdsForUpdateCheck( |
| 97 std::list<std::string>* out_ids_for_update_check) const; | 98 std::list<std::string>* out_ids_for_update_check) const; |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 typedef std::list<PendingExtensionInfo> PendingExtensionList; | 101 typedef std::list<PendingExtensionInfo> PendingExtensionList; |
| 101 | 102 |
| 102 // Assumes an extension with id |id| is not already installed. | 103 // Assumes an extension with id |id| is not already installed. |
| 103 // Return true if the extension was added. | 104 // Return true if the extension was added. |
| 104 bool AddExtensionImpl( | 105 bool AddExtensionImpl( |
| 105 const std::string& id, | 106 const std::string& id, |
| 106 const GURL& update_url, | 107 const GURL& update_url, |
| 107 const Version& version, | 108 const Version& version, |
| 108 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 109 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
| 109 bool is_from_sync, | 110 bool is_from_sync, |
| 110 bool install_silently, | 111 bool install_silently, |
| 111 Extension::Location install_source); | 112 Manifest::Location install_source); |
| 112 | 113 |
| 113 // Add a pending extension record directly. Used for unit tests that need | 114 // Add a pending extension record directly. Used for unit tests that need |
| 114 // to set an inital state. Use friendship to allow the tests to call this | 115 // to set an inital state. Use friendship to allow the tests to call this |
| 115 // method. | 116 // method. |
| 116 void AddForTesting(const PendingExtensionInfo& pending_extension_info); | 117 void AddForTesting(const PendingExtensionInfo& pending_extension_info); |
| 117 | 118 |
| 118 // Reference to the extension service whose pending extensions this class is | 119 // Reference to the extension service whose pending extensions this class is |
| 119 // managing. Because this class is a member of |service_|, it is created | 120 // managing. Because this class is a member of |service_|, it is created |
| 120 // and destroyed with |service_|. We only use methods from the interface | 121 // and destroyed with |service_|. We only use methods from the interface |
| 121 // ExtensionServiceInterface. | 122 // ExtensionServiceInterface. |
| 122 const ExtensionServiceInterface& service_; | 123 const ExtensionServiceInterface& service_; |
| 123 | 124 |
| 124 PendingExtensionList pending_extension_list_; | 125 PendingExtensionList pending_extension_list_; |
| 125 | 126 |
| 126 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, | 127 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, |
| 127 UpdatePendingExtensionAlreadyInstalled); | 128 UpdatePendingExtensionAlreadyInstalled); |
| 128 friend class ExtensionUpdaterTest; | 129 friend class ExtensionUpdaterTest; |
| 129 friend void SetupPendingExtensionManagerForTest( | 130 friend void SetupPendingExtensionManagerForTest( |
| 130 int count, const GURL& update_url, | 131 int count, const GURL& update_url, |
| 131 PendingExtensionManager* pending_extension_manager); | 132 PendingExtensionManager* pending_extension_manager); |
| 132 | 133 |
| 133 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); | 134 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 } // namespace extensions | 137 } // namespace extensions |
| 137 | 138 |
| 138 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 139 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
| OLD | NEW |