| 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_provider_impl.h" | 5 #include "chrome/browser/extensions/external_provider_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if (!path.IsAbsolute()) { | 336 if (!path.IsAbsolute()) { |
| 337 base::FilePath base_path = loader_->GetBaseCrxFilePath(); | 337 base::FilePath base_path = loader_->GetBaseCrxFilePath(); |
| 338 if (base_path.empty()) { | 338 if (base_path.empty()) { |
| 339 LOG(WARNING) << "File path " << external_crx.c_str() | 339 LOG(WARNING) << "File path " << external_crx.c_str() |
| 340 << " is relative. An absolute path is required."; | 340 << " is relative. An absolute path is required."; |
| 341 continue; | 341 continue; |
| 342 } | 342 } |
| 343 path = base_path.Append(external_crx); | 343 path = base_path.Append(external_crx); |
| 344 } | 344 } |
| 345 | 345 |
| 346 std::unique_ptr<Version> version(new Version(external_version)); | 346 std::unique_ptr<base::Version> version( |
| 347 new base::Version(external_version)); |
| 347 if (!version->IsValid()) { | 348 if (!version->IsValid()) { |
| 348 LOG(WARNING) << "Malformed extension dictionary for extension: " | 349 LOG(WARNING) << "Malformed extension dictionary for extension: " |
| 349 << extension_id.c_str() << ". Invalid version string \"" | 350 << extension_id.c_str() << ". Invalid version string \"" |
| 350 << external_version << "\"."; | 351 << external_version << "\"."; |
| 351 continue; | 352 continue; |
| 352 } | 353 } |
| 353 external_file_extensions->push_back(new ExternalInstallInfoFile( | 354 external_file_extensions->push_back(new ExternalInstallInfoFile( |
| 354 extension_id, std::move(version), path, crx_location_, creation_flags, | 355 extension_id, std::move(version), path, crx_location_, creation_flags, |
| 355 auto_acknowledge_, install_immediately_)); | 356 auto_acknowledge_, install_immediately_)); |
| 356 } else { // if (has_external_update_url) | 357 } else { // if (has_external_update_url) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 const std::string& id) const { | 396 const std::string& id) const { |
| 396 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 397 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 397 CHECK(prefs_.get()); | 398 CHECK(prefs_.get()); |
| 398 CHECK(ready_); | 399 CHECK(ready_); |
| 399 return prefs_->HasKey(id); | 400 return prefs_->HasKey(id); |
| 400 } | 401 } |
| 401 | 402 |
| 402 bool ExternalProviderImpl::GetExtensionDetails( | 403 bool ExternalProviderImpl::GetExtensionDetails( |
| 403 const std::string& id, | 404 const std::string& id, |
| 404 Manifest::Location* location, | 405 Manifest::Location* location, |
| 405 std::unique_ptr<Version>* version) const { | 406 std::unique_ptr<base::Version>* version) const { |
| 406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 407 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 407 CHECK(prefs_.get()); | 408 CHECK(prefs_.get()); |
| 408 CHECK(ready_); | 409 CHECK(ready_); |
| 409 base::DictionaryValue* extension = NULL; | 410 base::DictionaryValue* extension = NULL; |
| 410 if (!prefs_->GetDictionary(id, &extension)) | 411 if (!prefs_->GetDictionary(id, &extension)) |
| 411 return false; | 412 return false; |
| 412 | 413 |
| 413 Manifest::Location loc = Manifest::INVALID_LOCATION; | 414 Manifest::Location loc = Manifest::INVALID_LOCATION; |
| 414 if (extension->HasKey(kExternalUpdateUrl)) { | 415 if (extension->HasKey(kExternalUpdateUrl)) { |
| 415 loc = download_location_; | 416 loc = download_location_; |
| 416 | 417 |
| 417 } else if (extension->HasKey(kExternalCrx)) { | 418 } else if (extension->HasKey(kExternalCrx)) { |
| 418 loc = crx_location_; | 419 loc = crx_location_; |
| 419 | 420 |
| 420 std::string external_version; | 421 std::string external_version; |
| 421 if (!extension->GetString(kExternalVersion, &external_version)) | 422 if (!extension->GetString(kExternalVersion, &external_version)) |
| 422 return false; | 423 return false; |
| 423 | 424 |
| 424 if (version) | 425 if (version) |
| 425 version->reset(new Version(external_version)); | 426 version->reset(new base::Version(external_version)); |
| 426 | 427 |
| 427 } else { | 428 } else { |
| 428 NOTREACHED(); // Chrome should not allow prefs to get into this state. | 429 NOTREACHED(); // Chrome should not allow prefs to get into this state. |
| 429 return false; | 430 return false; |
| 430 } | 431 } |
| 431 | 432 |
| 432 if (location) | 433 if (location) |
| 433 *location = loc; | 434 *location = loc; |
| 434 | 435 |
| 435 return true; | 436 return true; |
| 436 } | 437 } |
| 437 | 438 |
| 438 bool ExternalProviderImpl::HandleMinProfileVersion( | 439 bool ExternalProviderImpl::HandleMinProfileVersion( |
| 439 const base::DictionaryValue* extension, | 440 const base::DictionaryValue* extension, |
| 440 const std::string& extension_id, | 441 const std::string& extension_id, |
| 441 std::set<std::string>* unsupported_extensions) { | 442 std::set<std::string>* unsupported_extensions) { |
| 442 std::string min_profile_created_by_version; | 443 std::string min_profile_created_by_version; |
| 443 if (profile_ && | 444 if (profile_ && |
| 444 extension->GetString(kMinProfileCreatedByVersion, | 445 extension->GetString(kMinProfileCreatedByVersion, |
| 445 &min_profile_created_by_version)) { | 446 &min_profile_created_by_version)) { |
| 446 Version profile_version( | 447 base::Version profile_version( |
| 447 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion)); | 448 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion)); |
| 448 Version min_version(min_profile_created_by_version); | 449 base::Version min_version(min_profile_created_by_version); |
| 449 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) { | 450 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) { |
| 450 unsupported_extensions->insert(extension_id); | 451 unsupported_extensions->insert(extension_id); |
| 451 VLOG(1) << "Skip installing (or uninstall) external extension: " | 452 VLOG(1) << "Skip installing (or uninstall) external extension: " |
| 452 << extension_id | 453 << extension_id |
| 453 << " profile.created_by_version: " << profile_version.GetString() | 454 << " profile.created_by_version: " << profile_version.GetString() |
| 454 << " min_profile_created_by_version: " | 455 << " min_profile_created_by_version: " |
| 455 << min_profile_created_by_version; | 456 << min_profile_created_by_version; |
| 456 return false; | 457 return false; |
| 457 } | 458 } |
| 458 } | 459 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 new ExternalProviderImpl( | 738 new ExternalProviderImpl( |
| 738 service, | 739 service, |
| 739 new ExternalComponentLoader(profile), | 740 new ExternalComponentLoader(profile), |
| 740 profile, | 741 profile, |
| 741 Manifest::INVALID_LOCATION, | 742 Manifest::INVALID_LOCATION, |
| 742 Manifest::EXTERNAL_COMPONENT, | 743 Manifest::EXTERNAL_COMPONENT, |
| 743 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 744 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
| 744 } | 745 } |
| 745 | 746 |
| 746 } // namespace extensions | 747 } // namespace extensions |
| OLD | NEW |