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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 #include "chrome/browser/speech/tts_controller.h" | 78 #include "chrome/browser/speech/tts_controller.h" |
79 #include "chrome/browser/speech/tts_message_filter.h" | 79 #include "chrome/browser/speech/tts_message_filter.h" |
80 #include "chrome/browser/ssl/ssl_blocking_page.h" | 80 #include "chrome/browser/ssl/ssl_blocking_page.h" |
81 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 81 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
82 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" | 82 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" |
83 #include "chrome/browser/ssl/ssl_error_handler.h" | 83 #include "chrome/browser/ssl/ssl_error_handler.h" |
84 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 84 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
85 #include "chrome/browser/tab_contents/tab_util.h" | 85 #include "chrome/browser/tab_contents/tab_util.h" |
86 #include "chrome/browser/tracing/chrome_tracing_delegate.h" | 86 #include "chrome/browser/tracing/chrome_tracing_delegate.h" |
87 #include "chrome/browser/translate/chrome_translate_client.h" | 87 #include "chrome/browser/translate/chrome_translate_client.h" |
88 #include "chrome/browser/ui/ash/ash_util.h" | |
88 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" | 89 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
89 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 90 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
90 #include "chrome/browser/ui/browser_navigator.h" | 91 #include "chrome/browser/ui/browser_navigator.h" |
91 #include "chrome/browser/ui/browser_navigator_params.h" | 92 #include "chrome/browser/ui/browser_navigator_params.h" |
92 #include "chrome/browser/ui/chrome_select_file_policy.h" | 93 #include "chrome/browser/ui/chrome_select_file_policy.h" |
93 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 94 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
94 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 95 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
95 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 96 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
96 #include "chrome/browser/ui/webui/log_web_ui_url.h" | 97 #include "chrome/browser/ui/webui/log_web_ui_url.h" |
97 #include "chrome/browser/usb/usb_tab_helper.h" | 98 #include "chrome/browser/usb/usb_tab_helper.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 #include "sandbox/win/src/sandbox_policy.h" | 216 #include "sandbox/win/src/sandbox_policy.h" |
216 #elif defined(OS_MACOSX) | 217 #elif defined(OS_MACOSX) |
217 #include "chrome/browser/chrome_browser_main_mac.h" | 218 #include "chrome/browser/chrome_browser_main_mac.h" |
218 #elif defined(OS_CHROMEOS) | 219 #elif defined(OS_CHROMEOS) |
219 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 220 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
220 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_de legate.h" | 221 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_de legate.h" |
221 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_del egate.h" | 222 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_del egate.h" |
222 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" | 223 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" |
223 #include "chrome/browser/chromeos/attestation/platform_verification_impl.h" | 224 #include "chrome/browser/chromeos/attestation/platform_verification_impl.h" |
224 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 225 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
225 #include "chrome/browser/chromeos/chrome_interface_factory.h" | |
226 #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h" | 226 #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h" |
227 #include "chrome/browser/chromeos/file_manager/app_id.h" | 227 #include "chrome/browser/chromeos/file_manager/app_id.h" |
228 #include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate. h" | 228 #include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate. h" |
229 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 229 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
230 #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" | 230 #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" |
231 #include "chrome/browser/chromeos/login/signin/merge_session_navigation_throttle .h" | 231 #include "chrome/browser/chromeos/login/signin/merge_session_navigation_throttle .h" |
232 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" | 232 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
233 #include "chrome/browser/chromeos/login/startup_utils.h" | 233 #include "chrome/browser/chromeos/login/startup_utils.h" |
234 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 234 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
235 #include "chrome/browser/chromeos/system/input_device_settings.h" | 235 #include "chrome/browser/chromeos/system/input_device_settings.h" |
236 #include "chrome/browser/profiles/profile_manager.h" | |
236 #include "chrome/browser/ui/ash/ash_util.h" | 237 #include "chrome/browser/ui/ash/ash_util.h" |
238 #include "chrome/browser/ui/browser_commands.h" | |
237 #include "chrome/browser/ui/browser_dialogs.h" | 239 #include "chrome/browser/ui/browser_dialogs.h" |
240 #include "chrome/browser/ui/browser_finder.h" | |
238 #include "chromeos/chromeos_switches.h" | 241 #include "chromeos/chromeos_switches.h" |
239 #include "components/user_manager/user_manager.h" | 242 #include "components/user_manager/user_manager.h" |
243 #include "mash/public/interfaces/launchable.mojom.h" | |
244 #include "services/service_manager/public/cpp/interface_factory.h" | |
245 #include "services/service_manager/public/interfaces/interface_provider_spec.moj om.h" | |
240 #elif defined(OS_LINUX) | 246 #elif defined(OS_LINUX) |
241 #include "chrome/browser/chrome_browser_main_linux.h" | 247 #include "chrome/browser/chrome_browser_main_linux.h" |
242 #elif defined(OS_ANDROID) | 248 #elif defined(OS_ANDROID) |
243 #include "chrome/browser/chrome_browser_main_android.h" | 249 #include "chrome/browser/chrome_browser_main_android.h" |
244 #include "chrome/common/descriptors_android.h" | 250 #include "chrome/common/descriptors_android.h" |
245 #include "components/crash/content/browser/crash_dump_manager_android.h" | 251 #include "components/crash/content/browser/crash_dump_manager_android.h" |
246 #include "components/navigation_interception/intercept_navigation_delegate.h" | 252 #include "components/navigation_interception/intercept_navigation_delegate.h" |
247 #include "ui/base/resource/resource_bundle_android.h" | 253 #include "ui/base/resource/resource_bundle_android.h" |
248 #elif defined(OS_POSIX) | 254 #elif defined(OS_POSIX) |
249 #include "chrome/browser/chrome_browser_main_posix.h" | 255 #include "chrome/browser/chrome_browser_main_posix.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084 | 461 "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084 |
456 }; | 462 }; |
457 #endif | 463 #endif |
458 | 464 |
459 enum AppLoadedInTabSource { | 465 enum AppLoadedInTabSource { |
460 APP_LOADED_IN_TAB_SOURCE_APP = 0, | 466 APP_LOADED_IN_TAB_SOURCE_APP = 0, |
461 APP_LOADED_IN_TAB_SOURCE_BACKGROUND_PAGE, | 467 APP_LOADED_IN_TAB_SOURCE_BACKGROUND_PAGE, |
462 APP_LOADED_IN_TAB_SOURCE_MAX | 468 APP_LOADED_IN_TAB_SOURCE_MAX |
463 }; | 469 }; |
464 | 470 |
471 #if defined(OS_CHROMEOS) | |
472 | |
473 const char kChromeServiceName[] = "chrome"; | |
sky
2017/02/15 00:35:26
Add description.
Ken Rockot(use gerrit already)
2017/02/15 01:38:05
Done
| |
474 | |
475 class ChromeService | |
sky
2017/02/15 00:35:26
Please add description, also, I would be inclined
Ken Rockot(use gerrit already)
2017/02/15 01:38:05
Done
| |
476 : public service_manager::Service, | |
477 public mash::mojom::Launchable, | |
478 public service_manager::InterfaceFactory<mash::mojom::Launchable> { | |
479 public: | |
480 ChromeService() | |
481 : interfaces_(service_manager::mojom::kServiceManager_ConnectorSpec) { | |
482 interfaces_.AddInterface<mash::mojom::Launchable>(this); | |
483 } | |
484 ~ChromeService() override {} | |
485 | |
486 static std::unique_ptr<service_manager::Service> CreateService() { | |
487 return base::MakeUnique<ChromeService>(); | |
488 } | |
489 | |
490 private: | |
491 void CreateNewWindowImpl(bool is_incognito) { | |
492 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
493 chrome::NewEmptyWindow(is_incognito ? profile->GetOffTheRecordProfile() | |
494 : profile); | |
495 } | |
496 | |
497 // service_manager::Service: | |
498 void OnBindInterface(const service_manager::ServiceInfo& remote_info, | |
499 const std::string& name, | |
500 mojo::ScopedMessagePipeHandle handle) override { | |
501 interfaces_.BindInterface(name, std::move(handle)); | |
502 } | |
503 | |
504 // mash::mojom::Launchable: | |
505 void Launch(uint32_t what, mash::mojom::LaunchMode how) override { | |
506 if (how != mash::mojom::LaunchMode::MAKE_NEW) { | |
507 LOG(ERROR) << "Unable to handle Launch request with how = " << how; | |
508 return; | |
509 } | |
510 switch (what) { | |
511 case mash::mojom::kWindow: | |
512 CreateNewWindowImpl(false /* is_incognito */); | |
513 break; | |
514 case mash::mojom::kIncognitoWindow: | |
515 CreateNewWindowImpl(true /* is_incognito */); | |
516 break; | |
517 default: | |
518 NOTREACHED(); | |
519 } | |
520 } | |
521 | |
522 // mojo::InterfaceFactory<mash::mojom::Launchable>: | |
523 void Create(const service_manager::Identity& remote_identity, | |
524 mash::mojom::LaunchableRequest request) override { | |
525 bindings_.AddBinding(this, std::move(request)); | |
526 } | |
527 | |
528 service_manager::InterfaceRegistry interfaces_; | |
529 mojo::BindingSet<mash::mojom::Launchable> bindings_; | |
530 | |
531 DISALLOW_COPY_AND_ASSIGN(ChromeService); | |
532 }; | |
533 | |
534 #endif // defined(OS_CHROMEOS) | |
535 | |
465 // Returns a copy of the given url with its host set to given host and path set | 536 // Returns a copy of the given url with its host set to given host and path set |
466 // to given path. Other parts of the url will be the same. | 537 // to given path. Other parts of the url will be the same. |
467 GURL ReplaceURLHostAndPath(const GURL& url, | 538 GURL ReplaceURLHostAndPath(const GURL& url, |
468 const std::string& host, | 539 const std::string& host, |
469 const std::string& path) { | 540 const std::string& path) { |
470 url::Replacements<char> replacements; | 541 url::Replacements<char> replacements; |
471 replacements.SetHost(host.c_str(), url::Component(0, host.length())); | 542 replacements.SetHost(host.c_str(), url::Component(0, host.length())); |
472 replacements.SetPath(path.c_str(), url::Component(0, path.length())); | 543 replacements.SetPath(path.c_str(), url::Component(0, path.length())); |
473 return url.ReplaceComponents(replacements); | 544 return url.ReplaceComponents(replacements); |
474 } | 545 } |
(...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3100 } | 3171 } |
3101 | 3172 |
3102 void ChromeContentBrowserClient::RegisterInProcessServices( | 3173 void ChromeContentBrowserClient::RegisterInProcessServices( |
3103 StaticServiceMap* services) { | 3174 StaticServiceMap* services) { |
3104 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | 3175 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
3105 content::ServiceInfo info; | 3176 content::ServiceInfo info; |
3106 info.factory = base::Bind(&media::CreateMediaService); | 3177 info.factory = base::Bind(&media::CreateMediaService); |
3107 services->insert(std::make_pair("media", info)); | 3178 services->insert(std::make_pair("media", info)); |
3108 #endif | 3179 #endif |
3109 #if defined(OS_CHROMEOS) | 3180 #if defined(OS_CHROMEOS) |
3110 content::ServiceManagerConnection::GetForProcess()->AddConnectionFilter( | 3181 { |
3111 base::MakeUnique<chromeos::ChromeInterfaceFactory>()); | 3182 content::ServiceInfo info; |
3183 info.factory = base::Bind(&ChromeService::CreateService); | |
3184 info.task_runner = base::ThreadTaskRunnerHandle::Get(); | |
3185 services->insert(std::make_pair(kChromeServiceName, info)); | |
3186 } | |
3187 | |
3112 { | 3188 { |
3113 content::ServiceInfo info; | 3189 content::ServiceInfo info; |
3114 info.factory = base::Bind([] { | 3190 info.factory = base::Bind([] { |
3115 return std::unique_ptr<service_manager::Service>( | 3191 return std::unique_ptr<service_manager::Service>( |
3116 base::MakeUnique<PreferencesConnectionManager>()); | 3192 base::MakeUnique<PreferencesConnectionManager>()); |
3117 }); | 3193 }); |
3194 info.task_runner = base::ThreadTaskRunnerHandle::Get(); | |
3118 services->insert(std::make_pair(prefs::mojom::kServiceName, info)); | 3195 services->insert(std::make_pair(prefs::mojom::kServiceName, info)); |
3119 } | 3196 } |
3197 | |
3198 if (!chrome::IsRunningInMash()) { | |
3199 content::ServiceInfo info; | |
3200 info.factory = base::Bind(&ash_util::CreateEmbeddedAshService, | |
3201 base::ThreadTaskRunnerHandle::Get()); | |
3202 services->insert(std::make_pair("ash", info)); | |
3203 } | |
3120 #endif // OS_CHROMEOS | 3204 #endif // OS_CHROMEOS |
3121 } | 3205 } |
3122 | 3206 |
3123 void ChromeContentBrowserClient::RegisterOutOfProcessServices( | 3207 void ChromeContentBrowserClient::RegisterOutOfProcessServices( |
3124 OutOfProcessServiceMap* services) { | 3208 OutOfProcessServiceMap* services) { |
3125 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 3209 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
3126 services->insert(std::make_pair("media", | 3210 services->insert(std::make_pair("media", |
3127 base::ASCIIToUTF16("Media Service"))); | 3211 base::ASCIIToUTF16("Media Service"))); |
3128 #endif | 3212 #endif |
3129 services->insert(std::make_pair(image_decoder::mojom::kServiceName, | 3213 services->insert(std::make_pair(image_decoder::mojom::kServiceName, |
3130 base::ASCIIToUTF16("Image Decoder Service"))); | 3214 base::ASCIIToUTF16("Image Decoder Service"))); |
3131 } | 3215 } |
3132 | 3216 |
3133 std::unique_ptr<base::Value> | 3217 std::unique_ptr<base::Value> |
3134 ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { | 3218 ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { |
3135 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 3219 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
3136 int id = -1; | 3220 int id = -1; |
3137 if (name == content::mojom::kBrowserServiceName) | 3221 if (name == content::mojom::kBrowserServiceName) |
3138 id = IDR_CHROME_CONTENT_BROWSER_MANIFEST_OVERLAY; | 3222 id = IDR_CHROME_CONTENT_BROWSER_MANIFEST_OVERLAY; |
3139 else if (name == content::mojom::kGpuServiceName) | 3223 else if (name == content::mojom::kGpuServiceName) |
3140 id = IDR_CHROME_CONTENT_GPU_MANIFEST_OVERLAY; | 3224 id = IDR_CHROME_CONTENT_GPU_MANIFEST_OVERLAY; |
3225 else if (name == content::mojom::kPackagedServicesServiceName) | |
3226 id = IDR_CHROME_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY; | |
3141 else if (name == content::mojom::kPluginServiceName) | 3227 else if (name == content::mojom::kPluginServiceName) |
3142 id = IDR_CHROME_CONTENT_PLUGIN_MANIFEST_OVERLAY; | 3228 id = IDR_CHROME_CONTENT_PLUGIN_MANIFEST_OVERLAY; |
3143 else if (name == content::mojom::kRendererServiceName) | 3229 else if (name == content::mojom::kRendererServiceName) |
3144 id = IDR_CHROME_CONTENT_RENDERER_MANIFEST_OVERLAY; | 3230 id = IDR_CHROME_CONTENT_RENDERER_MANIFEST_OVERLAY; |
3145 else if (name == content::mojom::kUtilityServiceName) | 3231 else if (name == content::mojom::kUtilityServiceName) |
3146 id = IDR_CHROME_CONTENT_UTILITY_MANIFEST_OVERLAY; | 3232 id = IDR_CHROME_CONTENT_UTILITY_MANIFEST_OVERLAY; |
3147 if (id == -1) | 3233 if (id == -1) |
3148 return nullptr; | 3234 return nullptr; |
3149 | 3235 |
3150 base::StringPiece manifest_contents = | 3236 base::StringPiece manifest_contents = |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3434 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3520 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
3435 return variations::GetVariationParamValue( | 3521 return variations::GetVariationParamValue( |
3436 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3522 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
3437 } | 3523 } |
3438 | 3524 |
3439 // static | 3525 // static |
3440 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( | 3526 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
3441 const storage::QuotaSettings* settings) { | 3527 const storage::QuotaSettings* settings) { |
3442 g_default_quota_settings = settings; | 3528 g_default_quota_settings = settings; |
3443 } | 3529 } |
OLD | NEW |