| 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 scoped_ptr<Version> version(new Version(external_version)); | 346 std::unique_ptr<Version> version(new Version(external_version)); |
| 347 if (!version->IsValid()) { | 347 if (!version->IsValid()) { |
| 348 LOG(WARNING) << "Malformed extension dictionary for extension: " | 348 LOG(WARNING) << "Malformed extension dictionary for extension: " |
| 349 << extension_id.c_str() << ". Invalid version string \"" | 349 << extension_id.c_str() << ". Invalid version string \"" |
| 350 << external_version << "\"."; | 350 << external_version << "\"."; |
| 351 continue; | 351 continue; |
| 352 } | 352 } |
| 353 external_file_extensions->push_back(new ExternalInstallInfoFile( | 353 external_file_extensions->push_back(new ExternalInstallInfoFile( |
| 354 extension_id, std::move(version), path, crx_location_, creation_flags, | 354 extension_id, std::move(version), path, crx_location_, creation_flags, |
| 355 auto_acknowledge_, install_immediately_)); | 355 auto_acknowledge_, install_immediately_)); |
| 356 } else { // if (has_external_update_url) | 356 } else { // if (has_external_update_url) |
| 357 CHECK(has_external_update_url); // Checking of keys above ensures this. | 357 CHECK(has_external_update_url); // Checking of keys above ensures this. |
| 358 if (download_location_ == Manifest::INVALID_LOCATION) { | 358 if (download_location_ == Manifest::INVALID_LOCATION) { |
| 359 LOG(WARNING) << "This provider does not support installing external " | 359 LOG(WARNING) << "This provider does not support installing external " |
| 360 << "extensions from update URLs."; | 360 << "extensions from update URLs."; |
| 361 continue; | 361 continue; |
| 362 } | 362 } |
| 363 scoped_ptr<GURL> update_url(new GURL(external_update_url)); | 363 std::unique_ptr<GURL> update_url(new GURL(external_update_url)); |
| 364 if (!update_url->is_valid()) { | 364 if (!update_url->is_valid()) { |
| 365 LOG(WARNING) << "Malformed extension dictionary for extension: " | 365 LOG(WARNING) << "Malformed extension dictionary for extension: " |
| 366 << extension_id.c_str() << ". Key " << kExternalUpdateUrl | 366 << extension_id.c_str() << ". Key " << kExternalUpdateUrl |
| 367 << " has value \"" << external_update_url | 367 << " has value \"" << external_update_url |
| 368 << "\", which is not a valid URL."; | 368 << "\", which is not a valid URL."; |
| 369 continue; | 369 continue; |
| 370 } | 370 } |
| 371 external_update_url_extensions->push_back( | 371 external_update_url_extensions->push_back( |
| 372 new ExternalInstallInfoUpdateUrl( | 372 new ExternalInstallInfoUpdateUrl( |
| 373 extension_id, install_parameter, std::move(update_url), | 373 extension_id, install_parameter, std::move(update_url), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 393 | 393 |
| 394 bool ExternalProviderImpl::HasExtension( | 394 bool ExternalProviderImpl::HasExtension( |
| 395 const std::string& id) const { | 395 const std::string& id) const { |
| 396 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 396 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 397 CHECK(prefs_.get()); | 397 CHECK(prefs_.get()); |
| 398 CHECK(ready_); | 398 CHECK(ready_); |
| 399 return prefs_->HasKey(id); | 399 return prefs_->HasKey(id); |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool ExternalProviderImpl::GetExtensionDetails( | 402 bool ExternalProviderImpl::GetExtensionDetails( |
| 403 const std::string& id, Manifest::Location* location, | 403 const std::string& id, |
| 404 scoped_ptr<Version>* version) const { | 404 Manifest::Location* location, |
| 405 std::unique_ptr<Version>* version) const { |
| 405 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 406 CHECK(prefs_.get()); | 407 CHECK(prefs_.get()); |
| 407 CHECK(ready_); | 408 CHECK(ready_); |
| 408 base::DictionaryValue* extension = NULL; | 409 base::DictionaryValue* extension = NULL; |
| 409 if (!prefs_->GetDictionary(id, &extension)) | 410 if (!prefs_->GetDictionary(id, &extension)) |
| 410 return false; | 411 return false; |
| 411 | 412 |
| 412 Manifest::Location loc = Manifest::INVALID_LOCATION; | 413 Manifest::Location loc = Manifest::INVALID_LOCATION; |
| 413 if (extension->HasKey(kExternalUpdateUrl)) { | 414 if (extension->HasKey(kExternalUpdateUrl)) { |
| 414 loc = download_location_; | 415 loc = download_location_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (!kiosk_app_manager->external_loader_created()) { | 551 if (!kiosk_app_manager->external_loader_created()) { |
| 551 // For enterprise managed kiosk apps, change the location to | 552 // For enterprise managed kiosk apps, change the location to |
| 552 // "force-installed by policy". | 553 // "force-installed by policy". |
| 553 policy::BrowserPolicyConnectorChromeOS* const connector = | 554 policy::BrowserPolicyConnectorChromeOS* const connector = |
| 554 g_browser_process->platform_part() | 555 g_browser_process->platform_part() |
| 555 ->browser_policy_connector_chromeos(); | 556 ->browser_policy_connector_chromeos(); |
| 556 Manifest::Location location = Manifest::EXTERNAL_PREF; | 557 Manifest::Location location = Manifest::EXTERNAL_PREF; |
| 557 if (connector && connector->IsEnterpriseManaged()) | 558 if (connector && connector->IsEnterpriseManaged()) |
| 558 location = Manifest::EXTERNAL_POLICY; | 559 location = Manifest::EXTERNAL_POLICY; |
| 559 | 560 |
| 560 scoped_ptr<ExternalProviderImpl> kiosk_app_provider( | 561 std::unique_ptr<ExternalProviderImpl> kiosk_app_provider( |
| 561 new ExternalProviderImpl( | 562 new ExternalProviderImpl( |
| 562 service, kiosk_app_manager->CreateExternalLoader(), profile, | 563 service, kiosk_app_manager->CreateExternalLoader(), profile, |
| 563 location, Manifest::INVALID_LOCATION, Extension::NO_FLAGS)); | 564 location, Manifest::INVALID_LOCATION, Extension::NO_FLAGS)); |
| 564 kiosk_app_provider->set_auto_acknowledge(true); | 565 kiosk_app_provider->set_auto_acknowledge(true); |
| 565 kiosk_app_provider->set_install_immediately(true); | 566 kiosk_app_provider->set_install_immediately(true); |
| 566 provider_list->push_back( | 567 provider_list->push_back( |
| 567 linked_ptr<ExternalProviderInterface>(kiosk_app_provider.release())); | 568 linked_ptr<ExternalProviderInterface>(kiosk_app_provider.release())); |
| 568 } | 569 } |
| 569 | 570 |
| 570 // Kiosk secondary app external provider. | 571 // Kiosk secondary app external provider. |
| 571 if (!kiosk_app_manager->secondary_app_external_loader_created()) { | 572 if (!kiosk_app_manager->secondary_app_external_loader_created()) { |
| 572 scoped_ptr<ExternalProviderImpl> secondary_kiosk_app_provider( | 573 std::unique_ptr<ExternalProviderImpl> secondary_kiosk_app_provider( |
| 573 new ExternalProviderImpl( | 574 new ExternalProviderImpl( |
| 574 service, kiosk_app_manager->CreateSecondaryAppExternalLoader(), | 575 service, kiosk_app_manager->CreateSecondaryAppExternalLoader(), |
| 575 profile, Manifest::EXTERNAL_PREF, | 576 profile, Manifest::EXTERNAL_PREF, |
| 576 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS)); | 577 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS)); |
| 577 secondary_kiosk_app_provider->set_auto_acknowledge(true); | 578 secondary_kiosk_app_provider->set_auto_acknowledge(true); |
| 578 secondary_kiosk_app_provider->set_install_immediately(true); | 579 secondary_kiosk_app_provider->set_install_immediately(true); |
| 579 provider_list->push_back(linked_ptr<ExternalProviderInterface>( | 580 provider_list->push_back(linked_ptr<ExternalProviderInterface>( |
| 580 secondary_kiosk_app_provider.release())); | 581 secondary_kiosk_app_provider.release())); |
| 581 } | 582 } |
| 582 #endif | 583 #endif |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 service, | 713 service, |
| 713 new ExternalPrefLoader(chrome::DIR_DEFAULT_APPS, | 714 new ExternalPrefLoader(chrome::DIR_DEFAULT_APPS, |
| 714 ExternalPrefLoader::NONE, | 715 ExternalPrefLoader::NONE, |
| 715 NULL), | 716 NULL), |
| 716 Manifest::INTERNAL, | 717 Manifest::INTERNAL, |
| 717 Manifest::INTERNAL, | 718 Manifest::INTERNAL, |
| 718 Extension::FROM_WEBSTORE | | 719 Extension::FROM_WEBSTORE | |
| 719 Extension::WAS_INSTALLED_BY_DEFAULT))); | 720 Extension::WAS_INSTALLED_BY_DEFAULT))); |
| 720 #endif | 721 #endif |
| 721 | 722 |
| 722 scoped_ptr<ExternalProviderImpl> drive_migration_provider( | 723 std::unique_ptr<ExternalProviderImpl> drive_migration_provider( |
| 723 new ExternalProviderImpl( | 724 new ExternalProviderImpl( |
| 724 service, | 725 service, |
| 725 new ExtensionMigrator(profile, | 726 new ExtensionMigrator(profile, extension_misc::kDriveHostedAppId, |
| 726 extension_misc::kDriveHostedAppId, | |
| 727 extension_misc::kDriveExtensionId), | 727 extension_misc::kDriveExtensionId), |
| 728 profile, | 728 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 729 Manifest::EXTERNAL_PREF, | 729 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)); |
| 730 Manifest::EXTERNAL_PREF_DOWNLOAD, | |
| 731 Extension::FROM_WEBSTORE | | |
| 732 Extension::WAS_INSTALLED_BY_DEFAULT)); | |
| 733 drive_migration_provider->set_auto_acknowledge(true); | 730 drive_migration_provider->set_auto_acknowledge(true); |
| 734 provider_list->push_back(linked_ptr<ExternalProviderInterface>( | 731 provider_list->push_back(linked_ptr<ExternalProviderInterface>( |
| 735 drive_migration_provider.release())); | 732 drive_migration_provider.release())); |
| 736 } | 733 } |
| 737 | 734 |
| 738 provider_list->push_back( | 735 provider_list->push_back( |
| 739 linked_ptr<ExternalProviderInterface>( | 736 linked_ptr<ExternalProviderInterface>( |
| 740 new ExternalProviderImpl( | 737 new ExternalProviderImpl( |
| 741 service, | 738 service, |
| 742 new ExternalComponentLoader(profile), | 739 new ExternalComponentLoader(profile), |
| 743 profile, | 740 profile, |
| 744 Manifest::INVALID_LOCATION, | 741 Manifest::INVALID_LOCATION, |
| 745 Manifest::EXTERNAL_COMPONENT, | 742 Manifest::EXTERNAL_COMPONENT, |
| 746 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 743 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
| 747 } | 744 } |
| 748 | 745 |
| 749 } // namespace extensions | 746 } // namespace extensions |
| OLD | NEW |