Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/extensions/external_provider_impl.cc

Issue 2294653002: Some linked_ptr -> unique_ptr conversion in extensions/browser. (Closed)
Patch Set: nullptr Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/linked_ptr.h"
16 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
17 #include "base/stl_util.h" 16 #include "base/stl_util.h"
18 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
19 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
20 #include "base/values.h" 19 #include "base/values.h"
21 #include "base/version.h" 20 #include "base/version.h"
22 #include "build/build_config.h" 21 #include "build/build_config.h"
23 #include "chrome/browser/app_mode/app_mode_utils.h" 22 #include "chrome/browser/app_mode/app_mode_utils.h"
24 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_process_platform_part.h" 24 #include "chrome/browser/browser_process_platform_part.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 ExtensionManagementFactory::GetForBrowserContext(profile), 523 ExtensionManagementFactory::GetForBrowserContext(profile),
525 ExternalPolicyLoader::FORCED); 524 ExternalPolicyLoader::FORCED);
526 external_recommended_loader = new ExternalPolicyLoader( 525 external_recommended_loader = new ExternalPolicyLoader(
527 ExtensionManagementFactory::GetForBrowserContext(profile), 526 ExtensionManagementFactory::GetForBrowserContext(profile),
528 ExternalPolicyLoader::RECOMMENDED); 527 ExternalPolicyLoader::RECOMMENDED);
529 #endif 528 #endif
530 529
531 // Policies are mandatory so they can't be skipped with command line flag. 530 // Policies are mandatory so they can't be skipped with command line flag.
532 if (external_loader.get()) { 531 if (external_loader.get()) {
533 provider_list->push_back( 532 provider_list->push_back(
534 linked_ptr<ExternalProviderInterface>( 533 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
Devlin 2016/08/30 19:21:53 prefer base::MakeUnique
lazyboy 2016/08/30 20:30:56 Done.
535 new ExternalProviderImpl( 534 service, external_loader, profile, crx_location,
536 service, 535 Manifest::EXTERNAL_POLICY_DOWNLOAD, Extension::NO_FLAGS)));
537 external_loader,
538 profile,
539 crx_location,
540 Manifest::EXTERNAL_POLICY_DOWNLOAD,
541 Extension::NO_FLAGS)));
542 } 536 }
543 537
544 // Load the KioskAppExternalProvider when running in kiosk mode. 538 // Load the KioskAppExternalProvider when running in kiosk mode.
545 if (chrome::IsRunningInForcedAppMode()) { 539 if (chrome::IsRunningInForcedAppMode()) {
546 #if defined(OS_CHROMEOS) 540 #if defined(OS_CHROMEOS)
547 chromeos::KioskAppManager* kiosk_app_manager = 541 chromeos::KioskAppManager* kiosk_app_manager =
548 chromeos::KioskAppManager::Get(); 542 chromeos::KioskAppManager::Get();
549 CHECK(kiosk_app_manager); 543 CHECK(kiosk_app_manager);
550 544
551 // Kiosk primary app external provider. 545 // Kiosk primary app external provider.
552 if (!kiosk_app_manager->external_loader_created()) { 546 if (!kiosk_app_manager->external_loader_created()) {
553 // For enterprise managed kiosk apps, change the location to 547 // For enterprise managed kiosk apps, change the location to
554 // "force-installed by policy". 548 // "force-installed by policy".
555 policy::BrowserPolicyConnectorChromeOS* const connector = 549 policy::BrowserPolicyConnectorChromeOS* const connector =
556 g_browser_process->platform_part() 550 g_browser_process->platform_part()
557 ->browser_policy_connector_chromeos(); 551 ->browser_policy_connector_chromeos();
558 Manifest::Location location = Manifest::EXTERNAL_PREF; 552 Manifest::Location location = Manifest::EXTERNAL_PREF;
559 if (connector && connector->IsEnterpriseManaged()) 553 if (connector && connector->IsEnterpriseManaged())
560 location = Manifest::EXTERNAL_POLICY; 554 location = Manifest::EXTERNAL_POLICY;
561 555
562 std::unique_ptr<ExternalProviderImpl> kiosk_app_provider( 556 std::unique_ptr<ExternalProviderImpl> kiosk_app_provider(
563 new ExternalProviderImpl( 557 new ExternalProviderImpl(
564 service, kiosk_app_manager->CreateExternalLoader(), profile, 558 service, kiosk_app_manager->CreateExternalLoader(), profile,
565 location, Manifest::INVALID_LOCATION, Extension::NO_FLAGS)); 559 location, Manifest::INVALID_LOCATION, Extension::NO_FLAGS));
566 kiosk_app_provider->set_auto_acknowledge(true); 560 kiosk_app_provider->set_auto_acknowledge(true);
567 kiosk_app_provider->set_install_immediately(true); 561 kiosk_app_provider->set_install_immediately(true);
568 provider_list->push_back( 562 provider_list->push_back(std::move(kiosk_app_provider));
569 linked_ptr<ExternalProviderInterface>(kiosk_app_provider.release()));
570 } 563 }
571 564
572 // Kiosk secondary app external provider. 565 // Kiosk secondary app external provider.
573 if (!kiosk_app_manager->secondary_app_external_loader_created()) { 566 if (!kiosk_app_manager->secondary_app_external_loader_created()) {
574 std::unique_ptr<ExternalProviderImpl> secondary_kiosk_app_provider( 567 std::unique_ptr<ExternalProviderImpl> secondary_kiosk_app_provider(
575 new ExternalProviderImpl( 568 new ExternalProviderImpl(
576 service, kiosk_app_manager->CreateSecondaryAppExternalLoader(), 569 service, kiosk_app_manager->CreateSecondaryAppExternalLoader(),
577 profile, Manifest::EXTERNAL_PREF, 570 profile, Manifest::EXTERNAL_PREF,
578 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS)); 571 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS));
579 secondary_kiosk_app_provider->set_auto_acknowledge(true); 572 secondary_kiosk_app_provider->set_auto_acknowledge(true);
580 secondary_kiosk_app_provider->set_install_immediately(true); 573 secondary_kiosk_app_provider->set_install_immediately(true);
581 provider_list->push_back(linked_ptr<ExternalProviderInterface>( 574 provider_list->push_back(std::move(secondary_kiosk_app_provider));
582 secondary_kiosk_app_provider.release()));
583 } 575 }
584 #endif 576 #endif
585 return; 577 return;
586 } 578 }
587 579
588 // Extensions provided by recommended policies. 580 // Extensions provided by recommended policies.
589 if (external_recommended_loader.get()) { 581 if (external_recommended_loader.get()) {
590 provider_list->push_back(linked_ptr<ExternalProviderInterface>( 582 provider_list->push_back(
591 new ExternalProviderImpl(service, 583 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
Devlin 2016/08/30 19:21:53 ditto
lazyboy 2016/08/30 20:30:56 Done.
592 external_recommended_loader, 584 service, external_recommended_loader, profile, crx_location,
593 profile, 585 Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS)));
594 crx_location,
595 Manifest::EXTERNAL_PREF_DOWNLOAD,
596 Extension::NO_FLAGS)));
597 } 586 }
598 587
599 // In tests don't install extensions from default external sources. 588 // In tests don't install extensions from default external sources.
600 // It would only slowdown tests and make them flaky. 589 // It would only slowdown tests and make them flaky.
601 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 590 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
602 switches::kDisableDefaultApps)) 591 switches::kDisableDefaultApps))
603 return; 592 return;
604 593
605 // On Mac OS, items in /Library/... should be written by the superuser. 594 // On Mac OS, items in /Library/... should be written by the superuser.
606 // Check that all components of the path are writable by root only. 595 // Check that all components of the path are writable by root only.
(...skipping 14 matching lines...) Expand all
621 610
622 if (!is_chrome_os_public_session) { 611 if (!is_chrome_os_public_session) {
623 int external_apps_path_id = profile->IsSupervised() ? 612 int external_apps_path_id = profile->IsSupervised() ?
624 chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS : 613 chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS :
625 chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS; 614 chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS;
626 ExternalPrefLoader::Options pref_load_flags = 615 ExternalPrefLoader::Options pref_load_flags =
627 profile->IsNewProfile() 616 profile->IsNewProfile()
628 ? ExternalPrefLoader::DELAY_LOAD_UNTIL_PRIORITY_SYNC 617 ? ExternalPrefLoader::DELAY_LOAD_UNTIL_PRIORITY_SYNC
629 : ExternalPrefLoader::NONE; 618 : ExternalPrefLoader::NONE;
630 provider_list->push_back( 619 provider_list->push_back(
631 linked_ptr<ExternalProviderInterface>(new ExternalProviderImpl( 620 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
Devlin 2016/08/30 19:21:53 ditto (and for the rest of this file)
lazyboy 2016/08/30 20:30:56 Done.
632 service, new ExternalPrefLoader(external_apps_path_id, 621 service, new ExternalPrefLoader(external_apps_path_id,
633 pref_load_flags, profile), 622 pref_load_flags, profile),
634 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD, 623 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
635 bundled_extension_creation_flags))); 624 bundled_extension_creation_flags)));
636 625
637 // OEM default apps. 626 // OEM default apps.
638 int oem_extension_creation_flags = 627 int oem_extension_creation_flags =
639 bundled_extension_creation_flags | Extension::WAS_INSTALLED_BY_OEM; 628 bundled_extension_creation_flags | Extension::WAS_INSTALLED_BY_OEM;
640 chromeos::ServicesCustomizationDocument* customization = 629 chromeos::ServicesCustomizationDocument* customization =
641 chromeos::ServicesCustomizationDocument::GetInstance(); 630 chromeos::ServicesCustomizationDocument::GetInstance();
642 provider_list->push_back(linked_ptr<ExternalProviderInterface>( 631 provider_list->push_back(
643 new ExternalProviderImpl(service, 632 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
644 customization->CreateExternalLoader(profile), 633 service, customization->CreateExternalLoader(profile), profile,
645 profile, 634 Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
646 Manifest::EXTERNAL_PREF, 635 oem_extension_creation_flags)));
647 Manifest::EXTERNAL_PREF_DOWNLOAD,
648 oem_extension_creation_flags)));
649 } 636 }
650 #elif defined(OS_LINUX) 637 #elif defined(OS_LINUX)
651 if (!profile->IsLegacySupervised()) { 638 if (!profile->IsLegacySupervised()) {
652 provider_list->push_back( 639 provider_list->push_back(
653 linked_ptr<ExternalProviderInterface>( 640 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
654 new ExternalProviderImpl( 641 service,
655 service, 642 new ExternalPrefLoader(chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS,
656 new ExternalPrefLoader( 643 ExternalPrefLoader::NONE, nullptr),
657 chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS, 644 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
658 ExternalPrefLoader::NONE, 645 bundled_extension_creation_flags)));
659 NULL),
660 profile,
661 Manifest::EXTERNAL_PREF,
662 Manifest::EXTERNAL_PREF_DOWNLOAD,
663 bundled_extension_creation_flags)));
664 } 646 }
665 #endif 647 #endif
666 648
667 if (!profile->IsLegacySupervised()) { 649 if (!profile->IsLegacySupervised()) {
668 #if defined(OS_WIN) 650 #if defined(OS_WIN)
669 provider_list->push_back( 651 provider_list->push_back(
670 linked_ptr<ExternalProviderInterface>( 652 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
671 new ExternalProviderImpl( 653 service, new ExternalRegistryLoader, profile,
672 service, 654 Manifest::EXTERNAL_REGISTRY, Manifest::EXTERNAL_PREF_DOWNLOAD,
673 new ExternalRegistryLoader, 655 Extension::NO_FLAGS)));
674 profile,
675 Manifest::EXTERNAL_REGISTRY,
676 Manifest::EXTERNAL_PREF_DOWNLOAD,
677 Extension::NO_FLAGS)));
678 #else 656 #else
679 provider_list->push_back( 657 provider_list->push_back(
680 linked_ptr<ExternalProviderInterface>( 658 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
681 new ExternalProviderImpl( 659 service,
682 service, 660 new ExternalPrefLoader(chrome::DIR_EXTERNAL_EXTENSIONS,
683 new ExternalPrefLoader(chrome::DIR_EXTERNAL_EXTENSIONS, 661 check_admin_permissions_on_mac, nullptr),
684 check_admin_permissions_on_mac, 662 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
685 NULL), 663 bundled_extension_creation_flags)));
686 profile,
687 Manifest::EXTERNAL_PREF,
688 Manifest::EXTERNAL_PREF_DOWNLOAD,
689 bundled_extension_creation_flags)));
690 664
691 // Define a per-user source of external extensions. 665 // Define a per-user source of external extensions.
692 #if defined(OS_MACOSX) || (defined(OS_LINUX) && defined(CHROMIUM_BUILD)) 666 #if defined(OS_MACOSX) || (defined(OS_LINUX) && defined(CHROMIUM_BUILD))
693 provider_list->push_back( 667 provider_list->push_back(
694 linked_ptr<ExternalProviderInterface>( 668 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
695 new ExternalProviderImpl( 669 service,
696 service, 670 new ExternalPrefLoader(chrome::DIR_USER_EXTERNAL_EXTENSIONS,
697 new ExternalPrefLoader(chrome::DIR_USER_EXTERNAL_EXTENSIONS, 671 ExternalPrefLoader::NONE, nullptr),
698 ExternalPrefLoader::NONE, 672 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
699 NULL), 673 Extension::NO_FLAGS)));
700 profile,
701 Manifest::EXTERNAL_PREF,
702 Manifest::EXTERNAL_PREF_DOWNLOAD,
703 Extension::NO_FLAGS)));
704 #endif 674 #endif
705 #endif 675 #endif
706 676
707 #if !defined(OS_CHROMEOS) 677 #if !defined(OS_CHROMEOS)
708 // The default apps are installed as INTERNAL but use the external 678 // The default apps are installed as INTERNAL but use the external
709 // extension installer codeflow. 679 // extension installer codeflow.
710 provider_list->push_back( 680 provider_list->push_back(
711 linked_ptr<ExternalProviderInterface>( 681 std::unique_ptr<ExternalProviderInterface>(new default_apps::Provider(
712 new default_apps::Provider( 682 profile, service,
713 profile, 683 new ExternalPrefLoader(chrome::DIR_DEFAULT_APPS,
714 service, 684 ExternalPrefLoader::NONE, nullptr),
715 new ExternalPrefLoader(chrome::DIR_DEFAULT_APPS, 685 Manifest::INTERNAL, Manifest::INTERNAL,
716 ExternalPrefLoader::NONE, 686 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
717 NULL),
718 Manifest::INTERNAL,
719 Manifest::INTERNAL,
720 Extension::FROM_WEBSTORE |
721 Extension::WAS_INSTALLED_BY_DEFAULT)));
722 #endif 687 #endif
723 688
724 std::unique_ptr<ExternalProviderImpl> drive_migration_provider( 689 std::unique_ptr<ExternalProviderImpl> drive_migration_provider(
725 new ExternalProviderImpl( 690 new ExternalProviderImpl(
726 service, 691 service,
727 new ExtensionMigrator(profile, extension_misc::kDriveHostedAppId, 692 new ExtensionMigrator(profile, extension_misc::kDriveHostedAppId,
728 extension_misc::kDriveExtensionId), 693 extension_misc::kDriveExtensionId),
729 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD, 694 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
730 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)); 695 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT));
731 drive_migration_provider->set_auto_acknowledge(true); 696 drive_migration_provider->set_auto_acknowledge(true);
732 provider_list->push_back(linked_ptr<ExternalProviderInterface>( 697 provider_list->push_back(std::move(drive_migration_provider));
733 drive_migration_provider.release()));
734 } 698 }
735 699
736 provider_list->push_back( 700 provider_list->push_back(
737 linked_ptr<ExternalProviderInterface>( 701 std::unique_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
738 new ExternalProviderImpl( 702 service, new ExternalComponentLoader(profile), profile,
739 service, 703 Manifest::INVALID_LOCATION, Manifest::EXTERNAL_COMPONENT,
740 new ExternalComponentLoader(profile),
741 profile,
742 Manifest::INVALID_LOCATION,
743 Manifest::EXTERNAL_COMPONENT,
744 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 704 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
745 } 705 }
746 706
747 } // namespace extensions 707 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698