| 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 <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "extensions/common/manifest.h" | 36 #include "extensions/common/manifest.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 38 | 38 |
| 39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
| 40 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 40 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 41 #include "chrome/browser/chromeos/customization/customization_document.h" | 41 #include "chrome/browser/chromeos/customization/customization_document.h" |
| 42 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" | 42 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" |
| 43 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 43 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 44 #include "chrome/browser/chromeos/policy/device_local_account.h" | 44 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 45 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 45 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 46 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | |
| 47 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | |
| 48 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 46 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 49 #include "components/user_manager/user.h" | 47 #include "components/user_manager/user.h" |
| 50 #else | 48 #else |
| 51 #include "chrome/browser/extensions/default_apps.h" | 49 #include "chrome/browser/extensions/default_apps.h" |
| 52 #endif | 50 #endif |
| 53 | 51 |
| 54 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
| 55 #include "chrome/browser/extensions/external_registry_loader_win.h" | 53 #include "chrome/browser/extensions/external_registry_loader_win.h" |
| 56 #endif | 54 #endif |
| 57 | 55 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const Extension* extension = extension_service ? | 222 const Extension* extension = extension_service ? |
| 225 extension_service->GetExtensionById(extension_id, true) : NULL; | 223 extension_service->GetExtensionById(extension_id, true) : NULL; |
| 226 if (!extension) { | 224 if (!extension) { |
| 227 unsupported_extensions.insert(extension_id); | 225 unsupported_extensions.insert(extension_id); |
| 228 VLOG(1) << "Skip installing (or uninstall) external extension: " | 226 VLOG(1) << "Skip installing (or uninstall) external extension: " |
| 229 << extension_id << " because the extension should be kept " | 227 << extension_id << " because the extension should be kept " |
| 230 << "only if it is already installed."; | 228 << "only if it is already installed."; |
| 231 continue; | 229 continue; |
| 232 } | 230 } |
| 233 } | 231 } |
| 234 if (!HandleInstalledByOem(extension, extension_id, &unsupported_extensions, | 232 bool was_installed_by_oem = false; |
| 235 &creation_flags)) | 233 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && |
| 236 continue; | 234 was_installed_by_oem) { |
| 237 | 235 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; |
| 236 } |
| 238 bool may_be_untrusted = false; | 237 bool may_be_untrusted = false; |
| 239 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && | 238 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && |
| 240 may_be_untrusted) { | 239 may_be_untrusted) { |
| 241 creation_flags |= Extension::MAY_BE_UNTRUSTED; | 240 creation_flags |= Extension::MAY_BE_UNTRUSTED; |
| 242 } | 241 } |
| 243 | 242 |
| 244 if (!HandleMinProfileVersion(extension, extension_id, | 243 if (!ExternalProviderImpl::HandleMinProfileVersion(extension, extension_id, |
| 245 &unsupported_extensions)) | 244 &unsupported_extensions)) |
| 246 continue; | 245 continue; |
| 247 | 246 |
| 248 std::string install_parameter; | 247 std::string install_parameter; |
| 249 extension->GetString(kInstallParam, &install_parameter); | 248 extension->GetString(kInstallParam, &install_parameter); |
| 250 | 249 |
| 251 if (has_external_crx) { | 250 if (has_external_crx) { |
| 252 if (crx_location_ == Manifest::INVALID_LOCATION) { | 251 if (crx_location_ == Manifest::INVALID_LOCATION) { |
| 253 LOG(WARNING) << "This provider does not support installing external " | 252 LOG(WARNING) << "This provider does not support installing external " |
| 254 << "extensions from crx files."; | 253 << "extensions from crx files."; |
| 255 continue; | 254 continue; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 VLOG(1) << "Skip installing (or uninstall) external extension: " | 385 VLOG(1) << "Skip installing (or uninstall) external extension: " |
| 387 << extension_id | 386 << extension_id |
| 388 << " profile.created_by_version: " << profile_version.GetString() | 387 << " profile.created_by_version: " << profile_version.GetString() |
| 389 << " min_profile_created_by_version: " | 388 << " min_profile_created_by_version: " |
| 390 << min_profile_created_by_version; | 389 << min_profile_created_by_version; |
| 391 return false; | 390 return false; |
| 392 } | 391 } |
| 393 } | 392 } |
| 394 return true; | 393 return true; |
| 395 } | 394 } |
| 396 | |
| 397 bool ExternalProviderImpl::HandleInstalledByOem( | |
| 398 const base::DictionaryValue* extension, | |
| 399 const std::string& extension_id, | |
| 400 std::set<std::string>* unsupported_extensions, | |
| 401 int* creation_flags) { | |
| 402 bool was_installed_by_oem = false; | |
| 403 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && | |
| 404 was_installed_by_oem) { | |
| 405 #if defined(OS_CHROMEOS) | |
| 406 policy::UserCloudPolicyManagerChromeOS* policy_manager = | |
| 407 policy::UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile_); | |
| 408 if (policy_manager && policy_manager->core()->store()->is_managed()) { | |
| 409 unsupported_extensions->insert(extension_id); | |
| 410 VLOG(1) << "Skip installing (or uninstall) external extension " | |
| 411 << extension_id << " installed by OEM for managed user"; | |
| 412 return false; | |
| 413 } | |
| 414 #endif | |
| 415 *creation_flags |= Extension::WAS_INSTALLED_BY_OEM; | |
| 416 } | |
| 417 return true; | |
| 418 } | |
| 419 | 395 |
| 420 // static | 396 // static |
| 421 void ExternalProviderImpl::CreateExternalProviders( | 397 void ExternalProviderImpl::CreateExternalProviders( |
| 422 VisitorInterface* service, | 398 VisitorInterface* service, |
| 423 Profile* profile, | 399 Profile* profile, |
| 424 ProviderCollection* provider_list) { | 400 ProviderCollection* provider_list) { |
| 425 TRACE_EVENT0("browser,startup", | 401 TRACE_EVENT0("browser,startup", |
| 426 "ExternalProviderImpl::CreateExternalProviders"); | 402 "ExternalProviderImpl::CreateExternalProviders"); |
| 427 scoped_refptr<ExternalLoader> external_loader; | 403 scoped_refptr<ExternalLoader> external_loader; |
| 428 scoped_refptr<ExternalLoader> external_recommended_loader; | 404 scoped_refptr<ExternalLoader> external_recommended_loader; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 new ExternalProviderImpl( | 617 new ExternalProviderImpl( |
| 642 service, | 618 service, |
| 643 new ExternalComponentLoader(profile), | 619 new ExternalComponentLoader(profile), |
| 644 profile, | 620 profile, |
| 645 Manifest::INVALID_LOCATION, | 621 Manifest::INVALID_LOCATION, |
| 646 Manifest::EXTERNAL_COMPONENT, | 622 Manifest::EXTERNAL_COMPONENT, |
| 647 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 623 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
| 648 } | 624 } |
| 649 | 625 |
| 650 } // namespace extensions | 626 } // namespace extensions |
| OLD | NEW |