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

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

Issue 1740243003: Remove Now v1 component cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/component_loader.h" 5 #include "chrome/browser/extensions/component_loader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
robliao 2016/03/02 22:00:52 Haven't tried it, but a few of these includes may
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/profiler/scoped_profile.h" 15 #include "base/profiler/scoped_profile.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" 19 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h"
20 #include "chrome/browser/extensions/data_deleter.h" 20 #include "chrome/browser/extensions/data_deleter.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/pdf/pdf_extension_util.h" 22 #include "chrome/browser/pdf/pdf_extension_util.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 Add(IDR_IMAGE_LOADER_MANIFEST, 376 Add(IDR_IMAGE_LOADER_MANIFEST,
377 base::FilePath(FILE_PATH_LITERAL("image_loader"))); 377 base::FilePath(FILE_PATH_LITERAL("image_loader")));
378 #endif // defined(IMAGE_LOADER_EXTENSION) 378 #endif // defined(IMAGE_LOADER_EXTENSION)
379 } 379 }
380 380
381 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { 381 void ComponentLoader::AddNetworkSpeechSynthesisExtension() {
382 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, 382 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST,
383 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); 383 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis")));
384 } 384 }
385 385
386 void ComponentLoader::AddGoogleNowExtension() {
387 #if BUILDFLAG(ENABLE_GOOGLE_NOW)
388 const char kEnablePrefix[] = "Enable";
389 const char kFieldTrialName[] = "GoogleNow";
390 std::string enable_prefix(kEnablePrefix);
391 std::string field_trial_result =
392 base::FieldTrialList::FindFullName(kFieldTrialName);
393
394 bool enabled_via_field_trial =
395 field_trial_result.compare(0, enable_prefix.length(), enable_prefix) == 0;
396
397 // Enable the feature on trybots and trunk builds.
398 bool enabled_via_trunk_build =
399 chrome::GetChannel() == version_info::Channel::UNKNOWN;
400
401 bool is_authenticated =
402 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated();
403
404 bool enabled =
405 (enabled_via_field_trial && is_authenticated) || enabled_via_trunk_build;
406
407 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
408 // Don't load if newer trial is running (== new extension id is available).
409 std::string ignored_extension_id;
410 if (GetGoogleNowExtensionId(&ignored_extension_id)) {
411 enabled = false;
412 }
413 #endif // defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
414
415 const int google_now_manifest_id = IDR_GOOGLE_NOW_MANIFEST;
416 const base::FilePath root_directory =
417 base::FilePath(FILE_PATH_LITERAL("google_now"));
418 if (enabled) {
419 Add(google_now_manifest_id, root_directory);
420 } else {
421 DeleteData(google_now_manifest_id, root_directory);
422 }
423 #endif // BUILDFLAG(ENABLE_GOOGLE_NOW)
424 }
425
426 #if defined(OS_CHROMEOS) 386 #if defined(OS_CHROMEOS)
427 void ComponentLoader::AddChromeVoxExtension( 387 void ComponentLoader::AddChromeVoxExtension(
428 const base::Closure& done_cb) { 388 const base::Closure& done_cb) {
429 base::FilePath resources_path; 389 base::FilePath resources_path;
430 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path)); 390 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path));
431 391
432 base::FilePath chromevox_path = 392 base::FilePath chromevox_path =
433 resources_path.Append(extension_misc::kChromeVoxExtensionPath); 393 resources_path.Append(extension_misc::kChromeVoxExtensionPath);
434 394
435 const base::FilePath::CharType* manifest_filename = 395 const base::FilePath::CharType* manifest_filename =
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 AddVideoPlayerExtension(); 586 AddVideoPlayerExtension();
627 AddAudioPlayerExtension(); 587 AddAudioPlayerExtension();
628 AddFileManagerExtension(); 588 AddFileManagerExtension();
629 AddGalleryExtension(); 589 AddGalleryExtension();
630 AddWebstoreWidgetExtension(); 590 AddWebstoreWidgetExtension();
631 591
632 AddHangoutServicesExtension(); 592 AddHangoutServicesExtension();
633 AddHotwordAudioVerificationApp(); 593 AddHotwordAudioVerificationApp();
634 AddHotwordHelperExtension(); 594 AddHotwordHelperExtension();
635 AddImageLoaderExtension(); 595 AddImageLoaderExtension();
636 AddGoogleNowExtension();
637 596
638 bool install_feedback = enable_background_extensions_during_testing; 597 bool install_feedback = enable_background_extensions_during_testing;
639 #if defined(GOOGLE_CHROME_BUILD) 598 #if defined(GOOGLE_CHROME_BUILD)
640 install_feedback = true; 599 install_feedback = true;
641 #endif // defined(GOOGLE_CHROME_BUILD) 600 #endif // defined(GOOGLE_CHROME_BUILD)
642 if (install_feedback) 601 if (install_feedback)
643 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback"))); 602 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback")));
644 603
645 #if defined(ENABLE_SETTINGS_APP) 604 #if defined(ENABLE_SETTINGS_APP)
646 Add(IDR_SETTINGS_APP_MANIFEST, 605 Add(IDR_SETTINGS_APP_MANIFEST,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 (command_line->HasSwitch(switches::kTestType) || 667 (command_line->HasSwitch(switches::kTestType) ||
709 command_line->HasSwitch( 668 command_line->HasSwitch(
710 switches::kDisableComponentExtensionsWithBackgroundPages))) { 669 switches::kDisableComponentExtensionsWithBackgroundPages))) {
711 return; 670 return;
712 } 671 }
713 672
714 AddHangoutServicesExtension(); 673 AddHangoutServicesExtension();
715 } 674 }
716 675
717 void ComponentLoader::DeleteData(int manifest_resource_id, 676 void ComponentLoader::DeleteData(int manifest_resource_id,
718 const base::FilePath& root_directory) { 677 const base::FilePath& root_directory) {
robliao 2016/03/02 22:00:52 Might as well remove this as well.
719 std::string manifest_contents = 678 std::string manifest_contents =
720 ResourceBundle::GetSharedInstance().GetRawDataResource( 679 ResourceBundle::GetSharedInstance().GetRawDataResource(
721 manifest_resource_id).as_string(); 680 manifest_resource_id).as_string();
722 base::DictionaryValue* manifest = ParseManifest(manifest_contents); 681 base::DictionaryValue* manifest = ParseManifest(manifest_contents);
723 if (!manifest) 682 if (!manifest)
724 return; 683 return;
725 684
726 ComponentExtensionInfo info(manifest, root_directory); 685 ComponentExtensionInfo info(manifest, root_directory);
727 std::string error; 686 std::string error;
728 scoped_refptr<const Extension> extension(CreateExtension(info, &error)); 687 scoped_refptr<const Extension> extension(CreateExtension(info, &error));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 manifest.release(), 751 manifest.release(),
793 root_directory, 752 root_directory,
794 false); 753 false);
795 CHECK_EQ(extension_id, actual_extension_id); 754 CHECK_EQ(extension_id, actual_extension_id);
796 if (!done_cb.is_null()) 755 if (!done_cb.is_null())
797 done_cb.Run(); 756 done_cb.Run();
798 } 757 }
799 #endif 758 #endif
800 759
801 } // namespace extensions 760 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698