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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 #include "net/cookies/canonical_cookie.h" | 202 #include "net/cookies/canonical_cookie.h" |
203 #include "net/cookies/cookie_options.h" | 203 #include "net/cookies/cookie_options.h" |
204 #include "net/ssl/ssl_cert_request_info.h" | 204 #include "net/ssl/ssl_cert_request_info.h" |
205 #include "ppapi/features/features.h" | 205 #include "ppapi/features/features.h" |
206 #include "ppapi/host/ppapi_host.h" | 206 #include "ppapi/host/ppapi_host.h" |
207 #include "printing/features/features.h" | 207 #include "printing/features/features.h" |
208 #include "services/preferences/public/interfaces/preferences.mojom.h" | 208 #include "services/preferences/public/interfaces/preferences.mojom.h" |
209 #include "services/service_manager/public/cpp/binder_registry.h" | 209 #include "services/service_manager/public/cpp/binder_registry.h" |
210 #include "services/service_manager/public/cpp/interface_provider.h" | 210 #include "services/service_manager/public/cpp/interface_provider.h" |
211 #include "services/service_manager/public/cpp/service.h" | 211 #include "services/service_manager/public/cpp/service.h" |
| 212 #include "services/ui/public/interfaces/constants.mojom.h" |
| 213 // TODO: Is this okay? |
| 214 // Note we also do this in chrome/app/mash/embedded_services.cc |
| 215 #include "services/ui/service.h" |
212 #include "storage/browser/fileapi/external_mount_points.h" | 216 #include "storage/browser/fileapi/external_mount_points.h" |
213 #include "third_party/WebKit/public/platform/modules/installedapp/installed_app_
provider.mojom.h" | 217 #include "third_party/WebKit/public/platform/modules/installedapp/installed_app_
provider.mojom.h" |
214 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h" | 218 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h" |
215 #include "ui/base/l10n/l10n_util.h" | 219 #include "ui/base/l10n/l10n_util.h" |
216 #include "ui/base/resource/resource_bundle.h" | 220 #include "ui/base/resource/resource_bundle.h" |
217 #include "ui/resources/grit/ui_resources.h" | 221 #include "ui/resources/grit/ui_resources.h" |
218 #include "url/gurl.h" | 222 #include "url/gurl.h" |
219 #include "url/origin.h" | 223 #include "url/origin.h" |
220 | 224 |
221 #if defined(OS_WIN) | 225 #if defined(OS_WIN) |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 base::FieldTrialList::FindFullName("SaveDataHeader") | 938 base::FieldTrialList::FindFullName("SaveDataHeader") |
935 .compare("Disabled"); | 939 .compare("Disabled"); |
936 } | 940 } |
937 | 941 |
938 WebContents* GetWebContents(int render_process_id, int render_frame_id) { | 942 WebContents* GetWebContents(int render_process_id, int render_frame_id) { |
939 RenderFrameHost* rfh = | 943 RenderFrameHost* rfh = |
940 RenderFrameHost::FromID(render_process_id, render_frame_id); | 944 RenderFrameHost::FromID(render_process_id, render_frame_id); |
941 return WebContents::FromRenderFrameHost(rfh); | 945 return WebContents::FromRenderFrameHost(rfh); |
942 } | 946 } |
943 | 947 |
| 948 std::unique_ptr<service_manager::Service> CreateEmbeddedUIService( |
| 949 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 950 LOG(ERROR) << "CreateEmbeddedUIService"; |
| 951 return base::MakeUnique<ui::Service>(task_runner); |
| 952 } |
| 953 |
944 #if BUILDFLAG(ENABLE_EXTENSIONS) | 954 #if BUILDFLAG(ENABLE_EXTENSIONS) |
945 // Returns true if there is is an extension with the same origin as | 955 // Returns true if there is is an extension with the same origin as |
946 // |source_origin| in |opener_render_process_id| with | 956 // |source_origin| in |opener_render_process_id| with |
947 // APIPermission::kBackground. | 957 // APIPermission::kBackground. |
948 bool SecurityOriginHasExtensionBackgroundPermission( | 958 bool SecurityOriginHasExtensionBackgroundPermission( |
949 extensions::ProcessMap* process_map, | 959 extensions::ProcessMap* process_map, |
950 extensions::ExtensionRegistry* registry, | 960 extensions::ExtensionRegistry* registry, |
951 const GURL& source_origin, | 961 const GURL& source_origin, |
952 int opener_render_process_id) { | 962 int opener_render_process_id) { |
953 // Note: includes web URLs that are part of an extension's web extent. | 963 // Note: includes web URLs that are part of an extension's web extent. |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3134 mojo::ScopedMessagePipeHandle* interface_pipe) { | 3144 mojo::ScopedMessagePipeHandle* interface_pipe) { |
3135 if (source_info.identity.name() == content::mojom::kGpuServiceName && | 3145 if (source_info.identity.name() == content::mojom::kGpuServiceName && |
3136 gpu_binder_registry_.CanBindInterface(interface_name)) { | 3146 gpu_binder_registry_.CanBindInterface(interface_name)) { |
3137 gpu_binder_registry_.BindInterface(source_info, interface_name, | 3147 gpu_binder_registry_.BindInterface(source_info, interface_name, |
3138 std::move(*interface_pipe)); | 3148 std::move(*interface_pipe)); |
3139 } | 3149 } |
3140 } | 3150 } |
3141 | 3151 |
3142 void ChromeContentBrowserClient::RegisterInProcessServices( | 3152 void ChromeContentBrowserClient::RegisterInProcessServices( |
3143 StaticServiceMap* services) { | 3153 StaticServiceMap* services) { |
| 3154 LOG(ERROR) << "ChromeContentBrowserClient::RegisterInProcessServices"; |
| 3155 // base::debug::StackTrace().Print(); |
3144 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | 3156 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
3145 content::ServiceInfo info; | 3157 content::ServiceInfo info; |
3146 info.factory = base::Bind(&media::CreateMediaService); | 3158 info.factory = base::Bind(&media::CreateMediaService); |
3147 services->insert(std::make_pair("media", info)); | 3159 services->insert(std::make_pair("media", info)); |
3148 #endif | 3160 #endif |
3149 #if defined(OS_CHROMEOS) | 3161 #if defined(OS_CHROMEOS) |
3150 { | 3162 { |
3151 content::ServiceInfo info; | 3163 content::ServiceInfo info; |
3152 info.factory = base::Bind(&ChromeServiceChromeOS::CreateService); | 3164 info.factory = base::Bind(&ChromeServiceChromeOS::CreateService); |
3153 info.task_runner = base::ThreadTaskRunnerHandle::Get(); | 3165 info.task_runner = base::ThreadTaskRunnerHandle::Get(); |
3154 services->insert(std::make_pair(chromeos::kChromeServiceName, info)); | 3166 services->insert(std::make_pair(chromeos::kChromeServiceName, info)); |
3155 } | 3167 } |
3156 | 3168 |
3157 if (features::PrefServiceEnabled()) { | 3169 if (features::PrefServiceEnabled()) { |
3158 content::ServiceInfo info; | 3170 content::ServiceInfo info; |
3159 info.factory = base::Bind([] { | 3171 info.factory = base::Bind([] { |
3160 return std::unique_ptr<service_manager::Service>( | 3172 return std::unique_ptr<service_manager::Service>( |
3161 base::MakeUnique<ActiveProfilePrefService>()); | 3173 base::MakeUnique<ActiveProfilePrefService>()); |
3162 }); | 3174 }); |
3163 info.task_runner = base::ThreadTaskRunnerHandle::Get(); | 3175 info.task_runner = base::ThreadTaskRunnerHandle::Get(); |
3164 services->insert(std::make_pair(prefs::mojom::kForwarderServiceName, info)); | 3176 services->insert(std::make_pair(prefs::mojom::kForwarderServiceName, info)); |
3165 } | 3177 } |
3166 | 3178 |
3167 if (!ash_util::IsRunningInMash()) { | 3179 if (!ash_util::IsRunningInMash()) { |
3168 content::ServiceInfo info; | 3180 content::ServiceInfo info_ash; |
3169 info.factory = base::Bind(&ash_util::CreateEmbeddedAshService, | 3181 info_ash.factory = base::Bind(&ash_util::CreateEmbeddedAshService, |
3170 base::ThreadTaskRunnerHandle::Get()); | 3182 base::ThreadTaskRunnerHandle::Get()); |
3171 info.task_runner = base::ThreadTaskRunnerHandle::Get(); | 3183 info_ash.task_runner = base::ThreadTaskRunnerHandle::Get(); |
3172 services->insert(std::make_pair(ash::mojom::kServiceName, info)); | 3184 services->insert(std::make_pair(ash::mojom::kServiceName, info_ash)); |
| 3185 |
| 3186 // TODO: Note that even if we wanted, we wouldn't be able to run this on the |
| 3187 // UI thread because of WindowTreeClient::WaitForInitialDisplays in AshInit. |
| 3188 // On the other hand, running all interfaces on the other thread is also |
| 3189 // problematic, because resources have to all be loaded on the same thread - |
| 3190 // see CalledOnValidSequence() DCHECKs in ResourceBundle. |
| 3191 // WindowServer loads resources for cursor. |
| 3192 content::ServiceInfo info_ui; |
| 3193 info_ui.factory = base::Bind( |
| 3194 &CreateEmbeddedUIService, |
| 3195 base::ThreadTaskRunnerHandle::Get()); //, window_server_task_runner); |
| 3196 info_ui.use_own_thread = true; |
| 3197 info_ui.message_loop_type = base::MessageLoop::TYPE_UI; |
| 3198 info_ui.thread_priority = base::ThreadPriority::DISPLAY; |
| 3199 services->insert(std::make_pair(ui::mojom::kServiceName, info_ui)); |
3173 } | 3200 } |
3174 #endif // OS_CHROMEOS | 3201 #endif // OS_CHROMEOS |
3175 } | 3202 } |
3176 | 3203 |
3177 void ChromeContentBrowserClient::RegisterOutOfProcessServices( | 3204 void ChromeContentBrowserClient::RegisterOutOfProcessServices( |
3178 OutOfProcessServiceMap* services) { | 3205 OutOfProcessServiceMap* services) { |
3179 #if BUILDFLAG(ENABLE_PRINTING) | 3206 #if BUILDFLAG(ENABLE_PRINTING) |
3180 services->emplace(printing::mojom::kServiceName, | 3207 services->emplace(printing::mojom::kServiceName, |
3181 base::ASCIIToUTF16("PDF Compositor Service")); | 3208 base::ASCIIToUTF16("PDF Compositor Service")); |
3182 #endif | 3209 #endif |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3528 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
3502 return variations::GetVariationParamValue( | 3529 return variations::GetVariationParamValue( |
3503 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3530 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
3504 } | 3531 } |
3505 | 3532 |
3506 // static | 3533 // static |
3507 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( | 3534 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
3508 const storage::QuotaSettings* settings) { | 3535 const storage::QuotaSettings* settings) { |
3509 g_default_quota_settings = settings; | 3536 g_default_quota_settings = settings; |
3510 } | 3537 } |
OLD | NEW |