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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2695803004: Make browser process a singleton service (Closed)
Patch Set: . Created 3 years, 10 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/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
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
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
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 // The name of the packaged service used to expose miscellaneous application
474 // control features such as the mash Launchable interface.
475 const char kChromeServiceName[] = "chrome";
476
477 // Packaged service implementation used to expose miscellaneous application
478 // control features. This is a singleton service which runs on the main thread
479 // and never stops.
480 class ChromeServiceChromeOS
481 : public service_manager::Service,
482 public mash::mojom::Launchable,
483 public service_manager::InterfaceFactory<mash::mojom::Launchable> {
484 public:
485 ChromeServiceChromeOS()
486 : interfaces_(service_manager::mojom::kServiceManager_ConnectorSpec) {
487 interfaces_.AddInterface<mash::mojom::Launchable>(this);
488 }
489 ~ChromeServiceChromeOS() override {}
490
491 static std::unique_ptr<service_manager::Service> CreateService() {
492 return base::MakeUnique<ChromeServiceChromeOS>();
493 }
494
495 private:
496 void CreateNewWindowImpl(bool is_incognito) {
497 Profile* profile = ProfileManager::GetActiveUserProfile();
498 chrome::NewEmptyWindow(is_incognito ? profile->GetOffTheRecordProfile()
499 : profile);
500 }
501
502 // service_manager::Service:
503 void OnBindInterface(const service_manager::ServiceInfo& remote_info,
504 const std::string& name,
505 mojo::ScopedMessagePipeHandle handle) override {
506 interfaces_.BindInterface(name, std::move(handle));
507 }
508
509 // mash::mojom::Launchable:
510 void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
511 if (how != mash::mojom::LaunchMode::MAKE_NEW) {
512 LOG(ERROR) << "Unable to handle Launch request with how = " << how;
513 return;
514 }
515 switch (what) {
516 case mash::mojom::kWindow:
517 CreateNewWindowImpl(false /* is_incognito */);
518 break;
519 case mash::mojom::kIncognitoWindow:
520 CreateNewWindowImpl(true /* is_incognito */);
521 break;
522 default:
523 NOTREACHED();
524 }
525 }
526
527 // mojo::InterfaceFactory<mash::mojom::Launchable>:
528 void Create(const service_manager::Identity& remote_identity,
529 mash::mojom::LaunchableRequest request) override {
530 bindings_.AddBinding(this, std::move(request));
531 }
532
533 service_manager::InterfaceRegistry interfaces_;
534 mojo::BindingSet<mash::mojom::Launchable> bindings_;
535
536 DISALLOW_COPY_AND_ASSIGN(ChromeServiceChromeOS);
537 };
538
539 #endif // defined(OS_CHROMEOS)
540
465 // Returns a copy of the given url with its host set to given host and path set 541 // 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. 542 // to given path. Other parts of the url will be the same.
467 GURL ReplaceURLHostAndPath(const GURL& url, 543 GURL ReplaceURLHostAndPath(const GURL& url,
468 const std::string& host, 544 const std::string& host,
469 const std::string& path) { 545 const std::string& path) {
470 url::Replacements<char> replacements; 546 url::Replacements<char> replacements;
471 replacements.SetHost(host.c_str(), url::Component(0, host.length())); 547 replacements.SetHost(host.c_str(), url::Component(0, host.length()));
472 replacements.SetPath(path.c_str(), url::Component(0, path.length())); 548 replacements.SetPath(path.c_str(), url::Component(0, path.length()));
473 return url.ReplaceComponents(replacements); 549 return url.ReplaceComponents(replacements);
474 } 550 }
(...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 } 3176 }
3101 3177
3102 void ChromeContentBrowserClient::RegisterInProcessServices( 3178 void ChromeContentBrowserClient::RegisterInProcessServices(
3103 StaticServiceMap* services) { 3179 StaticServiceMap* services) {
3104 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 3180 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
3105 content::ServiceInfo info; 3181 content::ServiceInfo info;
3106 info.factory = base::Bind(&media::CreateMediaService); 3182 info.factory = base::Bind(&media::CreateMediaService);
3107 services->insert(std::make_pair("media", info)); 3183 services->insert(std::make_pair("media", info));
3108 #endif 3184 #endif
3109 #if defined(OS_CHROMEOS) 3185 #if defined(OS_CHROMEOS)
3110 content::ServiceManagerConnection::GetForProcess()->AddConnectionFilter( 3186 {
3111 base::MakeUnique<chromeos::ChromeInterfaceFactory>()); 3187 content::ServiceInfo info;
3188 info.factory = base::Bind(&ChromeServiceChromeOS::CreateService);
3189 info.task_runner = base::ThreadTaskRunnerHandle::Get();
3190 services->insert(std::make_pair(kChromeServiceName, info));
3191 }
3192
3112 { 3193 {
3113 content::ServiceInfo info; 3194 content::ServiceInfo info;
3114 info.factory = base::Bind([] { 3195 info.factory = base::Bind([] {
3115 return std::unique_ptr<service_manager::Service>( 3196 return std::unique_ptr<service_manager::Service>(
3116 base::MakeUnique<PreferencesConnectionManager>()); 3197 base::MakeUnique<PreferencesConnectionManager>());
3117 }); 3198 });
3199 info.task_runner = base::ThreadTaskRunnerHandle::Get();
3118 services->insert(std::make_pair(prefs::mojom::kServiceName, info)); 3200 services->insert(std::make_pair(prefs::mojom::kServiceName, info));
3119 } 3201 }
3202
3203 if (!chrome::IsRunningInMash()) {
3204 content::ServiceInfo info;
3205 info.factory = base::Bind(&ash_util::CreateEmbeddedAshService,
3206 base::ThreadTaskRunnerHandle::Get());
3207 services->insert(std::make_pair("ash", info));
3208 }
3120 #endif // OS_CHROMEOS 3209 #endif // OS_CHROMEOS
3121 } 3210 }
3122 3211
3123 void ChromeContentBrowserClient::RegisterOutOfProcessServices( 3212 void ChromeContentBrowserClient::RegisterOutOfProcessServices(
3124 OutOfProcessServiceMap* services) { 3213 OutOfProcessServiceMap* services) {
3125 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) 3214 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
3126 services->insert(std::make_pair("media", 3215 services->insert(std::make_pair("media",
3127 base::ASCIIToUTF16("Media Service"))); 3216 base::ASCIIToUTF16("Media Service")));
3128 #endif 3217 #endif
3129 services->insert(std::make_pair(image_decoder::mojom::kServiceName, 3218 services->insert(std::make_pair(image_decoder::mojom::kServiceName,
3130 base::ASCIIToUTF16("Image Decoder Service"))); 3219 base::ASCIIToUTF16("Image Decoder Service")));
3131 } 3220 }
3132 3221
3133 std::unique_ptr<base::Value> 3222 std::unique_ptr<base::Value>
3134 ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { 3223 ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
3135 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 3224 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
3136 int id = -1; 3225 int id = -1;
3137 if (name == content::mojom::kBrowserServiceName) 3226 if (name == content::mojom::kBrowserServiceName)
3138 id = IDR_CHROME_CONTENT_BROWSER_MANIFEST_OVERLAY; 3227 id = IDR_CHROME_CONTENT_BROWSER_MANIFEST_OVERLAY;
3139 else if (name == content::mojom::kGpuServiceName) 3228 else if (name == content::mojom::kGpuServiceName)
3140 id = IDR_CHROME_CONTENT_GPU_MANIFEST_OVERLAY; 3229 id = IDR_CHROME_CONTENT_GPU_MANIFEST_OVERLAY;
3230 else if (name == content::mojom::kPackagedServicesServiceName)
3231 id = IDR_CHROME_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY;
3141 else if (name == content::mojom::kPluginServiceName) 3232 else if (name == content::mojom::kPluginServiceName)
3142 id = IDR_CHROME_CONTENT_PLUGIN_MANIFEST_OVERLAY; 3233 id = IDR_CHROME_CONTENT_PLUGIN_MANIFEST_OVERLAY;
3143 else if (name == content::mojom::kRendererServiceName) 3234 else if (name == content::mojom::kRendererServiceName)
3144 id = IDR_CHROME_CONTENT_RENDERER_MANIFEST_OVERLAY; 3235 id = IDR_CHROME_CONTENT_RENDERER_MANIFEST_OVERLAY;
3145 else if (name == content::mojom::kUtilityServiceName) 3236 else if (name == content::mojom::kUtilityServiceName)
3146 id = IDR_CHROME_CONTENT_UTILITY_MANIFEST_OVERLAY; 3237 id = IDR_CHROME_CONTENT_UTILITY_MANIFEST_OVERLAY;
3147 if (id == -1) 3238 if (id == -1)
3148 return nullptr; 3239 return nullptr;
3149 3240
3150 base::StringPiece manifest_contents = 3241 base::StringPiece manifest_contents =
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { 3525 RedirectNonUINonIOBrowserThreadsToTaskScheduler() {
3435 return variations::GetVariationParamValue( 3526 return variations::GetVariationParamValue(
3436 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; 3527 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true";
3437 } 3528 }
3438 3529
3439 // static 3530 // static
3440 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( 3531 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting(
3441 const storage::QuotaSettings* settings) { 3532 const storage::QuotaSettings* settings) {
3442 g_default_quota_settings = settings; 3533 g_default_quota_settings = settings;
3443 } 3534 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/chrome_content_browser_manifest_overlay.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698