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" |
46 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 48 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
47 #include "components/user_manager/user.h" | 49 #include "components/user_manager/user.h" |
48 #else | 50 #else |
49 #include "chrome/browser/extensions/default_apps.h" | 51 #include "chrome/browser/extensions/default_apps.h" |
50 #endif | 52 #endif |
51 | 53 |
52 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
53 #include "chrome/browser/extensions/external_registry_loader_win.h" | 55 #include "chrome/browser/extensions/external_registry_loader_win.h" |
54 #endif | 56 #endif |
55 | 57 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const Extension* extension = extension_service ? | 224 const Extension* extension = extension_service ? |
223 extension_service->GetExtensionById(extension_id, true) : NULL; | 225 extension_service->GetExtensionById(extension_id, true) : NULL; |
224 if (!extension) { | 226 if (!extension) { |
225 unsupported_extensions.insert(extension_id); | 227 unsupported_extensions.insert(extension_id); |
226 VLOG(1) << "Skip installing (or uninstall) external extension: " | 228 VLOG(1) << "Skip installing (or uninstall) external extension: " |
227 << extension_id << " because the extension should be kept " | 229 << extension_id << " because the extension should be kept " |
228 << "only if it is already installed."; | 230 << "only if it is already installed."; |
229 continue; | 231 continue; |
230 } | 232 } |
231 } | 233 } |
232 bool was_installed_by_oem = false; | 234 if (!HandleInstalledByOem(extension, extension_id, &unsupported_extensions, |
233 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && | 235 &creation_flags)) |
234 was_installed_by_oem) { | 236 continue; |
235 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; | 237 |
236 } | |
237 bool may_be_untrusted = false; | 238 bool may_be_untrusted = false; |
238 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && | 239 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && |
239 may_be_untrusted) { | 240 may_be_untrusted) { |
240 creation_flags |= Extension::MAY_BE_UNTRUSTED; | 241 creation_flags |= Extension::MAY_BE_UNTRUSTED; |
241 } | 242 } |
242 | 243 |
243 if (!ExternalProviderImpl::HandleMinProfileVersion(extension, extension_id, | 244 if (!HandleMinProfileVersion(extension, extension_id, |
244 &unsupported_extensions)) | 245 &unsupported_extensions)) |
245 continue; | 246 continue; |
246 | 247 |
247 std::string install_parameter; | 248 std::string install_parameter; |
248 extension->GetString(kInstallParam, &install_parameter); | 249 extension->GetString(kInstallParam, &install_parameter); |
249 | 250 |
250 if (has_external_crx) { | 251 if (has_external_crx) { |
251 if (crx_location_ == Manifest::INVALID_LOCATION) { | 252 if (crx_location_ == Manifest::INVALID_LOCATION) { |
252 LOG(WARNING) << "This provider does not support installing external " | 253 LOG(WARNING) << "This provider does not support installing external " |
253 << "extensions from crx files."; | 254 << "extensions from crx files."; |
254 continue; | 255 continue; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 << extension_id | 387 << extension_id |
387 << " profile.created_by_version: " << profile_version.GetString() | 388 << " profile.created_by_version: " << profile_version.GetString() |
388 << " min_profile_created_by_version: " | 389 << " min_profile_created_by_version: " |
389 << min_profile_created_by_version; | 390 << min_profile_created_by_version; |
390 return false; | 391 return false; |
391 } | 392 } |
392 } | 393 } |
393 return true; | 394 return true; |
394 } | 395 } |
395 | 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 |
396 // static | 420 // static |
397 void ExternalProviderImpl::CreateExternalProviders( | 421 void ExternalProviderImpl::CreateExternalProviders( |
398 VisitorInterface* service, | 422 VisitorInterface* service, |
399 Profile* profile, | 423 Profile* profile, |
400 ProviderCollection* provider_list) { | 424 ProviderCollection* provider_list) { |
401 TRACE_EVENT0("browser,startup", | 425 TRACE_EVENT0("browser,startup", |
402 "ExternalProviderImpl::CreateExternalProviders"); | 426 "ExternalProviderImpl::CreateExternalProviders"); |
403 scoped_refptr<ExternalLoader> external_loader; | 427 scoped_refptr<ExternalLoader> external_loader; |
404 scoped_refptr<ExternalLoader> external_recommended_loader; | 428 scoped_refptr<ExternalLoader> external_recommended_loader; |
405 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; | 429 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 new ExternalProviderImpl( | 641 new ExternalProviderImpl( |
618 service, | 642 service, |
619 new ExternalComponentLoader(profile), | 643 new ExternalComponentLoader(profile), |
620 profile, | 644 profile, |
621 Manifest::INVALID_LOCATION, | 645 Manifest::INVALID_LOCATION, |
622 Manifest::EXTERNAL_COMPONENT, | 646 Manifest::EXTERNAL_COMPONENT, |
623 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 647 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
624 } | 648 } |
625 | 649 |
626 } // namespace extensions | 650 } // namespace extensions |
OLD | NEW |