| 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/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" |
| 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 "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" | 18 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" |
| 19 #include "chrome/browser/extensions/data_deleter.h" | 19 #include "chrome/browser/extensions/data_deleter.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/pdf/pdf_extension_util.h" | 21 #include "chrome/browser/pdf/pdf_extension_util.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/search/hotword_service.h" | 23 #include "chrome/browser/search/hotword_service.h" |
| 24 #include "chrome/browser/search/hotword_service_factory.h" | 24 #include "chrome/browser/search/hotword_service_factory.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/common/channel_info.h" | 26 #include "chrome/common/channel_info.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
| 30 #include "chrome/common/features.h" | |
| 31 #include "chrome/grit/chromium_strings.h" | 30 #include "chrome/grit/chromium_strings.h" |
| 32 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/crx_file/id_util.h" | 32 #include "components/crx_file/id_util.h" |
| 34 #include "components/signin/core/browser/signin_manager.h" | 33 #include "components/signin/core/browser/signin_manager.h" |
| 35 #include "components/signin/core/browser/signin_manager_base.h" | 34 #include "components/signin/core/browser/signin_manager_base.h" |
| 36 #include "components/version_info/version_info.h" | 35 #include "components/version_info/version_info.h" |
| 37 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/plugin_service.h" | 37 #include "content/public/browser/plugin_service.h" |
| 39 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
| 40 #include "extensions/common/constants.h" | 39 #include "extensions/common/constants.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 base::FilePath(FILE_PATH_LITERAL("image_loader"))); | 375 base::FilePath(FILE_PATH_LITERAL("image_loader"))); |
| 377 #endif // defined(IMAGE_LOADER_EXTENSION) | 376 #endif // defined(IMAGE_LOADER_EXTENSION) |
| 378 } | 377 } |
| 379 | 378 |
| 380 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { | 379 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { |
| 381 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, | 380 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, |
| 382 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); | 381 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); |
| 383 } | 382 } |
| 384 | 383 |
| 385 void ComponentLoader::AddGoogleNowExtension() { | 384 void ComponentLoader::AddGoogleNowExtension() { |
| 386 #if BUILDFLAG(ENABLE_GOOGLE_NOW) | 385 #if defined(ENABLE_GOOGLE_NOW) |
| 387 const char kEnablePrefix[] = "Enable"; | 386 const char kEnablePrefix[] = "Enable"; |
| 388 const char kFieldTrialName[] = "GoogleNow"; | 387 const char kFieldTrialName[] = "GoogleNow"; |
| 389 std::string enable_prefix(kEnablePrefix); | 388 std::string enable_prefix(kEnablePrefix); |
| 390 std::string field_trial_result = | 389 std::string field_trial_result = |
| 391 base::FieldTrialList::FindFullName(kFieldTrialName); | 390 base::FieldTrialList::FindFullName(kFieldTrialName); |
| 392 | 391 |
| 393 bool enabled_via_field_trial = | 392 bool enabled_via_field_trial = |
| 394 field_trial_result.compare(0, enable_prefix.length(), enable_prefix) == 0; | 393 field_trial_result.compare(0, enable_prefix.length(), enable_prefix) == 0; |
| 395 | 394 |
| 396 // Enable the feature on trybots and trunk builds. | 395 // Enable the feature on trybots and trunk builds. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 412 #endif // defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) | 411 #endif // defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) |
| 413 | 412 |
| 414 const int google_now_manifest_id = IDR_GOOGLE_NOW_MANIFEST; | 413 const int google_now_manifest_id = IDR_GOOGLE_NOW_MANIFEST; |
| 415 const base::FilePath root_directory = | 414 const base::FilePath root_directory = |
| 416 base::FilePath(FILE_PATH_LITERAL("google_now")); | 415 base::FilePath(FILE_PATH_LITERAL("google_now")); |
| 417 if (enabled) { | 416 if (enabled) { |
| 418 Add(google_now_manifest_id, root_directory); | 417 Add(google_now_manifest_id, root_directory); |
| 419 } else { | 418 } else { |
| 420 DeleteData(google_now_manifest_id, root_directory); | 419 DeleteData(google_now_manifest_id, root_directory); |
| 421 } | 420 } |
| 422 #endif // BUILDFLAG(ENABLE_GOOGLE_NOW) | 421 #endif // defined(ENABLE_GOOGLE_NOW) |
| 423 } | 422 } |
| 424 | 423 |
| 425 #if defined(OS_CHROMEOS) | 424 #if defined(OS_CHROMEOS) |
| 426 void ComponentLoader::AddChromeVoxExtension( | 425 void ComponentLoader::AddChromeVoxExtension( |
| 427 const base::Closure& done_cb) { | 426 const base::Closure& done_cb) { |
| 428 base::FilePath resources_path; | 427 base::FilePath resources_path; |
| 429 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path)); | 428 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path)); |
| 430 | 429 |
| 431 base::FilePath chromevox_path = | 430 base::FilePath chromevox_path = |
| 432 resources_path.Append(extension_misc::kChromeVoxExtensionPath); | 431 resources_path.Append(extension_misc::kChromeVoxExtensionPath); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 manifest.release(), | 765 manifest.release(), |
| 767 root_directory, | 766 root_directory, |
| 768 false); | 767 false); |
| 769 CHECK_EQ(extension_id, actual_extension_id); | 768 CHECK_EQ(extension_id, actual_extension_id); |
| 770 if (!done_cb.is_null()) | 769 if (!done_cb.is_null()) |
| 771 done_cb.Run(); | 770 done_cb.Run(); |
| 772 } | 771 } |
| 773 #endif | 772 #endif |
| 774 | 773 |
| 775 } // namespace extensions | 774 } // namespace extensions |
| OLD | NEW |