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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 bool AddFromSync( | 67 bool AddFromSync( |
68 const std::string& id, | 68 const std::string& id, |
69 const GURL& update_url, | 69 const GURL& update_url, |
70 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 70 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
71 bool install_silently); | 71 bool install_silently); |
72 | 72 |
73 // Given an extension id and an update URL, schedule the extension | 73 // Given an extension id and an update URL, schedule the extension |
74 // to be fetched, installed, and activated. | 74 // to be fetched, installed, and activated. |
75 bool AddFromExternalUpdateUrl(const std::string& id, | 75 bool AddFromExternalUpdateUrl(const std::string& id, |
76 const GURL& update_url, | 76 const GURL& update_url, |
77 Extension::Location location); | 77 extensions::Extension::Location location); |
78 | 78 |
79 // Add a pending extension record for an external CRX file. | 79 // Add a pending extension record for an external CRX file. |
80 // Return true if the CRX should be installed, false if an existing | 80 // Return true if the CRX should be installed, false if an existing |
81 // pending record overrides it. | 81 // pending record overrides it. |
82 bool AddFromExternalFile( | 82 bool AddFromExternalFile( |
83 const std::string& id, | 83 const std::string& id, |
84 Extension::Location location, | 84 extensions::Extension::Location location, |
85 const Version& version); | 85 const Version& version); |
86 | 86 |
87 // Get the set of pending IDs that should be installed from an update URL. | 87 // Get the set of pending IDs that should be installed from an update URL. |
88 // Pending extensions that will be installed from local files will not be | 88 // Pending extensions that will be installed from local files will not be |
89 // included in the set. | 89 // included in the set. |
90 void GetPendingIdsForUpdateCheck( | 90 void GetPendingIdsForUpdateCheck( |
91 std::set<std::string>* out_ids_for_update_check) const; | 91 std::set<std::string>* out_ids_for_update_check) const; |
92 | 92 |
93 private: | 93 private: |
94 typedef std::map<std::string, PendingExtensionInfo> PendingExtensionMap; | 94 typedef std::map<std::string, PendingExtensionInfo> PendingExtensionMap; |
95 | 95 |
96 // Assumes an extension with id |id| is not already installed. | 96 // Assumes an extension with id |id| is not already installed. |
97 // Return true if the extension was added. | 97 // Return true if the extension was added. |
98 bool AddExtensionImpl( | 98 bool AddExtensionImpl( |
99 const std::string& id, | 99 const std::string& id, |
100 const GURL& update_url, | 100 const GURL& update_url, |
101 const Version& version, | 101 const Version& version, |
102 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 102 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
103 bool is_from_sync, | 103 bool is_from_sync, |
104 bool install_silently, | 104 bool install_silently, |
105 Extension::Location install_source); | 105 extensions::Extension::Location install_source); |
106 | 106 |
107 // Add a pending extension record directly. Used for unit tests that need | 107 // Add a pending extension record directly. Used for unit tests that need |
108 // to set an inital state. Use friendship to allow the tests to call this | 108 // to set an inital state. Use friendship to allow the tests to call this |
109 // method. | 109 // method. |
110 void AddForTesting(const std::string& id, | 110 void AddForTesting(const std::string& id, |
111 const PendingExtensionInfo& pending_etension_info); | 111 const PendingExtensionInfo& pending_etension_info); |
112 | 112 |
113 // Reference to the extension service whose pending extensions this class is | 113 // Reference to the extension service whose pending extensions this class is |
114 // managing. Because this class is a member of |service_|, it is created | 114 // managing. Because this class is a member of |service_|, it is created |
115 // and destroyed with |service_|. We only use methods from the interface | 115 // and destroyed with |service_|. We only use methods from the interface |
116 // ExtensionServiceInterface. | 116 // ExtensionServiceInterface. |
117 const ExtensionServiceInterface& service_; | 117 const ExtensionServiceInterface& service_; |
118 | 118 |
119 // A map from extension id to the pending extension info for that extension. | 119 // A map from extension id to the pending extension info for that extension. |
120 PendingExtensionMap pending_extension_map_; | 120 PendingExtensionMap pending_extension_map_; |
121 | 121 |
122 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 122 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
123 UpdatePendingExtensionAlreadyInstalled); | 123 UpdatePendingExtensionAlreadyInstalled); |
124 friend class extensions::ExtensionUpdaterTest; | 124 friend class extensions::ExtensionUpdaterTest; |
125 friend void extensions::SetupPendingExtensionManagerForTest( | 125 friend void extensions::SetupPendingExtensionManagerForTest( |
126 int count, const GURL& update_url, | 126 int count, const GURL& update_url, |
127 PendingExtensionManager* pending_extension_manager); | 127 PendingExtensionManager* pending_extension_manager); |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); | 129 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); |
130 }; | 130 }; |
131 | 131 |
132 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 132 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
OLD | NEW |