OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "extensions/browser/pending_extension_manager.h" | 5 #include "extensions/browser/pending_extension_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Install predicate used by AddFromExternalUpdateUrl(). | 20 // Install predicate used by AddFromExternalUpdateUrl(). |
21 bool AlwaysInstall(const extensions::Extension* extension) { | 21 bool AlwaysInstall(const extensions::Extension* extension) { |
22 return true; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 std::string GetVersionString(const Version& version) { | 25 std::string GetVersionString(const base::Version& version) { |
26 return version.IsValid() ? version.GetString() : "invalid"; | 26 return version.IsValid() ? version.GetString() : "invalid"; |
27 } | 27 } |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 namespace extensions { | 31 namespace extensions { |
32 | 32 |
33 PendingExtensionManager::PendingExtensionManager( | 33 PendingExtensionManager::PendingExtensionManager( |
34 const ExtensionServiceInterface& service) | 34 const ExtensionServiceInterface& service) |
35 : service_(service) { | 35 : service_(service) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // should already be installed on every instance. | 102 // should already be installed on every instance. |
103 if (id == extension_misc::kWebStoreAppId) { | 103 if (id == extension_misc::kWebStoreAppId) { |
104 NOTREACHED(); | 104 NOTREACHED(); |
105 return false; | 105 return false; |
106 } | 106 } |
107 | 107 |
108 const bool kIsFromSync = true; | 108 const bool kIsFromSync = true; |
109 const Manifest::Location kSyncLocation = Manifest::INTERNAL; | 109 const Manifest::Location kSyncLocation = Manifest::INTERNAL; |
110 const bool kMarkAcknowledged = false; | 110 const bool kMarkAcknowledged = false; |
111 | 111 |
112 return AddExtensionImpl(id, update_url, Version(), should_allow_install, | 112 return AddExtensionImpl(id, update_url, base::Version(), should_allow_install, |
113 kIsFromSync, install_silently, kSyncLocation, | 113 kIsFromSync, install_silently, kSyncLocation, |
114 Extension::NO_FLAGS, kMarkAcknowledged); | 114 Extension::NO_FLAGS, kMarkAcknowledged); |
115 } | 115 } |
116 | 116 |
117 bool PendingExtensionManager::AddFromExtensionImport( | 117 bool PendingExtensionManager::AddFromExtensionImport( |
118 const std::string& id, | 118 const std::string& id, |
119 const GURL& update_url, | 119 const GURL& update_url, |
120 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { | 120 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { |
121 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 121 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
122 | 122 |
123 if (service_.GetInstalledExtension(id)) { | 123 if (service_.GetInstalledExtension(id)) { |
124 LOG(ERROR) << "Trying to add pending extension " << id | 124 LOG(ERROR) << "Trying to add pending extension " << id |
125 << " which already exists"; | 125 << " which already exists"; |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 const bool kIsFromSync = false; | 129 const bool kIsFromSync = false; |
130 const bool kInstallSilently = true; | 130 const bool kInstallSilently = true; |
131 const Manifest::Location kManifestLocation = Manifest::INTERNAL; | 131 const Manifest::Location kManifestLocation = Manifest::INTERNAL; |
132 const bool kMarkAcknowledged = false; | 132 const bool kMarkAcknowledged = false; |
133 | 133 |
134 return AddExtensionImpl(id, update_url, Version(), should_allow_install, | 134 return AddExtensionImpl(id, update_url, base::Version(), should_allow_install, |
135 kIsFromSync, kInstallSilently, kManifestLocation, | 135 kIsFromSync, kInstallSilently, kManifestLocation, |
136 Extension::NO_FLAGS, kMarkAcknowledged); | 136 Extension::NO_FLAGS, kMarkAcknowledged); |
137 } | 137 } |
138 | 138 |
139 bool PendingExtensionManager::AddFromExternalUpdateUrl( | 139 bool PendingExtensionManager::AddFromExternalUpdateUrl( |
140 const std::string& id, | 140 const std::string& id, |
141 const GURL& update_url, | 141 const GURL& update_url, |
142 Manifest::Location location, | 142 Manifest::Location location, |
143 int creation_flags, | 143 int creation_flags, |
144 bool mark_acknowledged) { | 144 bool mark_acknowledged) { |
(...skipping 12 matching lines...) Expand all Loading... |
157 if (service_.IsExternalExtensionUninstalled(id)) | 157 if (service_.IsExternalExtensionUninstalled(id)) |
158 return false; | 158 return false; |
159 | 159 |
160 if (extension) { | 160 if (extension) { |
161 LOG(DFATAL) << "Trying to add extension " << id | 161 LOG(DFATAL) << "Trying to add extension " << id |
162 << " by external update, but it is already installed."; | 162 << " by external update, but it is already installed."; |
163 return false; | 163 return false; |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 return AddExtensionImpl(id, update_url, Version(), &AlwaysInstall, | 167 return AddExtensionImpl(id, update_url, base::Version(), &AlwaysInstall, |
168 kIsFromSync, kInstallSilently, | 168 kIsFromSync, kInstallSilently, |
169 location, creation_flags, mark_acknowledged); | 169 location, creation_flags, mark_acknowledged); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 bool PendingExtensionManager::AddFromExternalFile( | 173 bool PendingExtensionManager::AddFromExternalFile( |
174 const std::string& id, | 174 const std::string& id, |
175 Manifest::Location install_source, | 175 Manifest::Location install_source, |
176 const Version& version, | 176 const base::Version& version, |
177 int creation_flags, | 177 int creation_flags, |
178 bool mark_acknowledged) { | 178 bool mark_acknowledged) { |
179 // TODO(skerner): AddFromSync() checks to see if the extension is | 179 // TODO(skerner): AddFromSync() checks to see if the extension is |
180 // installed, but this method assumes that the caller already | 180 // installed, but this method assumes that the caller already |
181 // made sure it is not installed. Make all AddFrom*() methods | 181 // made sure it is not installed. Make all AddFrom*() methods |
182 // consistent. | 182 // consistent. |
183 GURL kUpdateUrl = GURL(); | 183 GURL kUpdateUrl = GURL(); |
184 bool kIsFromSync = false; | 184 bool kIsFromSync = false; |
185 bool kInstallSilently = true; | 185 bool kInstallSilently = true; |
186 | 186 |
(...skipping 24 matching lines...) Expand all Loading... |
211 install_source == Manifest::EXTERNAL_REGISTRY) | 211 install_source == Manifest::EXTERNAL_REGISTRY) |
212 continue; | 212 continue; |
213 | 213 |
214 out_ids_for_update_check->push_back(iter->id()); | 214 out_ids_for_update_check->push_back(iter->id()); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 bool PendingExtensionManager::AddExtensionImpl( | 218 bool PendingExtensionManager::AddExtensionImpl( |
219 const std::string& id, | 219 const std::string& id, |
220 const GURL& update_url, | 220 const GURL& update_url, |
221 const Version& version, | 221 const base::Version& version, |
222 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 222 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
223 bool is_from_sync, | 223 bool is_from_sync, |
224 bool install_silently, | 224 bool install_silently, |
225 Manifest::Location install_source, | 225 Manifest::Location install_source, |
226 int creation_flags, | 226 int creation_flags, |
227 bool mark_acknowledged) { | 227 bool mark_acknowledged) { |
228 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 228 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
229 | 229 |
230 PendingExtensionInfo info(id, | 230 PendingExtensionInfo info(id, |
231 update_url, | 231 update_url, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 return true; | 272 return true; |
273 } | 273 } |
274 | 274 |
275 void PendingExtensionManager::AddForTesting( | 275 void PendingExtensionManager::AddForTesting( |
276 const PendingExtensionInfo& pending_extension_info) { | 276 const PendingExtensionInfo& pending_extension_info) { |
277 pending_extension_list_.push_back(pending_extension_info); | 277 pending_extension_list_.push_back(pending_extension_info); |
278 } | 278 } |
279 | 279 |
280 } // namespace extensions | 280 } // namespace extensions |
OLD | NEW |