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 #include "chrome/browser/extensions/external_extension_provider_impl.h" | 5 #include "chrome/browser/extensions/external_extension_provider_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (!path.IsAbsolute()) { | 197 if (!path.IsAbsolute()) { |
198 FilePath base_path = loader_->GetBaseCrxFilePath(); | 198 FilePath base_path = loader_->GetBaseCrxFilePath(); |
199 if (base_path.empty()) { | 199 if (base_path.empty()) { |
200 LOG(WARNING) << "File path " << external_crx.c_str() | 200 LOG(WARNING) << "File path " << external_crx.c_str() |
201 << " is relative. An absolute path is required."; | 201 << " is relative. An absolute path is required."; |
202 continue; | 202 continue; |
203 } | 203 } |
204 path = base_path.Append(external_crx); | 204 path = base_path.Append(external_crx); |
205 } | 205 } |
206 | 206 |
207 scoped_ptr<Version> version; | 207 Version version(external_version); |
208 version.reset(Version::GetVersionFromString(external_version)); | 208 if (!version.IsValid()) { |
209 if (!version.get()) { | |
210 LOG(WARNING) << "Malformed extension dictionary for extension: " | 209 LOG(WARNING) << "Malformed extension dictionary for extension: " |
211 << extension_id.c_str() << ". Invalid version string \"" | 210 << extension_id.c_str() << ". Invalid version string \"" |
212 << external_version << "\"."; | 211 << external_version << "\"."; |
213 continue; | 212 continue; |
214 } | 213 } |
215 service_->OnExternalExtensionFileFound(extension_id, version.get(), path, | 214 service_->OnExternalExtensionFileFound(extension_id, &version, path, |
216 crx_location_, creation_flags, | 215 crx_location_, creation_flags, |
217 auto_acknowledge_); | 216 auto_acknowledge_); |
218 } else { // if (has_external_update_url) | 217 } else { // if (has_external_update_url) |
219 CHECK(has_external_update_url); // Checking of keys above ensures this. | 218 CHECK(has_external_update_url); // Checking of keys above ensures this. |
220 if (download_location_ == Extension::INVALID) { | 219 if (download_location_ == Extension::INVALID) { |
221 LOG(WARNING) << "This provider does not support installing external " | 220 LOG(WARNING) << "This provider does not support installing external " |
222 << "extensions from update URLs."; | 221 << "extensions from update URLs."; |
223 continue; | 222 continue; |
224 } | 223 } |
225 GURL update_url(external_update_url); | 224 GURL update_url(external_update_url); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 loc = download_location_; | 275 loc = download_location_; |
277 | 276 |
278 } else if (extension->HasKey(kExternalCrx)) { | 277 } else if (extension->HasKey(kExternalCrx)) { |
279 loc = crx_location_; | 278 loc = crx_location_; |
280 | 279 |
281 std::string external_version; | 280 std::string external_version; |
282 if (!extension->GetString(kExternalVersion, &external_version)) | 281 if (!extension->GetString(kExternalVersion, &external_version)) |
283 return false; | 282 return false; |
284 | 283 |
285 if (version) | 284 if (version) |
286 version->reset(Version::GetVersionFromString(external_version)); | 285 version->reset(new Version(external_version)); |
287 | 286 |
288 } else { | 287 } else { |
289 NOTREACHED(); // Chrome should not allow prefs to get into this state. | 288 NOTREACHED(); // Chrome should not allow prefs to get into this state. |
290 return false; | 289 return false; |
291 } | 290 } |
292 | 291 |
293 if (location) | 292 if (location) |
294 *location = loc; | 293 *location = loc; |
295 | 294 |
296 return true; | 295 return true; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 linked_ptr<ExternalExtensionProviderInterface>( | 404 linked_ptr<ExternalExtensionProviderInterface>( |
406 new ExternalExtensionProviderImpl( | 405 new ExternalExtensionProviderImpl( |
407 service, | 406 service, |
408 connector->GetAppPackUpdater()->CreateExternalExtensionLoader(), | 407 connector->GetAppPackUpdater()->CreateExternalExtensionLoader(), |
409 Extension::EXTERNAL_PREF, | 408 Extension::EXTERNAL_PREF, |
410 Extension::INVALID, | 409 Extension::INVALID, |
411 Extension::NO_FLAGS))); | 410 Extension::NO_FLAGS))); |
412 } | 411 } |
413 #endif | 412 #endif |
414 } | 413 } |
OLD | NEW |