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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 return true; | 361 return true; |
362 } | 362 } |
363 | 363 |
364 // static | 364 // static |
365 void ExternalProviderImpl::CreateExternalProviders( | 365 void ExternalProviderImpl::CreateExternalProviders( |
366 VisitorInterface* service, | 366 VisitorInterface* service, |
367 Profile* profile, | 367 Profile* profile, |
368 ProviderCollection* provider_list) { | 368 ProviderCollection* provider_list) { |
369 scoped_refptr<ExternalLoader> external_loader; | 369 scoped_refptr<ExternalLoader> external_loader; |
| 370 scoped_refptr<ExternalLoader> external_recommended_loader; |
370 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; | 371 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; |
371 #if defined(OS_CHROMEOS) | 372 #if defined(OS_CHROMEOS) |
372 policy::BrowserPolicyConnectorChromeOS* connector = | 373 policy::BrowserPolicyConnectorChromeOS* connector = |
373 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 374 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
374 bool is_chrome_os_public_session = false; | 375 bool is_chrome_os_public_session = false; |
375 const user_manager::User* user = | 376 const user_manager::User* user = |
376 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 377 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
377 policy::DeviceLocalAccount::Type account_type; | 378 policy::DeviceLocalAccount::Type account_type; |
378 if (user && policy::IsDeviceLocalAccountUser(user->email(), &account_type)) { | 379 if (user && policy::IsDeviceLocalAccountUser(user->email(), &account_type)) { |
379 if (account_type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION) | 380 if (account_type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION) |
380 is_chrome_os_public_session = true; | 381 is_chrome_os_public_session = true; |
381 policy::DeviceLocalAccountPolicyBroker* broker = | 382 policy::DeviceLocalAccountPolicyBroker* broker = |
382 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 383 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
383 user->email()); | 384 user->email()); |
384 if (broker) { | 385 if (broker) { |
385 external_loader = broker->extension_loader(); | 386 external_loader = broker->extension_loader(); |
386 crx_location = Manifest::EXTERNAL_POLICY; | 387 crx_location = Manifest::EXTERNAL_POLICY; |
387 } else { | 388 } else { |
388 NOTREACHED(); | 389 NOTREACHED(); |
389 } | 390 } |
390 } else { | 391 } else { |
391 external_loader = new ExternalPolicyLoader( | 392 external_loader = new ExternalPolicyLoader( |
392 ExtensionManagementFactory::GetForBrowserContext(profile)); | 393 ExtensionManagementFactory::GetForBrowserContext(profile), |
| 394 ExternalPolicyLoader::FORCED); |
| 395 external_recommended_loader = new ExternalPolicyLoader( |
| 396 ExtensionManagementFactory::GetForBrowserContext(profile), |
| 397 ExternalPolicyLoader::RECOMMENDED); |
393 } | 398 } |
394 #else | 399 #else |
395 external_loader = new ExternalPolicyLoader( | 400 external_loader = new ExternalPolicyLoader( |
396 ExtensionManagementFactory::GetForBrowserContext(profile)); | 401 ExtensionManagementFactory::GetForBrowserContext(profile), |
| 402 ExternalPolicyLoader::FORCED); |
| 403 external_recommended_loader = new ExternalPolicyLoader( |
| 404 ExtensionManagementFactory::GetForBrowserContext(profile), |
| 405 ExternalPolicyLoader::RECOMMENDED); |
397 #endif | 406 #endif |
398 | 407 |
399 // Policies are mandatory so they can't be skipped with command line flag. | 408 // Policies are mandatory so they can't be skipped with command line flag. |
400 if (external_loader.get()) { | 409 if (external_loader.get()) { |
401 provider_list->push_back( | 410 provider_list->push_back( |
402 linked_ptr<ExternalProviderInterface>( | 411 linked_ptr<ExternalProviderInterface>( |
403 new ExternalProviderImpl( | 412 new ExternalProviderImpl( |
404 service, | 413 service, |
405 external_loader, | 414 external_loader, |
406 profile, | 415 profile, |
(...skipping 14 matching lines...) Expand all Loading... |
421 kiosk_app_manager->CreateExternalLoader(), | 430 kiosk_app_manager->CreateExternalLoader(), |
422 profile, | 431 profile, |
423 Manifest::EXTERNAL_PREF, | 432 Manifest::EXTERNAL_PREF, |
424 Manifest::INVALID_LOCATION, | 433 Manifest::INVALID_LOCATION, |
425 Extension::NO_FLAGS))); | 434 Extension::NO_FLAGS))); |
426 } | 435 } |
427 #endif | 436 #endif |
428 return; | 437 return; |
429 } | 438 } |
430 | 439 |
| 440 // Extensions provided by recommended policies. |
| 441 if (external_recommended_loader.get()) { |
| 442 provider_list->push_back(linked_ptr<ExternalProviderInterface>( |
| 443 new ExternalProviderImpl(service, |
| 444 external_recommended_loader, |
| 445 profile, |
| 446 crx_location, |
| 447 Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 448 Extension::NO_FLAGS))); |
| 449 } |
| 450 |
431 // In tests don't install extensions from default external sources. | 451 // In tests don't install extensions from default external sources. |
432 // It would only slowdown tests and make them flaky. | 452 // It would only slowdown tests and make them flaky. |
433 if (CommandLine::ForCurrentProcess()->HasSwitch( | 453 if (CommandLine::ForCurrentProcess()->HasSwitch( |
434 switches::kDisableDefaultApps)) | 454 switches::kDisableDefaultApps)) |
435 return; | 455 return; |
436 | 456 |
437 // On Mac OS, items in /Library/... should be written by the superuser. | 457 // On Mac OS, items in /Library/... should be written by the superuser. |
438 // Check that all components of the path are writable by root only. | 458 // Check that all components of the path are writable by root only. |
439 ExternalPrefLoader::Options check_admin_permissions_on_mac; | 459 ExternalPrefLoader::Options check_admin_permissions_on_mac; |
440 #if defined(OS_MACOSX) | 460 #if defined(OS_MACOSX) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 service, | 597 service, |
578 new ExternalComponentLoader(profile), | 598 new ExternalComponentLoader(profile), |
579 profile, | 599 profile, |
580 Manifest::INVALID_LOCATION, | 600 Manifest::INVALID_LOCATION, |
581 Manifest::EXTERNAL_COMPONENT, | 601 Manifest::EXTERNAL_COMPONENT, |
582 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 602 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
583 } | 603 } |
584 } | 604 } |
585 | 605 |
586 } // namespace extensions | 606 } // namespace extensions |
OLD | NEW |