blob: bc2bba12c150ff0fec2ecd2d9ade7c3773cc27f3 [file] [log] [blame]
[email protected]f3986f82012-01-03 20:00:061// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]d977f9c2011-03-14 16:10:262// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/chrome_content_browser_client.h"
6
[email protected]7c3228a2011-11-11 21:35:227#include <set>
[email protected]1033acd2012-02-08 08:46:278#include <utility>
[email protected]7c3228a2011-11-11 21:35:229#include <vector>
10
[email protected]317c58f02011-11-09 02:15:0311#include "base/bind.h"
[email protected]b80f68432011-05-02 17:22:3012#include "base/command_line.h"
[email protected]e461da2f2012-02-16 19:06:4013#include "base/string_tokenizer.h"
[email protected]f3986f82012-01-03 20:00:0614#include "base/utf_string_conversions.h"
[email protected]b80f68432011-05-02 17:22:3015#include "chrome/app/breakpad_mac.h"
[email protected]b8148ac2011-07-13 22:03:2516#include "chrome/browser/browser_about_handler.h"
[email protected]b80f68432011-05-02 17:22:3017#include "chrome/browser/browser_process.h"
[email protected]3b8f7e32011-07-13 11:52:2318#include "chrome/browser/browsing_data_remover.h"
[email protected]763ec4ca2011-04-29 15:48:1219#include "chrome/browser/character_encoding.h"
[email protected]6f08af82011-09-15 01:19:0320#include "chrome/browser/chrome_benchmarking_message_filter.h"
[email protected]317f96c92011-05-31 06:53:4121#include "chrome/browser/chrome_quota_permission_context.h"
[email protected]edece212011-11-16 11:56:5622#include "chrome/browser/content_settings/content_settings_utils.h"
[email protected]30fde822011-10-28 09:49:0523#include "chrome/browser/content_settings/cookie_settings.h"
[email protected]6786bf402011-12-03 15:19:4524#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]8093a542011-05-13 07:29:3225#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]9d06d88d2012-02-23 22:37:0826#include "chrome/browser/defaults.h"
[email protected]e1d16eb92011-08-18 23:19:3227#include "chrome/browser/download/download_util.h"
[email protected]6e672df2012-01-25 10:39:4728#include "chrome/browser/extensions/api/webrequest/webrequest_api.h"
[email protected]76411f412012-02-22 18:56:0629#include "chrome/browser/extensions/extension_host.h"
[email protected]941623e2011-06-07 23:06:0430#include "chrome/browser/extensions/extension_info_map.h"
[email protected]76411f412012-02-22 18:56:0631#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]f364d1392011-04-08 21:03:1032#include "chrome/browser/extensions/extension_message_handler.h"
[email protected]d977f9c2011-03-14 16:10:2633#include "chrome/browser/extensions/extension_service.h"
[email protected]b8148ac2011-07-13 22:03:2534#include "chrome/browser/extensions/extension_web_ui.h"
[email protected]f3986f82012-01-03 20:00:0635#include "chrome/browser/extensions/extension_webkit_preferences.h"
[email protected]32538d92011-08-25 00:09:2336#include "chrome/browser/geolocation/chrome_access_token_store.h"
[email protected]763ec4ca2011-04-29 15:48:1237#include "chrome/browser/google/google_util.h"
[email protected]117b6b42012-02-29 09:11:0838#include "chrome/browser/infobars/infobar_tab_helper.h"
[email protected]ae6e9912011-07-27 01:18:2839#include "chrome/browser/net/chrome_net_log.h"
[email protected]941623e2011-06-07 23:06:0440#include "chrome/browser/notifications/desktop_notification_service.h"
41#include "chrome/browser/notifications/desktop_notification_service_factory.h"
[email protected]0609b17f2011-05-31 20:13:4242#include "chrome/browser/platform_util.h"
[email protected]763ec4ca2011-04-29 15:48:1243#include "chrome/browser/prefs/pref_service.h"
[email protected]f3986f82012-01-03 20:00:0644#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]f9034cf2011-07-21 12:43:4145#include "chrome/browser/prerender/prerender_manager.h"
[email protected]3085c502011-10-05 17:50:5046#include "chrome/browser/prerender/prerender_manager_factory.h"
[email protected]f9034cf2011-07-21 12:43:4147#include "chrome/browser/prerender/prerender_tracker.h"
[email protected]05fcf982011-04-19 00:44:1448#include "chrome/browser/printing/printing_message_filter.h"
49#include "chrome/browser/profiles/profile.h"
[email protected]8093a542011-05-13 07:29:3250#include "chrome/browser/profiles/profile_io_data.h"
[email protected]76411f412012-02-22 18:56:0651#include "chrome/browser/profiles/profile_manager.h"
[email protected]05fcf982011-04-19 00:44:1452#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
[email protected]53a0afa2011-04-28 02:09:3353#include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
[email protected]8aa7a412011-11-07 12:33:4254#include "chrome/browser/renderer_host/plugin_info_message_filter.h"
[email protected]05fcf982011-04-19 00:44:1455#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
[email protected]66cfec62012-02-24 17:57:5156#include "chrome/browser/speech/chrome_speech_input_manager_delegate.h"
[email protected]8ec71262011-07-28 08:12:4657#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
[email protected]8ec26472011-06-06 16:52:4558#include "chrome/browser/ssl/ssl_add_cert_handler.h"
[email protected]848dd042011-06-04 18:24:0359#include "chrome/browser/ssl/ssl_blocking_page.h"
[email protected]8ec26472011-06-06 16:52:4560#include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
61#include "chrome/browser/tab_contents/tab_util.h"
[email protected]117b6b42012-02-29 09:11:0862#include "chrome/browser/ui/media_stream_infobar_delegate.h"
[email protected]8ec26472011-06-06 16:52:4563#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
[email protected]863f70a2012-01-27 02:05:5064#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
[email protected]f3986f82012-01-03 20:00:0665#include "chrome/browser/user_style_sheet_watcher.h"
[email protected]b80f68432011-05-02 17:22:3066#include "chrome/common/child_process_logging.h"
[email protected]4a65826d2011-08-25 16:04:0167#include "chrome/common/chrome_constants.h"
[email protected]b80f68432011-05-02 17:22:3068#include "chrome/common/chrome_switches.h"
[email protected]941623e2011-06-07 23:06:0469#include "chrome/common/extensions/extension.h"
[email protected]615d88f2011-12-13 01:47:4470#include "chrome/common/extensions/extension_set.h"
[email protected]f1933792011-06-14 00:49:3471#include "chrome/common/logging_chrome.h"
[email protected]763ec4ca2011-04-29 15:48:1272#include "chrome/common/pref_names.h"
[email protected]3e69bc82011-05-26 23:22:3873#include "chrome/common/render_messages.h"
[email protected]c5dbef02011-05-13 05:06:0974#include "chrome/common/url_constants.h"
[email protected]b8148ac2011-07-13 22:03:2575#include "content/browser/browser_url_handler.h"
[email protected]d977f9c2011-03-14 16:10:2676#include "content/browser/renderer_host/render_view_host.h"
[email protected]b48c9182011-10-26 18:03:3077#include "content/public/browser/browser_main_parts.h"
[email protected]b9535422012-02-09 01:47:5978#include "content/public/browser/child_process_security_policy.h"
[email protected]f3b1a082011-11-18 00:34:3079#include "content/public/browser/render_process_host.h"
[email protected]ce967862012-02-09 22:47:0580#include "content/public/browser/resource_context.h"
[email protected]b6583592012-01-25 19:52:3381#include "content/public/browser/site_instance.h"
[email protected]91ee3682012-01-19 15:02:1982#include "content/public/browser/web_contents.h"
[email protected]8643e6d2012-01-18 20:26:1083#include "content/public/browser/web_contents_view.h"
[email protected]c9b6eb62011-10-18 20:49:3984#include "grit/generated_resources.h"
[email protected]29b25d092011-06-29 20:57:3485#include "grit/ui_resources.h"
[email protected]ed24fad2011-05-10 22:44:0186#include "net/base/cookie_monster.h"
87#include "net/base/cookie_options.h"
[email protected]7a593db2012-02-13 21:19:4088#include "net/base/ssl_cert_request_info.h"
[email protected]c9b6eb62011-10-18 20:49:3989#include "ui/base/l10n/l10n_util.h"
[email protected]ac55e292011-06-24 05:16:0890#include "ui/base/resource/resource_bundle.h"
[email protected]4fdf6742012-01-10 20:14:3691#include "webkit/glue/webpreferences.h"
[email protected]d977f9c2011-03-14 16:10:2692
[email protected]b48c9182011-10-26 18:03:3093#if defined(OS_WIN)
[email protected]199fc7a2011-09-28 22:45:3894#include "chrome/browser/chrome_browser_main_win.h"
95#elif defined(OS_MACOSX)
96#include "chrome/browser/chrome_browser_main_mac.h"
[email protected]7ceb99012011-12-21 08:05:5697#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
[email protected]b48c9182011-10-26 18:03:3098#elif defined(OS_CHROMEOS)
99#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
[email protected]e60c0232011-11-11 19:56:35100#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]b48c9182011-10-26 18:03:30101#include "chrome/browser/chrome_browser_main_linux.h"
102#elif defined(OS_POSIX)
103#include "chrome/browser/chrome_browser_main_posix.h"
104#endif
105
[email protected]b48c9182011-10-26 18:03:30106#if defined(TOOLKIT_USES_GTK)
[email protected]50462bf02011-11-21 19:13:31107#include "chrome/browser/chrome_browser_main_extra_parts_gtk.h"
[email protected]199fc7a2011-09-28 22:45:38108#endif
109
[email protected]c7480942011-11-08 19:18:27110#if defined(TOOLKIT_VIEWS)
[email protected]50462bf02011-11-21 19:13:31111#include "chrome/browser/chrome_browser_main_extra_parts_views.h"
[email protected]c7480942011-11-08 19:18:27112#endif
113
114#if defined(USE_AURA)
[email protected]50462bf02011-11-21 19:13:31115#include "chrome/browser/chrome_browser_main_extra_parts_aura.h"
116#endif
117
[email protected]e60c0232011-11-11 19:56:35118#if defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]b80f68432011-05-02 17:22:30119#include "base/linux_util.h"
120#include "chrome/browser/crash_handler_host_linux.h"
[email protected]1fd5302c2011-05-28 04:06:43121#endif
[email protected]b80f68432011-05-02 17:22:30122
[email protected]080f34f2011-09-20 05:39:26123#if defined(TOOLKIT_VIEWS)
[email protected]74313b42011-08-24 16:51:32124#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
[email protected]c92f4ed2011-10-21 19:50:21125#elif defined(TOOLKIT_USES_GTK)
[email protected]9bce7772011-11-16 01:24:45126#include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h"
[email protected]90580422012-01-12 00:26:22127#include "content/browser/tab_contents/tab_contents_view_gtk.h"
[email protected]74313b42011-08-24 16:51:32128#elif defined(OS_MACOSX)
[email protected]cce3ab72012-02-04 18:05:16129#include "chrome/browser/tab_contents/chrome_web_contents_view_mac_delegate.h"
[email protected]eb668c92012-02-06 15:35:29130#include "content/browser/tab_contents/web_contents_view_mac.h"
[email protected]6e677a342012-02-11 01:21:14131#elif defined(OS_ANDROID)
[email protected]82c9f44b2012-02-14 21:02:52132#include "content/browser/tab_contents/web_contents_view_android.h"
[email protected]74313b42011-08-24 16:51:32133#endif
134
[email protected]37a72af2011-06-13 05:42:01135#if defined(USE_NSS)
136#include "chrome/browser/ui/crypto_module_password_dialog.h"
137#endif
138
[email protected]c8c77182011-12-21 15:04:47139using content::AccessTokenStore;
[email protected]631bb742011-11-02 11:29:39140using content::BrowserThread;
[email protected]b9535422012-02-09 01:47:59141using content::ChildProcessSecurityPolicy;
[email protected]b6583592012-01-25 19:52:33142using content::SiteInstance;
[email protected]83ff91c2012-01-05 20:54:13143using content::WebContents;
[email protected]631bb742011-11-02 11:29:39144
[email protected]c5dbef02011-05-13 05:06:09145namespace {
146
[email protected]e461da2f2012-02-16 19:06:40147const char* kPredefinedAllowedSocketOrigins[] = {
148 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
149 "pnhechapfaindjhompbnflcldabbghjo" // HTerm App (SSH Client)
150};
151
[email protected]b8148ac2011-07-13 22:03:25152// Handles rewriting Web UI URLs.
[email protected]8d3132f62011-10-12 07:13:42153bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
[email protected]863f70a2012-01-27 02:05:50154 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
155 browser_context, *url))
[email protected]b8148ac2011-07-13 22:03:25156 return false;
157
158 // Special case the new tab page. In older versions of Chrome, the new tab
159 // page was hosted at chrome-internal:<blah>. This might be in people's saved
160 // sessions or bookmarks, so we say any URL with that scheme triggers the new
161 // tab page.
162 if (url->SchemeIs(chrome::kChromeInternalScheme)) {
163 // Rewrite it with the proper new tab URL.
164 *url = GURL(chrome::kChromeUINewTabURL);
165 }
166
167 return true;
168}
169
[email protected]8d3132f62011-10-12 07:13:42170// Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
171// below. Extension, and isolated apps require different privileges to be
172// granted to their RenderProcessHosts. This classification allows us to make
173// sure URLs are served by hosts with the right set of privileges.
174enum RenderProcessHostPrivilege {
175 PRIV_NORMAL,
[email protected]eec0b33c2011-12-05 22:09:45176 PRIV_HOSTED,
[email protected]8d3132f62011-10-12 07:13:42177 PRIV_ISOLATED,
[email protected]eec0b33c2011-12-05 22:09:45178 PRIV_EXTENSION,
[email protected]8d3132f62011-10-12 07:13:42179};
180
181RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
182 const GURL& url,
183 ExtensionService* service) {
184 // Default to a normal renderer cause it is lower privileged. This should only
185 // occur if the URL on a site instance is either malformed, or uninitialized.
186 // If it is malformed, then there is no need for better privileges anyways.
187 // If it is uninitialized, but eventually settles on being an a scheme other
188 // than normal webrenderer, the navigation logic will correct us out of band
189 // anyways.
190 if (!url.is_valid())
191 return PRIV_NORMAL;
192
193 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]615d88f2011-12-13 01:47:44194 const Extension* extension =
195 service->extensions()->GetByID(url.host());
[email protected]eec0b33c2011-12-05 22:09:45196 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42197 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45198 if (extension && extension->is_hosted_app())
199 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42200
201 return PRIV_EXTENSION;
202 }
203
204 return PRIV_NORMAL;
205}
206
207RenderProcessHostPrivilege GetProcessPrivilege(
[email protected]f3b1a082011-11-18 00:34:30208 content::RenderProcessHost* process_host,
[email protected]6f371442011-11-09 06:45:46209 extensions::ProcessMap* process_map,
210 ExtensionService* service) {
[email protected]6f371442011-11-09 06:45:46211 std::set<std::string> extension_ids =
[email protected]f3b1a082011-11-18 00:34:30212 process_map->GetExtensionsInProcess(process_host->GetID());
[email protected]6f371442011-11-09 06:45:46213 if (extension_ids.empty())
[email protected]676f6ab2011-10-19 20:23:21214 return PRIV_NORMAL;
215
[email protected]6f371442011-11-09 06:45:46216 for (std::set<std::string>::iterator iter = extension_ids.begin();
217 iter != extension_ids.end(); ++iter) {
218 const Extension* extension = service->GetExtensionById(*iter, false);
219 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42220 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45221 if (extension && extension->is_hosted_app())
222 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42223 }
224
[email protected]676f6ab2011-10-19 20:23:21225 return PRIV_EXTENSION;
[email protected]8d3132f62011-10-12 07:13:42226}
227
[email protected]eec0b33c2011-12-05 22:09:45228bool IsIsolatedAppInProcess(const GURL& site_url,
229 content::RenderProcessHost* process_host,
230 extensions::ProcessMap* process_map,
231 ExtensionService* service) {
232 std::set<std::string> extension_ids =
233 process_map->GetExtensionsInProcess(process_host->GetID());
234 if (extension_ids.empty())
235 return false;
236
237 for (std::set<std::string>::iterator iter = extension_ids.begin();
238 iter != extension_ids.end(); ++iter) {
239 const Extension* extension = service->GetExtensionById(*iter, false);
240 if (extension &&
241 extension->is_storage_isolated() &&
242 extension->url() == site_url)
243 return true;
244 }
245
246 return false;
247}
248
[email protected]6786bf402011-12-03 15:19:45249bool CertMatchesFilter(const net::X509Certificate& cert,
250 const base::DictionaryValue& filter) {
251 // TODO(markusheintz): This is the minimal required filter implementation.
252 // Implement a better matcher.
253
254 // An empty filter matches any client certificate since no requirements are
255 // specified at all.
256 if (filter.empty())
257 return true;
258
259 std::string common_name;
260 if (filter.GetString("ISSUER.CN", &common_name) &&
261 (cert.issuer().common_name == common_name)) {
262 return true;
263 }
264 return false;
265}
266
[email protected]f3986f82012-01-03 20:00:06267// Fills |map| with the per-script font prefs under path |map_name|.
268void FillFontFamilyMap(const PrefService* prefs,
269 const char* map_name,
270 WebPreferences::ScriptFontFamilyMap* map) {
271 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
272 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
273 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
274 std::string font_family = prefs->GetString(pref_name.c_str());
275 if (!font_family.empty())
276 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
277 }
278}
279
[email protected]9dbfff12011-07-01 19:37:07280} // namespace
[email protected]c5dbef02011-05-13 05:06:09281
[email protected]d977f9c2011-03-14 16:10:26282namespace chrome {
283
[email protected]e461da2f2012-02-16 19:06:40284ChromeContentBrowserClient::ChromeContentBrowserClient() {
285 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
286 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
287
288 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
289 std::string allowed_list =
290 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
291 if (!allowed_list.empty()) {
292 StringTokenizer t(allowed_list, ",");
293 while (t.GetNext()) {
294 allowed_socket_origins_.insert(t.token());
295 }
296 }
297}
298
299ChromeContentBrowserClient::~ChromeContentBrowserClient() {
300}
301
[email protected]50462bf02011-11-21 19:13:31302content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
303 const content::MainFunctionParams& parameters) {
304 ChromeBrowserMainParts* main_parts;
[email protected]b48c9182011-10-26 18:03:30305 // Construct the Main browser parts based on the OS type.
306#if defined(OS_WIN)
[email protected]50462bf02011-11-21 19:13:31307 main_parts = new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04308#elif defined(OS_MACOSX)
[email protected]50462bf02011-11-21 19:13:31309 main_parts = new ChromeBrowserMainPartsMac(parameters);
[email protected]b48c9182011-10-26 18:03:30310#elif defined(OS_CHROMEOS)
[email protected]50462bf02011-11-21 19:13:31311 main_parts = new ChromeBrowserMainPartsChromeos(parameters);
[email protected]e60c0232011-11-11 19:56:35312#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]50462bf02011-11-21 19:13:31313 main_parts = new ChromeBrowserMainPartsLinux(parameters);
[email protected]6e677a342012-02-11 01:21:14314#elif defined(OS_ANDROID)
315 // Do nothing for Android.
316 // TODO(klobag): Android initialization should use the
317 // *BrowserMainParts class-hierarchy for setting up custom initialization.
318 main_parts = NULL;
[email protected]b48c9182011-10-26 18:03:30319#elif defined(OS_POSIX)
[email protected]50462bf02011-11-21 19:13:31320 main_parts = new ChromeBrowserMainPartsPosix(parameters);
[email protected]f967b722011-09-07 00:58:04321#else
[email protected]b48c9182011-10-26 18:03:30322 NOTREACHED();
[email protected]50462bf02011-11-21 19:13:31323 main_parts = new ChromeBrowserMainParts(parameters);
[email protected]b48c9182011-10-26 18:03:30324#endif
325
[email protected]c7480942011-11-08 19:18:27326 // Construct additional browser parts. Stages are called in the order in
327 // which they are added.
[email protected]b48c9182011-10-26 18:03:30328#if defined(TOOLKIT_USES_GTK)
[email protected]50462bf02011-11-21 19:13:31329 main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk());
[email protected]f967b722011-09-07 00:58:04330#endif
[email protected]c7480942011-11-08 19:18:27331
332#if defined(TOOLKIT_VIEWS)
[email protected]50462bf02011-11-21 19:13:31333 main_parts->AddParts(new ChromeBrowserMainExtraPartsViews());
[email protected]c7480942011-11-08 19:18:27334#endif
335
336#if defined(USE_AURA)
[email protected]50462bf02011-11-21 19:13:31337 main_parts->AddParts(new ChromeBrowserMainExtraPartsAura());
[email protected]c7480942011-11-08 19:18:27338#endif
339
[email protected]50462bf02011-11-21 19:13:31340 return main_parts;
[email protected]f967b722011-09-07 00:58:04341}
342
[email protected]8643e6d2012-01-18 20:26:10343content::WebContentsView* ChromeContentBrowserClient::CreateWebContentsView(
[email protected]8dad546b2012-01-17 21:47:35344 WebContents* web_contents) {
[email protected]080f34f2011-09-20 05:39:26345#if defined(TOOLKIT_VIEWS)
[email protected]8dad546b2012-01-17 21:47:35346 return new TabContentsViewViews(web_contents);
[email protected]c92f4ed2011-10-21 19:50:21347#elif defined(TOOLKIT_USES_GTK)
[email protected]8dad546b2012-01-17 21:47:35348 return new content::TabContentsViewGtk(web_contents,
[email protected]90580422012-01-12 00:26:22349 new ChromeTabContentsViewWrapperGtk);
[email protected]74313b42011-08-24 16:51:32350#elif defined(OS_MACOSX)
[email protected]eb668c92012-02-06 15:35:29351 return web_contents_view_mac::CreateWebContentsView(
[email protected]cce3ab72012-02-04 18:05:16352 web_contents,
353 chrome_web_contents_view_mac_delegate::CreateWebContentsViewMacDelegate(
354 web_contents));
[email protected]6e677a342012-02-11 01:21:14355#elif defined(OS_ANDROID)
[email protected]82c9f44b2012-02-14 21:02:52356 return new WebContentsViewAndroid(web_contents);
[email protected]74313b42011-08-24 16:51:32357#else
[email protected]8643e6d2012-01-18 20:26:10358#error Need to create your platform WebContentsView here.
[email protected]74313b42011-08-24 16:51:32359#endif
360}
361
[email protected]f364d1392011-04-08 21:03:10362void ChromeContentBrowserClient::RenderViewHostCreated(
363 RenderViewHost* render_view_host) {
[email protected]67372ecf2011-09-10 01:30:46364
365 SiteInstance* site_instance = render_view_host->site_instance();
366 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02367 site_instance->GetBrowserContext());
[email protected]67372ecf2011-09-10 01:30:46368
369 new ChromeRenderViewHostObserver(render_view_host,
370 profile->GetNetworkPredictor());
[email protected]f364d1392011-04-08 21:03:10371 new ExtensionMessageHandler(render_view_host);
[email protected]85f0a572012-02-07 22:20:13372
373 if (render_view_host->delegate()->GetRenderViewType() ==
374 content::VIEW_TYPE_INTERSTITIAL_PAGE) {
375 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial(
376 render_view_host->routing_id()));
377 }
[email protected]d977f9c2011-03-14 16:10:26378}
379
[email protected]f3b1a082011-11-18 00:34:30380void ChromeContentBrowserClient::RenderProcessHostCreated(
381 content::RenderProcessHost* host) {
382 int id = host->GetID();
383 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
384 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]c47cfd62011-04-29 21:27:02385 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]f3b1a082011-11-18 00:34:30386 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
[email protected]058e5732012-03-01 22:48:03387#if !defined(OS_ANDROID)
[email protected]f3b1a082011-11-18 00:34:30388 host->GetChannel()->AddFilter(new PrintingMessageFilter());
[email protected]058e5732012-03-01 22:48:03389#endif
[email protected]f3b1a082011-11-18 00:34:30390 host->GetChannel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02391 new SearchProviderInstallStateMessageFilter(id, profile));
[email protected]f3b1a082011-11-18 00:34:30392 host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]7ceb99012011-12-21 08:05:56393#if defined(OS_MACOSX)
394 host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac());
395#endif
[email protected]f3b1a082011-11-18 00:34:30396 host->GetChannel()->AddFilter(new ChromeBenchmarkingMessageFilter(
[email protected]6f08af82011-09-15 01:19:03397 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]3e69bc82011-05-26 23:22:38398
[email protected]2ccf45c2011-08-19 23:35:50399 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
400 profile->IsOffTheRecord()));
[email protected]39a5b532011-10-22 01:47:07401
402 SendExtensionWebRequestStatusToHost(host);
[email protected]edece212011-11-16 11:56:56403
404 RendererContentSettingRules rules;
405 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules);
406 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
[email protected]05fcf982011-04-19 00:44:14407}
408
[email protected]863f70a2012-01-27 02:05:50409content::WebUIControllerFactory*
410 ChromeContentBrowserClient::GetWebUIControllerFactory() {
411 return ChromeWebUIControllerFactory::GetInstance();
[email protected]1fd1a502011-03-30 16:55:56412}
413
[email protected]3d7474ff2011-07-27 17:47:37414GURL ChromeContentBrowserClient::GetEffectiveURL(
415 content::BrowserContext* browser_context, const GURL& url) {
416 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]36fb2c7c2011-04-04 15:49:08417 // Get the effective URL for the given actual URL. If the URL is part of an
418 // installed app, the effective URL is an extension URL with the ID of that
419 // extension as the host. This has the effect of grouping apps together in
420 // a common SiteInstance.
421 if (!profile || !profile->GetExtensionService())
422 return url;
423
[email protected]615d88f2011-12-13 01:47:44424 const Extension* extension = profile->GetExtensionService()->extensions()->
425 GetHostedAppByURL(ExtensionURLInfo(url));
[email protected]36fb2c7c2011-04-04 15:49:08426 if (!extension)
427 return url;
428
[email protected]15877ca2011-11-18 22:40:52429 // Bookmark apps do not use the hosted app process model, and should be
430 // treated as normal URLs.
431 if (extension->from_bookmark())
432 return url;
433
[email protected]36fb2c7c2011-04-04 15:49:08434 // If the URL is part of an extension's web extent, convert it to an
435 // extension URL.
436 return extension->GetResourceURL(url.path());
437}
438
[email protected]056ad2a2011-07-12 02:13:55439bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37440 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]056ad2a2011-07-12 02:13:55441 // Non-extension URLs should generally use process-per-site-instance.
[email protected]15877ca2011-11-18 22:40:52442 // Because we expect to use the effective URL, URLs for hosted apps (apart
443 // from bookmark apps) should have an extension scheme by now.
[email protected]056ad2a2011-07-12 02:13:55444 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
445 return false;
446
[email protected]3d7474ff2011-07-27 17:47:37447 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]056ad2a2011-07-12 02:13:55448 if (!profile || !profile->GetExtensionService())
449 return false;
450
[email protected]615d88f2011-12-13 01:47:44451 const Extension* extension = profile->GetExtensionService()->extensions()->
452 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
[email protected]056ad2a2011-07-12 02:13:55453 if (!extension)
454 return false;
455
456 // If the URL is part of a hosted app that does not have the background
[email protected]7b54ca02012-03-02 18:06:53457 // permission, or that does not allow JavaScript access to the background
458 // page, we want to give each instance its own process to improve
[email protected]056ad2a2011-07-12 02:13:55459 // responsiveness.
[email protected]7b54ca02012-03-02 18:06:53460 if (extension->GetType() == Extension::TYPE_HOSTED_APP) {
461 if (!extension->HasAPIPermission(ExtensionAPIPermission::kBackground) ||
462 !extension->allow_background_js_access()) {
463 return false;
464 }
465 }
[email protected]056ad2a2011-07-12 02:13:55466
[email protected]7b54ca02012-03-02 18:06:53467 // Hosted apps that have script access to their background page must use
468 // process per site, since all instances can make synchronous calls to the
469 // background window. Other extensions should use process per site as well.
[email protected]056ad2a2011-07-12 02:13:55470 return true;
471}
472
[email protected]46fb9442011-12-09 17:57:47473bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
474 return ProfileIOData::IsHandledURL(url);
475}
476
[email protected]2a5221b2011-09-27 23:07:31477bool ChromeContentBrowserClient::IsSuitableHost(
[email protected]f3b1a082011-11-18 00:34:30478 content::RenderProcessHost* process_host,
[email protected]2a5221b2011-09-27 23:07:31479 const GURL& site_url) {
480 Profile* profile =
[email protected]f3b1a082011-11-18 00:34:30481 Profile::FromBrowserContext(process_host->GetBrowserContext());
[email protected]8d3132f62011-10-12 07:13:42482 ExtensionService* service = profile->GetExtensionService();
[email protected]6f371442011-11-09 06:45:46483 extensions::ProcessMap* process_map = service->process_map();
[email protected]2a5221b2011-09-27 23:07:31484
[email protected]ffa97602011-11-17 17:55:52485 // Don't allow the Task Manager to share a process with anything else.
486 // Otherwise it can affect the renderers it is observing.
487 // Note: we could create another RenderProcessHostPrivilege bucket for
488 // this to allow multiple chrome://tasks instances to share, but that's
489 // a very unlikely case without serious consequences.
490 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin())
491 return false;
492
[email protected]8d3132f62011-10-12 07:13:42493 // These may be NULL during tests. In that case, just assume any site can
494 // share any host.
[email protected]6f371442011-11-09 06:45:46495 if (!service || !process_map)
[email protected]2a5221b2011-09-27 23:07:31496 return true;
497
[email protected]a8c269a2011-10-25 20:17:22498 // Experimental:
499 // If --enable-strict-site-isolation is enabled, do not allow non-WebUI pages
500 // to share a renderer process. (We could allow pages from the same site or
501 // extensions of the same type to share, if we knew what the given process
502 // was dedicated to. Allowing no sharing is simpler for now.) This may
503 // cause resource exhaustion issues if too many sites are open at once.
504 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
505 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation))
506 return false;
507
[email protected]eec0b33c2011-12-05 22:09:45508 // An isolated app is only allowed to share with the exact same app in order
509 // to provide complete renderer process isolation. This also works around
510 // issue http://crbug.com/85588, where different isolated apps in the same
511 // process would end up using the first app's storage contexts.
512 RenderProcessHostPrivilege privilege_required =
[email protected]8d3132f62011-10-12 07:13:42513 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]eec0b33c2011-12-05 22:09:45514 if (privilege_required == PRIV_ISOLATED)
515 return IsIsolatedAppInProcess(site_url, process_host, process_map, service);
516
517 // Otherwise, just make sure the process privilege matches the privilege
518 // required by the site.
519 return GetProcessPrivilege(process_host, process_map, service) ==
520 privilege_required;
[email protected]2a5221b2011-09-27 23:07:31521}
522
[email protected]76411f412012-02-22 18:56:06523// This function is trying to limit the amount of processes used by extensions
524// with background pages. It uses a globally set percentage of processes to
525// run such extensions and if the limit is exceeded, it returns true, to
526// indicate to the content module to group extensions together.
527bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
528 content::BrowserContext* browser_context, const GURL& url) {
529 // It has to be a valid URL for us to check for an extension.
530 if (!url.is_valid())
531 return false;
532
533 Profile* profile = Profile::FromBrowserContext(browser_context);
534 ExtensionService* service = profile->GetExtensionService();
535 if (!service)
536 return false;
537
538 // We have to have a valid extension with background page to proceed.
539 const Extension* extension =
540 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
541 if (!extension)
542 return false;
543 if (!extension->has_background_page())
544 return false;
545
546 std::set<int> process_ids;
547 size_t max_process_count =
548 content::RenderProcessHost::GetMaxRendererProcessCount();
549
550 // Go through all profiles to ensure we have total count of extension
551 // processes containing background pages, otherwise one profile can
552 // starve the other.
553 std::vector<Profile*> profiles = g_browser_process->profile_manager()->
554 GetLoadedProfiles();
555 for (size_t i = 0; i < profiles.size(); ++i) {
556 ExtensionProcessManager* epm = profiles[i]->GetExtensionProcessManager();
557 for (ExtensionProcessManager::const_iterator iter = epm->begin();
558 iter != epm->end();
559 ++iter) {
560 ExtensionHost* host = *iter;
561 if (host->extension()->has_background_page()) {
562 process_ids.insert(host->render_process_host()->GetID());
563 }
564 }
565 }
566
567 if (process_ids.size() >
568 (max_process_count * chrome::kMaxShareOfExtensionProcesses)) {
569 return true;
570 }
571
572 return false;
573}
574
[email protected]6f371442011-11-09 06:45:46575void ChromeContentBrowserClient::SiteInstanceGotProcess(
576 SiteInstance* site_instance) {
577 CHECK(site_instance->HasProcess());
578
579 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02580 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46581 ExtensionService* service = profile->GetExtensionService();
582 if (!service)
583 return;
584
585 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44586 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
[email protected]b6583592012-01-25 19:52:33587 site_instance->GetSite()));
[email protected]6f371442011-11-09 06:45:46588 if (!extension)
589 return;
590
[email protected]6bc04fd82011-12-04 02:29:35591 service->process_map()->Insert(extension->id(),
592 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33593 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46594 BrowserThread::PostTask(
595 BrowserThread::IO, FROM_HERE,
596 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
597 profile->GetExtensionInfoMap(),
598 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35599 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33600 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46601}
602
603void ChromeContentBrowserClient::SiteInstanceDeleting(
604 SiteInstance* site_instance) {
605 if (!site_instance->HasProcess())
606 return;
607
608 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02609 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46610 ExtensionService* service = profile->GetExtensionService();
611 if (!service)
612 return;
613
614 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44615 service->extensions()->GetExtensionOrAppByURL(
[email protected]b6583592012-01-25 19:52:33616 ExtensionURLInfo(site_instance->GetSite()));
[email protected]6f371442011-11-09 06:45:46617 if (!extension)
618 return;
619
[email protected]6bc04fd82011-12-04 02:29:35620 service->process_map()->Remove(extension->id(),
621 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33622 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46623 BrowserThread::PostTask(
624 BrowserThread::IO, FROM_HERE,
625 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
626 profile->GetExtensionInfoMap(),
627 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35628 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33629 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46630}
631
[email protected]e3daf3c2011-10-05 21:17:08632bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
633 const GURL& current_url,
634 const GURL& new_url) {
635 if (current_url.is_empty()) {
636 // Always choose a new process when navigating to extension URLs. The
637 // process grouping logic will combine all of a given extension's pages
638 // into the same process.
639 if (new_url.SchemeIs(chrome::kExtensionScheme))
640 return true;
641
642 return false;
643 }
644
645 // Also, we must switch if one is an extension and the other is not the exact
646 // same extension.
647 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
648 new_url.SchemeIs(chrome::kExtensionScheme)) {
649 if (current_url.GetOrigin() != new_url.GetOrigin())
650 return true;
651 }
652
653 return false;
654}
655
[email protected]763ec4ca2011-04-29 15:48:12656std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
657 const std::string& alias_name) {
658 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
659}
660
[email protected]b80f68432011-05-02 17:22:30661void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
662 CommandLine* command_line, int child_process_id) {
663#if defined(USE_LINUX_BREAKPAD)
664 if (IsCrashReporterEnabled()) {
665 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
666 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
667 }
668#elif defined(OS_MACOSX)
669 if (IsCrashReporterEnabled()) {
670 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
671 child_process_logging::GetClientId());
672 }
673#endif // OS_MACOSX
674
[email protected]f1933792011-06-14 00:49:34675 if (logging::DialogsAreSuppressed())
676 command_line->AppendSwitch(switches::kNoErrorDialogs);
677
[email protected]b80f68432011-05-02 17:22:30678 std::string process_type =
679 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:17680 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]718eab62011-10-05 21:16:52681 if (process_type == switches::kRendererProcess) {
[email protected]b80f68432011-05-02 17:22:30682 FilePath user_data_dir =
683 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
684 if (!user_data_dir.empty())
685 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
686#if defined(OS_CHROMEOS)
687 const std::string& login_profile =
688 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile);
689 if (!login_profile.empty())
690 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile);
691#endif
692
[email protected]f3b1a082011-11-18 00:34:30693 content::RenderProcessHost* process =
694 content::RenderProcessHost::FromID(child_process_id);
[email protected]a8d851f82011-12-21 00:32:37695 if (process) {
696 Profile* profile = Profile::FromBrowserContext(
697 process->GetBrowserContext());
698 extensions::ProcessMap* process_map =
699 profile->GetExtensionService()->process_map();
700 if (process_map && process_map->Contains(process->GetID()))
701 command_line->AppendSwitch(switches::kExtensionProcess);
[email protected]b80f68432011-05-02 17:22:30702
[email protected]a8d851f82011-12-21 00:32:37703 PrefService* prefs = profile->GetPrefs();
704 // Currently this pref is only registered if applied via a policy.
705 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
706 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
707 // Turn this policy into a command line switch.
708 command_line->AppendSwitch(switches::kDisable3DAPIs);
709 }
[email protected]718eab62011-10-05 21:16:52710
[email protected]a8d851f82011-12-21 00:32:37711 // Disable client-side phishing detection in the renderer if it is
712 // disabled in the Profile preferences or the browser process.
713 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
714 !g_browser_process->safe_browsing_detection_service()) {
715 command_line->AppendSwitch(
716 switches::kDisableClientSidePhishingDetection);
717 }
[email protected]8c40da62011-07-13 22:58:46718 }
[email protected]47c7ec82012-01-18 03:29:21719 {
720 PrefService* local_state = g_browser_process->local_state();
721 if (local_state &&
722 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) {
723 command_line->AppendSwitch(switches::kRendererPrintPreview);
724 }
725 }
[email protected]4287a3d2011-06-13 23:56:51726
[email protected]47c7ec82012-01-18 03:29:21727 // Please keep this in alphabetical order.
[email protected]4287a3d2011-06-13 23:56:51728 static const char* const kSwitchNames[] = {
729 switches::kAllowHTTPBackgroundPage,
[email protected]70f48c02011-12-02 21:27:48730 switches::kAllowLegacyExtensionManifests,
[email protected]4287a3d2011-06-13 23:56:51731 switches::kAllowScriptingGallery,
732 switches::kAppsCheckoutURL,
733 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:31734 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:51735 switches::kDebugPrint,
[email protected]382fb0d2012-02-25 00:19:50736 switches::kDisableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51737 switches::kDumpHistogramsOnExit,
[email protected]b7e44ff2012-02-16 03:37:34738 switches::kEnableAsynchronousSpellChecking,
[email protected]47c7ec82012-01-18 03:29:21739 switches::kEnableBenchmarking,
[email protected]b50368b2012-02-18 00:02:13740 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51741 switches::kEnableCrxlessWebApps,
742 switches::kEnableExperimentalExtensionApis,
743 switches::kEnableInBrowserThumbnailing,
744 switches::kEnableIPCFuzzing,
745 switches::kEnableNaCl,
[email protected]bcbe7652012-02-22 00:08:48746 switches::kEnablePasswordGeneration,
[email protected]9776e82e2011-11-15 02:17:53747 switches::kEnablePlatformApps,
[email protected]4287a3d2011-06-13 23:56:51748 switches::kEnableWatchdog,
749 switches::kExperimentalSpellcheckerFeatures,
750 switches::kMemoryProfiling,
751 switches::kMessageLoopHistogrammer,
[email protected]2a6bb0b12011-10-05 19:18:04752 switches::kNoRunningInsecureContent,
[email protected]4287a3d2011-06-13 23:56:51753 switches::kPpapiFlashArgs,
754 switches::kPpapiFlashInProcess,
755 switches::kPpapiFlashPath,
756 switches::kPpapiFlashVersion,
757 switches::kProfilingAtStart,
758 switches::kProfilingFile,
759 switches::kProfilingFlush,
[email protected]4287a3d2011-06-13 23:56:51760 switches::kSilentDumpOnDCHECK,
[email protected]a446534d2012-02-09 00:07:38761 switches::kWhitelistedExtensionID,
[email protected]4287a3d2011-06-13 23:56:51762 };
763
764 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
765 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17766 } else if (process_type == switches::kUtilityProcess) {
[email protected]a446534d2012-02-09 00:07:38767 static const char* const kSwitchNames[] = {
768 switches::kEnableExperimentalExtensionApis,
769 switches::kWhitelistedExtensionID,
770 };
771
772 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
773 arraysize(kSwitchNames));
[email protected]4287a3d2011-06-13 23:56:51774 } else if (process_type == switches::kPluginProcess) {
775 static const char* const kSwitchNames[] = {
776 #if defined(OS_CHROMEOS)
777 switches::kLoginProfile,
778 #endif
779 switches::kMemoryProfiling,
780 switches::kSilentDumpOnDCHECK,
781 switches::kUserDataDir,
782 };
783
784 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
785 arraysize(kSwitchNames));
786 } else if (process_type == switches::kZygoteProcess) {
787 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51788 switches::kUserDataDir, // Make logs go to the right file.
789 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
[email protected]382fb0d2012-02-25 00:19:50790 switches::kDisableBundledPpapiFlash,
[email protected]b50368b2012-02-18 00:02:13791 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51792 switches::kPpapiFlashInProcess,
793 switches::kPpapiFlashPath,
794 switches::kPpapiFlashVersion,
795 };
796
797 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
798 arraysize(kSwitchNames));
[email protected]d56ecf922012-02-15 16:03:11799 } else if (process_type == switches::kGpuProcess) {
800 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
801 // because GPU is expected to be unreliable.
802 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) &&
803 !command_line->HasSwitch(switches::kDisableBreakpad))
804 command_line->AppendSwitch(switches::kDisableBreakpad);
[email protected]b80f68432011-05-02 17:22:30805 }
[email protected]6f08af82011-09-15 01:19:03806
807 // The command line switch kEnableBenchmarking needs to be specified along
808 // with the kEnableStatsTable switch to ensure that the stats table global
809 // is initialized correctly.
810 if (command_line->HasSwitch(switches::kEnableBenchmarking))
811 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:30812}
813
814std::string ChromeContentBrowserClient::GetApplicationLocale() {
815 return g_browser_process->GetApplicationLocale();
816}
817
[email protected]597a867b2011-11-18 18:31:20818std::string ChromeContentBrowserClient::GetAcceptLangs(
819 content::BrowserContext* context) {
820 Profile* profile = Profile::FromBrowserContext(context);
[email protected]3d7474ff2011-07-27 17:47:37821 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:08822}
823
[email protected]ac55e292011-06-24 05:16:08824SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() {
[email protected]7c3228a2011-11-11 21:35:22825 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
[email protected]ac55e292011-06-24 05:16:08826 return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
827}
828
[email protected]a2176792011-05-08 19:30:49829bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:09830 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:19831 const GURL& first_party,
[email protected]df02aca2012-02-09 21:03:20832 content::ResourceContext* context) {
[email protected]8093a542011-05-13 07:29:32833 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20834 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05835 return io_data->GetCookieSettings()->
836 IsSettingCookieAllowed(manifest_url, first_party);
[email protected]a2176792011-05-08 19:30:49837}
838
[email protected]ed24fad2011-05-10 22:44:01839bool ChromeContentBrowserClient::AllowGetCookie(
840 const GURL& url,
841 const GURL& first_party,
842 const net::CookieList& cookie_list,
[email protected]df02aca2012-02-09 21:03:20843 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:01844 int render_process_id,
845 int render_view_id) {
846 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20847 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05848 bool allow = io_data->GetCookieSettings()->
849 IsReadingCookieAllowed(url, first_party);
[email protected]ed24fad2011-05-10 22:44:01850
[email protected]8093a542011-05-13 07:29:32851 BrowserThread::PostTask(
852 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:03853 base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
854 render_view_id, url, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:01855 return allow;
856}
857
858bool ChromeContentBrowserClient::AllowSetCookie(
859 const GURL& url,
860 const GURL& first_party,
861 const std::string& cookie_line,
[email protected]df02aca2012-02-09 21:03:20862 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:01863 int render_process_id,
864 int render_view_id,
865 net::CookieOptions* options) {
866 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20867 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05868 CookieSettings* cookie_settings = io_data->GetCookieSettings();
869 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
870
871 if (cookie_settings->IsCookieSessionOnly(url))
[email protected]5b52ad42011-05-26 14:26:09872 options->set_force_session();
[email protected]ed24fad2011-05-10 22:44:01873
[email protected]8093a542011-05-13 07:29:32874 BrowserThread::PostTask(
875 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:03876 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
877 render_view_id, url, cookie_line, *options, !allow));
[email protected]ed24fad2011-05-10 22:44:01878 return allow;
879}
880
[email protected]d5a19162011-06-30 18:51:54881bool ChromeContentBrowserClient::AllowSaveLocalState(
[email protected]df02aca2012-02-09 21:03:20882 content::ResourceContext* context) {
[email protected]d5a19162011-06-30 18:51:54883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20884 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]1848cdc2012-02-17 10:48:26885
886 if (!io_data->clear_local_state_on_exit()->GetValue())
887 return true;
888
[email protected]068b7b52012-02-27 12:41:44889 // Disable clearing the local state on exit if the browsing session is going
[email protected]1848cdc2012-02-17 10:48:26890 // to be restored on the next startup.
891 SessionStartupPref::Type startup_pref =
892 SessionStartupPref::PrefValueToType(
893 io_data->session_startup_pref()->GetValue());
894 return (startup_pref == SessionStartupPref::LAST &&
[email protected]068b7b52012-02-27 12:41:44895 !CommandLine::ForCurrentProcess()->HasSwitch(
896 switches::kDisableRestoreSessionState));
[email protected]d5a19162011-06-30 18:51:54897}
898
[email protected]5c5a88e2011-11-12 00:45:35899bool ChromeContentBrowserClient::AllowWorkerDatabase(
[email protected]5c5a88e2011-11-12 00:45:35900 const GURL& url,
901 const string16& name,
902 const string16& display_name,
903 unsigned long estimated_size,
[email protected]df02aca2012-02-09 21:03:20904 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:48905 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:35906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20907 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:35908 CookieSettings* cookie_settings = io_data->GetCookieSettings();
909 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
910
[email protected]62151052012-02-01 18:40:48911 // Record access to database for potential display in UI.
912 std::vector<std::pair<int, int> >::const_iterator i;
913 for (i = render_views.begin(); i != render_views.end(); ++i) {
914 BrowserThread::PostTask(
915 BrowserThread::UI, FROM_HERE,
916 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
917 i->first, i->second, url, name, display_name, !allow));
[email protected]5c5a88e2011-11-12 00:45:35918 }
919
920 return allow;
921}
922
923bool ChromeContentBrowserClient::AllowWorkerFileSystem(
[email protected]5c5a88e2011-11-12 00:45:35924 const GURL& url,
[email protected]df02aca2012-02-09 21:03:20925 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:48926 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:35927 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20928 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:35929 CookieSettings* cookie_settings = io_data->GetCookieSettings();
930 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
931
[email protected]62151052012-02-01 18:40:48932 // Record access to file system for potential display in UI.
933 std::vector<std::pair<int, int> >::const_iterator i;
934 for (i = render_views.begin(); i != render_views.end(); ++i) {
935 BrowserThread::PostTask(
936 BrowserThread::UI, FROM_HERE,
937 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
938 i->first, i->second, url, !allow));
[email protected]5c5a88e2011-11-12 00:45:35939 }
940
941 return allow;
942}
943
[email protected]7c5ff9a2012-03-02 07:42:49944bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
945 const GURL& url,
946 const string16& name,
947 content::ResourceContext* context,
948 const std::vector<std::pair<int, int> >& render_views) {
949 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
950 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
951 CookieSettings* cookie_settings = io_data->GetCookieSettings();
952 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
953
954 // Record access to IndexedDB for potential display in UI.
955 std::vector<std::pair<int, int> >::const_iterator i;
956 for (i = render_views.begin(); i != render_views.end(); ++i) {
957 BrowserThread::PostTask(
958 BrowserThread::UI, FROM_HERE,
959 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
960 i->first, i->second, url, name, !allow));
961 }
962
963 return allow;
964}
965
[email protected]6133f922011-07-01 21:34:34966net::URLRequestContext*
967ChromeContentBrowserClient::OverrideRequestContextForURL(
[email protected]df02aca2012-02-09 21:03:20968 const GURL& url, content::ResourceContext* context) {
[email protected]6133f922011-07-01 21:34:34969 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
970 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]df02aca2012-02-09 21:03:20971 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]6133f922011-07-01 21:34:34972 return io_data->extensions_request_context();
973 }
974
975 return NULL;
976}
977
[email protected]317f96c92011-05-31 06:53:41978QuotaPermissionContext*
979ChromeContentBrowserClient::CreateQuotaPermissionContext() {
980 return new ChromeQuotaPermissionContext();
981}
982
[email protected]a0ce3282011-08-19 20:49:52983void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:42984 platform_util::OpenItem(path);
[email protected]0609b17f2011-05-31 20:13:42985}
986
[email protected]a0ce3282011-08-19 20:49:52987void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
[email protected]a0ce3282011-08-19 20:49:52988 platform_util::ShowItemInFolder(path);
[email protected]a0ce3282011-08-19 20:49:52989}
990
[email protected]848dd042011-06-04 18:24:03991void ChromeContentBrowserClient::AllowCertificateError(
[email protected]4cf611e32012-02-13 16:06:17992 int render_process_id,
993 int render_view_id,
994 int cert_error,
995 const net::SSLInfo& ssl_info,
996 const GURL& request_url,
[email protected]848dd042011-06-04 18:24:03997 bool overridable,
[email protected]4cf611e32012-02-13 16:06:17998 const base::Callback<void(bool)>& callback,
999 bool* cancel_request) {
[email protected]f9034cf2011-07-21 12:43:411000 // If the tab is being prerendered, cancel the prerender and the request.
[email protected]83ff91c2012-01-05 20:54:131001 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]4cf611e32012-02-13 16:06:171002 render_process_id, render_view_id);
[email protected]f9034cf2011-07-21 12:43:411003 if (!tab) {
1004 NOTREACHED();
1005 return;
1006 }
1007 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:501008 prerender::PrerenderManagerFactory::GetForProfile(
[email protected]627e0512011-12-21 22:55:301009 Profile::FromBrowserContext(tab->GetBrowserContext()));
[email protected]ea049a02011-12-25 21:37:091010 if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab)) {
[email protected]f9034cf2011-07-21 12:43:411011 if (prerender_manager->prerender_tracker()->TryCancel(
[email protected]4cf611e32012-02-13 16:06:171012 render_process_id, render_view_id,
[email protected]f9034cf2011-07-21 12:43:411013 prerender::FINAL_STATUS_SSL_ERROR)) {
[email protected]4cf611e32012-02-13 16:06:171014 *cancel_request = true;
[email protected]f9034cf2011-07-21 12:43:411015 return;
1016 }
1017 }
1018
1019 // Otherwise, display an SSL blocking page.
[email protected]4cf611e32012-02-13 16:06:171020 new SSLBlockingPage(
1021 tab, cert_error, ssl_info, request_url, overridable, callback);
[email protected]848dd042011-06-04 18:24:031022}
1023
[email protected]c99c442e2011-08-24 11:37:301024void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:451025 int render_process_id,
1026 int render_view_id,
[email protected]7a593db2012-02-13 21:19:401027 const net::HttpNetworkSession* network_session,
1028 net::SSLCertRequestInfo* cert_request_info,
1029 const base::Callback<void(net::X509Certificate*)>& callback) {
[email protected]83ff91c2012-01-05 20:54:131030 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]8ec26472011-06-06 16:52:451031 render_process_id, render_view_id);
1032 if (!tab) {
1033 NOTREACHED();
1034 return;
1035 }
1036
[email protected]6786bf402011-12-03 15:19:451037 GURL requesting_url("https://" + cert_request_info->host_and_port);
1038 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
1039 << cert_request_info->host_and_port;
1040
[email protected]627e0512011-12-21 22:55:301041 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
[email protected]6786bf402011-12-03 15:19:451042 scoped_ptr<Value> filter(
1043 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1044 requesting_url,
1045 requesting_url,
1046 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1047 std::string(), NULL));
1048
1049 if (filter.get()) {
1050 // Try to automatically select a client certificate.
1051 if (filter->IsType(Value::TYPE_DICTIONARY)) {
1052 DictionaryValue* filter_dict =
1053 static_cast<DictionaryValue*>(filter.get());
1054
1055 const std::vector<scoped_refptr<net::X509Certificate> >&
1056 all_client_certs = cert_request_info->client_certs;
1057 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1058 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
1059 // Use the first certificate that is matched by the filter.
[email protected]7a593db2012-02-13 21:19:401060 callback.Run(all_client_certs[i]);
[email protected]6786bf402011-12-03 15:19:451061 return;
1062 }
1063 }
1064 } else {
1065 NOTREACHED();
1066 }
1067 }
1068
[email protected]8ec26472011-06-06 16:52:451069 TabContentsWrapper* wrapper =
1070 TabContentsWrapper::GetCurrentWrapperForContents(tab);
[email protected]6786bf402011-12-03 15:19:451071 if (!wrapper) {
[email protected]83ff91c2012-01-05 20:54:131072 // If there is no TabContentsWrapper for the given WebContents then we can't
[email protected]6786bf402011-12-03 15:19:451073 // show the user a dialog to select a client certificate. So we simply
[email protected]2a349e92011-12-07 12:00:141074 // proceed with no client certificate.
[email protected]7a593db2012-02-13 21:19:401075 callback.Run(NULL);
[email protected]6786bf402011-12-03 15:19:451076 return;
1077 }
[email protected]7a593db2012-02-13 21:19:401078 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(
1079 network_session, cert_request_info, callback);
[email protected]8ec26472011-06-06 16:52:451080}
1081
1082void ChromeContentBrowserClient::AddNewCertificate(
1083 net::URLRequest* request,
1084 net::X509Certificate* cert,
1085 int render_process_id,
1086 int render_view_id) {
1087 // The handler will run the UI and delete itself when it's finished.
1088 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
1089}
1090
[email protected]a93670ab2012-02-24 03:46:391091void ChromeContentBrowserClient::RequestMediaAccessPermission(
1092 const content::MediaStreamRequest* request,
1093 const content::MediaResponseCallback& callback) {
1094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1095
[email protected]117b6b42012-02-29 09:11:081096 WebContents* contents = tab_util::GetWebContentsByID(
1097 request->render_process_id, request->render_view_id);
1098 if (!contents) {
1099 // Abort, if the tab was closed after the request was made but before we
1100 // got to this point.
1101 callback.Run(content::MediaStreamDevices());
1102 return;
1103 }
1104
1105 TabContentsWrapper* tab =
1106 TabContentsWrapper::GetCurrentWrapperForContents(contents);
1107 DCHECK(tab);
1108
1109 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
1110 InfoBarDelegate* old_infobar = NULL;
1111 for (size_t i = 0; i < infobar_helper->infobar_count() && !old_infobar; ++i) {
1112 old_infobar =
1113 infobar_helper->GetInfoBarDelegateAt(i)->AsMediaStreamInfobarDelegate();
1114 }
1115
1116#if defined(TOOLKIT_VIEWS)
1117 InfoBarDelegate* infobar = new MediaStreamInfoBarDelegate(infobar_helper,
1118 request,
1119 callback);
1120 if (old_infobar)
1121 infobar_helper->ReplaceInfoBar(old_infobar, infobar);
1122 else
1123 infobar_helper->AddInfoBar(infobar);
1124#elif defined(OS_LINUX) || defined(OS_MACOSX)
1125 // TODO(macourteau): UI is not implemented yet for Linux and OS X. Fallback to
1126 // the default behaviour and allow access to the first device of each
1127 // requested type.
1128 content::MediaStreamDevices devices;
[email protected]a93670ab2012-02-24 03:46:391129 for (content::MediaStreamDeviceMap::const_iterator it =
1130 request->devices.begin(); it != request->devices.end(); ++it) {
[email protected]6c6415a2012-03-01 17:17:281131 if (!it->second.empty())
1132 devices.push_back(*it->second.begin());
[email protected]a93670ab2012-02-24 03:46:391133 }
1134
[email protected]a93670ab2012-02-24 03:46:391135 callback.Run(devices);
[email protected]117b6b42012-02-29 09:11:081136#endif // TOOLKIT_VIEWS
[email protected]a93670ab2012-02-24 03:46:391137}
1138
[email protected]941623e2011-06-07 23:06:041139void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1140 const GURL& source_origin,
1141 int callback_context,
1142 int render_process_id,
1143 int render_view_id) {
[email protected]5fd2e842012-03-01 00:29:111144#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041145 RenderViewHost* rvh = RenderViewHost::FromID(
1146 render_process_id, render_view_id);
1147 if (!rvh) {
1148 NOTREACHED();
1149 return;
1150 }
1151
[email protected]f3b1a082011-11-18 00:34:301152 content::RenderProcessHost* process = rvh->process();
1153 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041154 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371155 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041156 service->RequestPermission(
1157 source_origin, render_process_id, render_view_id, callback_context,
[email protected]83ff91c2012-01-05 20:54:131158 tab_util::GetWebContentsByID(render_process_id, render_view_id));
[email protected]5fd2e842012-03-01 00:29:111159#else
1160 NOTIMPLEMENTED();
1161#endif
[email protected]941623e2011-06-07 23:06:041162}
1163
1164WebKit::WebNotificationPresenter::Permission
1165 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
[email protected]34eec7ffe32011-11-02 23:49:021166 const GURL& source_origin,
[email protected]df02aca2012-02-09 21:03:201167 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021168 int render_process_id) {
[email protected]5fd2e842012-03-01 00:29:111169#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201171 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]34eec7ffe32011-11-02 23:49:021172 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1173 source_origin, render_process_id,
1174 ExtensionAPIPermission::kNotification))
[email protected]941623e2011-06-07 23:06:041175 return WebKit::WebNotificationPresenter::PermissionAllowed;
[email protected]941623e2011-06-07 23:06:041176
1177 // Fall back to the regular notification preferences, which works on an
1178 // origin basis.
1179 return io_data->GetNotificationService() ?
[email protected]c7df61b2011-11-07 22:06:371180 io_data->GetNotificationService()->HasPermission(source_origin) :
[email protected]941623e2011-06-07 23:06:041181 WebKit::WebNotificationPresenter::PermissionNotAllowed;
[email protected]5fd2e842012-03-01 00:29:111182#else
1183 return WebKit::WebNotificationPresenter::PermissionAllowed;
1184#endif
[email protected]941623e2011-06-07 23:06:041185}
1186
1187void ChromeContentBrowserClient::ShowDesktopNotification(
[email protected]0ee57e22011-11-12 01:59:171188 const content::ShowDesktopNotificationHostMsgParams& params,
[email protected]941623e2011-06-07 23:06:041189 int render_process_id,
1190 int render_view_id,
1191 bool worker) {
[email protected]5fd2e842012-03-01 00:29:111192#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041193 RenderViewHost* rvh = RenderViewHost::FromID(
1194 render_process_id, render_view_id);
1195 if (!rvh) {
1196 NOTREACHED();
1197 return;
1198 }
1199
[email protected]f3b1a082011-11-18 00:34:301200 content::RenderProcessHost* process = rvh->process();
1201 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041202 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371203 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041204 service->ShowDesktopNotification(
1205 params, render_process_id, render_view_id,
1206 worker ? DesktopNotificationService::WorkerNotification :
1207 DesktopNotificationService::PageNotification);
[email protected]5fd2e842012-03-01 00:29:111208#else
1209 NOTIMPLEMENTED();
1210#endif
[email protected]941623e2011-06-07 23:06:041211}
1212
1213void ChromeContentBrowserClient::CancelDesktopNotification(
1214 int render_process_id,
1215 int render_view_id,
1216 int notification_id) {
[email protected]5fd2e842012-03-01 00:29:111217#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041218 RenderViewHost* rvh = RenderViewHost::FromID(
1219 render_process_id, render_view_id);
1220 if (!rvh) {
1221 NOTREACHED();
1222 return;
1223 }
1224
[email protected]f3b1a082011-11-18 00:34:301225 content::RenderProcessHost* process = rvh->process();
1226 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041227 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371228 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041229 service->CancelDesktopNotification(
1230 render_process_id, render_view_id, notification_id);
[email protected]5fd2e842012-03-01 00:29:111231#else
1232 NOTIMPLEMENTED();
1233#endif
[email protected]941623e2011-06-07 23:06:041234}
1235
[email protected]9f3fba52011-06-08 20:37:191236bool ChromeContentBrowserClient::CanCreateWindow(
[email protected]34eec7ffe32011-11-02 23:49:021237 const GURL& source_origin,
[email protected]9f3fba52011-06-08 20:37:191238 WindowContainerType container_type,
[email protected]df02aca2012-02-09 21:03:201239 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021240 int render_process_id) {
[email protected]9f3fba52011-06-08 20:37:191241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1242 // If the opener is trying to create a background window but doesn't have
1243 // the appropriate permission, fail the attempt.
1244 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
[email protected]df02aca2012-02-09 21:03:201245 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]7b54ca02012-03-02 18:06:531246 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1247
1248 // If the opener is not allowed to script its background window, then return
1249 // false so that the window.open call returns null. In this case, only
1250 // the manifest is permitted to create a background window.
1251 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1252 // return a recently installed Extension even if this CanCreateWindow call
1253 // was made by an old copy of the page in a normal web process. That's ok,
1254 // because the permission check below will still fail.
1255 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
1256 ExtensionURLInfo(source_origin));
1257 if (extension && !extension->allow_background_js_access())
1258 return false;
1259
1260 return map->SecurityOriginHasAPIPermission(
[email protected]34eec7ffe32011-11-02 23:49:021261 source_origin, render_process_id, ExtensionAPIPermission::kBackground);
[email protected]9f3fba52011-06-08 20:37:191262 }
1263 return true;
1264}
1265
1266std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
[email protected]df02aca2012-02-09 21:03:201267 const GURL& url, content::ResourceContext* context) {
[email protected]9f3fba52011-06-08 20:37:191268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1269 // Check if it's an extension-created worker, in which case we want to use
1270 // the name of the extension.
[email protected]df02aca2012-02-09 21:03:201271 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]9f3fba52011-06-08 20:37:191272 const Extension* extension =
1273 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
1274 return extension ? extension->name() : std::string();
1275}
1276
[email protected]99907362012-01-11 05:41:401277void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1278 return g_browser_process->ResourceDispatcherHostCreated();
[email protected]3cb054e62011-06-13 05:21:171279}
1280
[email protected]66cfec62012-02-24 17:57:511281content::SpeechInputManagerDelegate*
1282 ChromeContentBrowserClient::GetSpeechInputManagerDelegate() {
1283 return new speech_input::ChromeSpeechInputManagerDelegate();
1284}
1285
[email protected]3cb054e62011-06-13 05:21:171286ui::Clipboard* ChromeContentBrowserClient::GetClipboard() {
1287 return g_browser_process->clipboard();
1288}
1289
[email protected]ae6e9912011-07-27 01:18:281290net::NetLog* ChromeContentBrowserClient::GetNetLog() {
1291 return g_browser_process->net_log();
1292}
1293
[email protected]32538d92011-08-25 00:09:231294AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
1295 return new ChromeAccessTokenStore();
1296}
1297
[email protected]dbae6b02011-06-29 23:51:411298bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1299 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1300 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1301}
1302
[email protected]64d69de42012-02-06 00:19:541303void ChromeContentBrowserClient::OverrideWebkitPrefs(
1304 RenderViewHost* rvh, WebPreferences* web_prefs) {
[email protected]f3986f82012-01-03 20:00:061305 Profile* profile = Profile::FromBrowserContext(
1306 rvh->process()->GetBrowserContext());
1307 PrefService* prefs = profile->GetPrefs();
[email protected]f3986f82012-01-03 20:00:061308
[email protected]64d69de42012-02-06 00:19:541309 web_prefs->standard_font_family =
[email protected]f3986f82012-01-03 20:00:061310 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
[email protected]64d69de42012-02-06 00:19:541311 web_prefs->fixed_font_family =
[email protected]f3986f82012-01-03 20:00:061312 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
[email protected]64d69de42012-02-06 00:19:541313 web_prefs->serif_font_family =
[email protected]f3986f82012-01-03 20:00:061314 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
[email protected]64d69de42012-02-06 00:19:541315 web_prefs->sans_serif_font_family =
[email protected]f3986f82012-01-03 20:00:061316 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
[email protected]64d69de42012-02-06 00:19:541317 web_prefs->cursive_font_family =
[email protected]f3986f82012-01-03 20:00:061318 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
[email protected]64d69de42012-02-06 00:19:541319 web_prefs->fantasy_font_family =
[email protected]f3986f82012-01-03 20:00:061320 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
1321
1322 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541323 &web_prefs->standard_font_family_map);
[email protected]f3986f82012-01-03 20:00:061324 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541325 &web_prefs->fixed_font_family_map);
[email protected]f3986f82012-01-03 20:00:061326 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541327 &web_prefs->serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061328 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541329 &web_prefs->sans_serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061330 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541331 &web_prefs->cursive_font_family_map);
[email protected]f3986f82012-01-03 20:00:061332 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541333 &web_prefs->fantasy_font_family_map);
[email protected]f3986f82012-01-03 20:00:061334
[email protected]64d69de42012-02-06 00:19:541335 web_prefs->default_font_size =
[email protected]f3986f82012-01-03 20:00:061336 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize);
[email protected]64d69de42012-02-06 00:19:541337 web_prefs->default_fixed_font_size =
[email protected]f3986f82012-01-03 20:00:061338 prefs->GetInteger(prefs::kWebKitGlobalDefaultFixedFontSize);
[email protected]64d69de42012-02-06 00:19:541339 web_prefs->minimum_font_size =
[email protected]f3986f82012-01-03 20:00:061340 prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize);
[email protected]64d69de42012-02-06 00:19:541341 web_prefs->minimum_logical_font_size =
[email protected]f3986f82012-01-03 20:00:061342 prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize);
1343
[email protected]64d69de42012-02-06 00:19:541344 web_prefs->default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061345
[email protected]64d69de42012-02-06 00:19:541346 web_prefs->javascript_can_open_windows_automatically =
[email protected]f3986f82012-01-03 20:00:061347 prefs->GetBoolean(
1348 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically);
[email protected]64d69de42012-02-06 00:19:541349 web_prefs->dom_paste_enabled =
[email protected]f3986f82012-01-03 20:00:061350 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
[email protected]64d69de42012-02-06 00:19:541351 web_prefs->shrinks_standalone_images_to_fit =
[email protected]f3986f82012-01-03 20:00:061352 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
1353 const DictionaryValue* inspector_settings =
1354 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
1355 if (inspector_settings) {
1356 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys());
1357 iter != inspector_settings->end_keys(); ++iter) {
1358 std::string value;
1359 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value))
[email protected]64d69de42012-02-06 00:19:541360 web_prefs->inspector_settings.push_back(
[email protected]f3986f82012-01-03 20:00:061361 std::make_pair(*iter, value));
1362 }
1363 }
[email protected]64d69de42012-02-06 00:19:541364 web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
[email protected]f3986f82012-01-03 20:00:061365
[email protected]64d69de42012-02-06 00:19:541366 if (!prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled))
1367 web_prefs->javascript_enabled = false;
1368 if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled))
1369 web_prefs->web_security_enabled = false;
1370 if (!prefs->GetBoolean(prefs::kWebKitGlobalPluginsEnabled))
1371 web_prefs->plugins_enabled = false;
1372 if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled))
1373 web_prefs->java_enabled = false;
1374 web_prefs->loads_images_automatically =
1375 prefs->GetBoolean(prefs::kWebKitGlobalLoadsImagesAutomatically);
[email protected]f3986f82012-01-03 20:00:061376
[email protected]64d69de42012-02-06 00:19:541377 if (prefs->GetBoolean(prefs::kDisable3DAPIs))
1378 web_prefs->experimental_webgl_enabled = false;
[email protected]f3986f82012-01-03 20:00:061379
[email protected]64d69de42012-02-06 00:19:541380 web_prefs->memory_info_enabled =
1381 prefs->GetBoolean(prefs::kEnableMemoryInfo);
1382 web_prefs->allow_displaying_insecure_content =
1383 prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
1384 web_prefs->allow_running_insecure_content =
1385 prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
[email protected]9d06d88d2012-02-23 22:37:081386 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
[email protected]f3986f82012-01-03 20:00:061387
[email protected]64d69de42012-02-06 00:19:541388 // The user stylesheet watcher may not exist in a testing profile.
1389 if (profile->GetUserStyleSheetWatcher()) {
1390 web_prefs->user_style_sheet_enabled = true;
1391 web_prefs->user_style_sheet_location =
1392 profile->GetUserStyleSheetWatcher()->user_style_sheet();
1393 } else {
1394 web_prefs->user_style_sheet_enabled = false;
[email protected]f3986f82012-01-03 20:00:061395 }
1396
[email protected]b7e44ff2012-02-16 03:37:341397 web_prefs->asynchronous_spell_checking_enabled =
1398 CommandLine::ForCurrentProcess()->
1399 HasSwitch(switches::kEnableAsynchronousSpellChecking);
1400 web_prefs->unified_textchecker_enabled =
1401 web_prefs->asynchronous_spell_checking_enabled ||
1402 CommandLine::ForCurrentProcess()->
1403 HasSwitch(switches::kExperimentalSpellcheckerFeatures);
[email protected]dd5d0fb2012-01-18 03:37:571404
[email protected]64d69de42012-02-06 00:19:541405 web_prefs->uses_universal_detector =
[email protected]f3986f82012-01-03 20:00:061406 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);
[email protected]64d69de42012-02-06 00:19:541407 web_prefs->text_areas_are_resizable =
[email protected]f3986f82012-01-03 20:00:061408 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
[email protected]64d69de42012-02-06 00:19:541409 web_prefs->hyperlink_auditing_enabled =
[email protected]f3986f82012-01-03 20:00:061410 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
1411
1412 // Make sure we will set the default_encoding with canonical encoding name.
[email protected]64d69de42012-02-06 00:19:541413 web_prefs->default_encoding =
[email protected]f3986f82012-01-03 20:00:061414 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
[email protected]64d69de42012-02-06 00:19:541415 web_prefs->default_encoding);
1416 if (web_prefs->default_encoding.empty()) {
[email protected]f3986f82012-01-03 20:00:061417 prefs->ClearPref(prefs::kGlobalDefaultCharset);
[email protected]64d69de42012-02-06 00:19:541418 web_prefs->default_encoding =
1419 prefs->GetString(prefs::kGlobalDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061420 }
[email protected]64d69de42012-02-06 00:19:541421 DCHECK(!web_prefs->default_encoding.empty());
[email protected]f3986f82012-01-03 20:00:061422
1423 ExtensionService* service = profile->GetExtensionService();
1424 if (service) {
1425 const Extension* extension = service->extensions()->GetByID(
[email protected]b6583592012-01-25 19:52:331426 rvh->site_instance()->GetSite().host());
[email protected]f3986f82012-01-03 20:00:061427 extension_webkit_preferences::SetPreferences(
[email protected]64d69de42012-02-06 00:19:541428 extension, rvh->delegate()->GetRenderViewType(), web_prefs);
[email protected]f3986f82012-01-03 20:00:061429 }
1430
1431 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) {
[email protected]64d69de42012-02-06 00:19:541432 web_prefs->allow_scripts_to_close_windows = true;
[email protected]f3986f82012-01-03 20:00:061433 } else if (rvh->delegate()->GetRenderViewType() ==
1434 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1435 // Disable all kinds of acceleration for background pages.
1436 // See http://crbug.com/96005 and http://crbug.com/96006
[email protected]64d69de42012-02-06 00:19:541437 web_prefs->force_compositing_mode = false;
1438 web_prefs->accelerated_compositing_enabled = false;
1439 web_prefs->accelerated_2d_canvas_enabled = false;
1440 web_prefs->accelerated_video_enabled = false;
1441 web_prefs->accelerated_painting_enabled = false;
1442 web_prefs->accelerated_plugins_enabled = false;
[email protected]f3986f82012-01-03 20:00:061443 }
[email protected]181a95ee2011-07-12 19:26:361444}
1445
1446void ChromeContentBrowserClient::UpdateInspectorSetting(
1447 RenderViewHost* rvh, const std::string& key, const std::string& value) {
[email protected]f3986f82012-01-03 20:00:061448 content::BrowserContext* browser_context =
1449 rvh->process()->GetBrowserContext();
1450 DictionaryPrefUpdate update(
1451 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1452 prefs::kWebKitInspectorSettings);
1453 DictionaryValue* inspector_settings = update.Get();
1454 inspector_settings->SetWithoutPathExpansion(key,
1455 Value::CreateStringValue(value));
[email protected]181a95ee2011-07-12 19:26:361456}
1457
1458void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
[email protected]f3986f82012-01-03 20:00:061459 content::BrowserContext* browser_context =
1460 rvh->process()->GetBrowserContext();
1461 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1462 ClearPref(prefs::kWebKitInspectorSettings);
[email protected]181a95ee2011-07-12 19:26:361463}
1464
[email protected]b8148ac2011-07-13 22:03:251465void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1466 BrowserURLHandler* handler) {
1467 // Add the default URL handlers.
1468 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1469 BrowserURLHandler::null_handler());
1470 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1471 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1472
[email protected]b3adbd02011-11-30 22:23:271473 // about: handler. Must come before chrome: handler, since it will
1474 // rewrite about: urls to chrome: URLs and then expect chrome: to
1475 // actually handle them.
[email protected]b8148ac2011-07-13 22:03:251476 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1477 BrowserURLHandler::null_handler());
1478 // chrome: & friends.
1479 handler->AddHandlerPair(&HandleWebUI,
1480 BrowserURLHandler::null_handler());
1481}
1482
1483void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371484 Profile* profile = Profile::FromBrowserContext(
[email protected]f3b1a082011-11-18 00:34:301485 rvh->site_instance()->GetProcess()->GetBrowserContext());
[email protected]b8148ac2011-07-13 22:03:251486 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1487 BrowsingDataRemover::EVERYTHING,
1488 base::Time());
1489 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
1490 // BrowsingDataRemover takes care of deleting itself when done.
1491}
1492
1493void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371494 Profile* profile = Profile::FromBrowserContext(
[email protected]f3b1a082011-11-18 00:34:301495 rvh->site_instance()->GetProcess()->GetBrowserContext());
[email protected]b8148ac2011-07-13 22:03:251496 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1497 BrowsingDataRemover::EVERYTHING,
1498 base::Time());
[email protected]dceaa912011-09-06 17:17:231499 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]b8148ac2011-07-13 22:03:251500 remover->Remove(remove_mask);
1501 // BrowsingDataRemover takes care of deleting itself when done.
1502}
1503
[email protected]e1d16eb92011-08-18 23:19:321504FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1505 return download_util::GetDefaultDownloadDirectory();
1506}
1507
[email protected]c9b6eb62011-10-18 20:49:391508std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
1509 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
1510}
1511
[email protected]a658d452012-03-02 12:45:291512bool ChromeContentBrowserClient::AllowSocketAPI(
1513 content::BrowserContext* browser_context, const GURL& url) {
1514 if (!url.is_valid())
1515 return false;
1516
1517 std::string host = url.host();
1518 if (allowed_socket_origins_.count(host))
1519 return true;
1520
1521 Profile* profile = Profile::FromBrowserContext(browser_context);
1522 if (!profile || !profile->GetExtensionService())
1523 return false;
1524
1525 const Extension* extension = profile->GetExtensionService()->extensions()->
1526 GetExtensionOrAppByURL(ExtensionURLInfo(url));
1527 if (!extension)
1528 return false;
1529
1530 if (extension->HasAPIPermission(ExtensionAPIPermission::kSocket))
1531 return true;
1532
1533 return false;
[email protected]e461da2f2012-02-16 19:06:401534}
1535
[email protected]e60c0232011-11-11 19:56:351536#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301537int ChromeContentBrowserClient::GetCrashSignalFD(
[email protected]718eab62011-10-05 21:16:521538 const CommandLine& command_line) {
[email protected]6e677a342012-02-11 01:21:141539#if defined(OS_ANDROID)
1540 // TODO(carlosvaldivia): Upstream breakpad code for Android and remove this
1541 // fork. http://crbug.com/113560
1542 NOTIMPLEMENTED();
1543#else
[email protected]718eab62011-10-05 21:16:521544 if (command_line.HasSwitch(switches::kExtensionProcess)) {
[email protected]9dbfff12011-07-01 19:37:071545 ExtensionCrashHandlerHostLinux* crash_handler =
1546 ExtensionCrashHandlerHostLinux::GetInstance();
1547 return crash_handler->GetDeathSignalSocket();
1548 }
1549
[email protected]718eab62011-10-05 21:16:521550 std::string process_type =
1551 command_line.GetSwitchValueASCII(switches::kProcessType);
1552
1553 if (process_type == switches::kRendererProcess)
1554 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1555
[email protected]b80f68432011-05-02 17:22:301556 if (process_type == switches::kPluginProcess)
1557 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1558
1559 if (process_type == switches::kPpapiPluginProcess)
1560 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1561
1562 if (process_type == switches::kGpuProcess)
1563 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
[email protected]6e677a342012-02-11 01:21:141564#endif // defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:301565
1566 return -1;
1567}
[email protected]e60c0232011-11-11 19:56:351568#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301569
[email protected]4a65826d2011-08-25 16:04:011570#if defined(OS_WIN)
1571const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
1572 return chrome::kBrowserResourcesDll;
1573}
1574#endif
1575
[email protected]37a72af2011-06-13 05:42:011576#if defined(USE_NSS)
1577crypto::CryptoModuleBlockingPasswordDelegate*
1578 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1579 const GURL& url) {
1580 return browser::NewCryptoModuleBlockingDialogDelegate(
1581 browser::kCryptoModulePasswordKeygen, url.host());
1582}
1583#endif
1584
[email protected]d977f9c2011-03-14 16:10:261585} // namespace chrome