blob: a383c37bb30ad3bebffaacb54d5e0d8edbce7e26 [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]0288f652012-02-29 10:02:50100#include "chrome/browser/chromeos/login/user_manager.h"
[email protected]e60c0232011-11-11 19:56:35101#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]b48c9182011-10-26 18:03:30102#include "chrome/browser/chrome_browser_main_linux.h"
103#elif defined(OS_POSIX)
104#include "chrome/browser/chrome_browser_main_posix.h"
105#endif
106
[email protected]b48c9182011-10-26 18:03:30107#if defined(TOOLKIT_USES_GTK)
[email protected]50462bf02011-11-21 19:13:31108#include "chrome/browser/chrome_browser_main_extra_parts_gtk.h"
[email protected]199fc7a2011-09-28 22:45:38109#endif
110
[email protected]c7480942011-11-08 19:18:27111#if defined(TOOLKIT_VIEWS)
[email protected]50462bf02011-11-21 19:13:31112#include "chrome/browser/chrome_browser_main_extra_parts_views.h"
[email protected]c7480942011-11-08 19:18:27113#endif
114
115#if defined(USE_AURA)
[email protected]50462bf02011-11-21 19:13:31116#include "chrome/browser/chrome_browser_main_extra_parts_aura.h"
117#endif
118
[email protected]e60c0232011-11-11 19:56:35119#if defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]b80f68432011-05-02 17:22:30120#include "base/linux_util.h"
121#include "chrome/browser/crash_handler_host_linux.h"
[email protected]1fd5302c2011-05-28 04:06:43122#endif
[email protected]b80f68432011-05-02 17:22:30123
[email protected]080f34f2011-09-20 05:39:26124#if defined(TOOLKIT_VIEWS)
[email protected]74313b42011-08-24 16:51:32125#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
[email protected]c92f4ed2011-10-21 19:50:21126#elif defined(TOOLKIT_USES_GTK)
[email protected]9bce7772011-11-16 01:24:45127#include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h"
[email protected]90580422012-01-12 00:26:22128#include "content/browser/tab_contents/tab_contents_view_gtk.h"
[email protected]74313b42011-08-24 16:51:32129#elif defined(OS_MACOSX)
[email protected]cce3ab72012-02-04 18:05:16130#include "chrome/browser/tab_contents/chrome_web_contents_view_mac_delegate.h"
[email protected]eb668c92012-02-06 15:35:29131#include "content/browser/tab_contents/web_contents_view_mac.h"
[email protected]6e677a342012-02-11 01:21:14132#elif defined(OS_ANDROID)
[email protected]82c9f44b2012-02-14 21:02:52133#include "content/browser/tab_contents/web_contents_view_android.h"
[email protected]74313b42011-08-24 16:51:32134#endif
135
[email protected]37a72af2011-06-13 05:42:01136#if defined(USE_NSS)
137#include "chrome/browser/ui/crypto_module_password_dialog.h"
138#endif
139
[email protected]c8c77182011-12-21 15:04:47140using content::AccessTokenStore;
[email protected]631bb742011-11-02 11:29:39141using content::BrowserThread;
[email protected]b9535422012-02-09 01:47:59142using content::ChildProcessSecurityPolicy;
[email protected]b6583592012-01-25 19:52:33143using content::SiteInstance;
[email protected]83ff91c2012-01-05 20:54:13144using content::WebContents;
[email protected]631bb742011-11-02 11:29:39145
[email protected]c5dbef02011-05-13 05:06:09146namespace {
147
[email protected]e461da2f2012-02-16 19:06:40148const char* kPredefinedAllowedSocketOrigins[] = {
149 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
150 "pnhechapfaindjhompbnflcldabbghjo" // HTerm App (SSH Client)
151};
152
[email protected]b8148ac2011-07-13 22:03:25153// Handles rewriting Web UI URLs.
[email protected]8d3132f62011-10-12 07:13:42154bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
[email protected]863f70a2012-01-27 02:05:50155 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
156 browser_context, *url))
[email protected]b8148ac2011-07-13 22:03:25157 return false;
158
[email protected]0288f652012-02-29 10:02:50159#if defined(OS_CHROMEOS)
160 // Special case : in ChromeOS in Guest mode bookmarks and history are
161 // disabled for security reasons. New tab page explains the reasons, so
162 // we redirect user to new tab page.
163 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
164 if (url->SchemeIs(chrome::kChromeUIScheme) &&
165 (url->DomainIs(chrome::kChromeUIBookmarksHost) ||
166 url->DomainIs(chrome::kChromeUIHistoryHost))) {
167 // Rewrite with new tab URL
168 *url = GURL(chrome::kChromeUINewTabURL);
169 }
170 }
171#endif
172
[email protected]b8148ac2011-07-13 22:03:25173 // Special case the new tab page. In older versions of Chrome, the new tab
174 // page was hosted at chrome-internal:<blah>. This might be in people's saved
175 // sessions or bookmarks, so we say any URL with that scheme triggers the new
176 // tab page.
177 if (url->SchemeIs(chrome::kChromeInternalScheme)) {
178 // Rewrite it with the proper new tab URL.
179 *url = GURL(chrome::kChromeUINewTabURL);
180 }
181
182 return true;
183}
184
[email protected]8d3132f62011-10-12 07:13:42185// Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
186// below. Extension, and isolated apps require different privileges to be
187// granted to their RenderProcessHosts. This classification allows us to make
188// sure URLs are served by hosts with the right set of privileges.
189enum RenderProcessHostPrivilege {
190 PRIV_NORMAL,
[email protected]eec0b33c2011-12-05 22:09:45191 PRIV_HOSTED,
[email protected]8d3132f62011-10-12 07:13:42192 PRIV_ISOLATED,
[email protected]eec0b33c2011-12-05 22:09:45193 PRIV_EXTENSION,
[email protected]8d3132f62011-10-12 07:13:42194};
195
196RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
197 const GURL& url,
198 ExtensionService* service) {
199 // Default to a normal renderer cause it is lower privileged. This should only
200 // occur if the URL on a site instance is either malformed, or uninitialized.
201 // If it is malformed, then there is no need for better privileges anyways.
202 // If it is uninitialized, but eventually settles on being an a scheme other
203 // than normal webrenderer, the navigation logic will correct us out of band
204 // anyways.
205 if (!url.is_valid())
206 return PRIV_NORMAL;
207
208 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]615d88f2011-12-13 01:47:44209 const Extension* extension =
210 service->extensions()->GetByID(url.host());
[email protected]eec0b33c2011-12-05 22:09:45211 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42212 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45213 if (extension && extension->is_hosted_app())
214 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42215
216 return PRIV_EXTENSION;
217 }
218
219 return PRIV_NORMAL;
220}
221
222RenderProcessHostPrivilege GetProcessPrivilege(
[email protected]f3b1a082011-11-18 00:34:30223 content::RenderProcessHost* process_host,
[email protected]6f371442011-11-09 06:45:46224 extensions::ProcessMap* process_map,
225 ExtensionService* service) {
[email protected]6f371442011-11-09 06:45:46226 std::set<std::string> extension_ids =
[email protected]f3b1a082011-11-18 00:34:30227 process_map->GetExtensionsInProcess(process_host->GetID());
[email protected]6f371442011-11-09 06:45:46228 if (extension_ids.empty())
[email protected]676f6ab2011-10-19 20:23:21229 return PRIV_NORMAL;
230
[email protected]6f371442011-11-09 06:45:46231 for (std::set<std::string>::iterator iter = extension_ids.begin();
232 iter != extension_ids.end(); ++iter) {
233 const Extension* extension = service->GetExtensionById(*iter, false);
234 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42235 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45236 if (extension && extension->is_hosted_app())
237 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42238 }
239
[email protected]676f6ab2011-10-19 20:23:21240 return PRIV_EXTENSION;
[email protected]8d3132f62011-10-12 07:13:42241}
242
[email protected]eec0b33c2011-12-05 22:09:45243bool IsIsolatedAppInProcess(const GURL& site_url,
244 content::RenderProcessHost* process_host,
245 extensions::ProcessMap* process_map,
246 ExtensionService* service) {
247 std::set<std::string> extension_ids =
248 process_map->GetExtensionsInProcess(process_host->GetID());
249 if (extension_ids.empty())
250 return false;
251
252 for (std::set<std::string>::iterator iter = extension_ids.begin();
253 iter != extension_ids.end(); ++iter) {
254 const Extension* extension = service->GetExtensionById(*iter, false);
255 if (extension &&
256 extension->is_storage_isolated() &&
257 extension->url() == site_url)
258 return true;
259 }
260
261 return false;
262}
263
[email protected]6786bf402011-12-03 15:19:45264bool CertMatchesFilter(const net::X509Certificate& cert,
265 const base::DictionaryValue& filter) {
266 // TODO(markusheintz): This is the minimal required filter implementation.
267 // Implement a better matcher.
268
269 // An empty filter matches any client certificate since no requirements are
270 // specified at all.
271 if (filter.empty())
272 return true;
273
274 std::string common_name;
275 if (filter.GetString("ISSUER.CN", &common_name) &&
276 (cert.issuer().common_name == common_name)) {
277 return true;
278 }
279 return false;
280}
281
[email protected]f3986f82012-01-03 20:00:06282// Fills |map| with the per-script font prefs under path |map_name|.
283void FillFontFamilyMap(const PrefService* prefs,
284 const char* map_name,
285 WebPreferences::ScriptFontFamilyMap* map) {
286 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
287 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
288 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
289 std::string font_family = prefs->GetString(pref_name.c_str());
290 if (!font_family.empty())
291 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
292 }
293}
294
[email protected]9dbfff12011-07-01 19:37:07295} // namespace
[email protected]c5dbef02011-05-13 05:06:09296
[email protected]d977f9c2011-03-14 16:10:26297namespace chrome {
298
[email protected]e461da2f2012-02-16 19:06:40299ChromeContentBrowserClient::ChromeContentBrowserClient() {
300 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
301 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
302
303 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
304 std::string allowed_list =
305 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
306 if (!allowed_list.empty()) {
307 StringTokenizer t(allowed_list, ",");
308 while (t.GetNext()) {
309 allowed_socket_origins_.insert(t.token());
310 }
311 }
312}
313
314ChromeContentBrowserClient::~ChromeContentBrowserClient() {
315}
316
[email protected]50462bf02011-11-21 19:13:31317content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
318 const content::MainFunctionParams& parameters) {
319 ChromeBrowserMainParts* main_parts;
[email protected]b48c9182011-10-26 18:03:30320 // Construct the Main browser parts based on the OS type.
321#if defined(OS_WIN)
[email protected]50462bf02011-11-21 19:13:31322 main_parts = new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04323#elif defined(OS_MACOSX)
[email protected]50462bf02011-11-21 19:13:31324 main_parts = new ChromeBrowserMainPartsMac(parameters);
[email protected]b48c9182011-10-26 18:03:30325#elif defined(OS_CHROMEOS)
[email protected]50462bf02011-11-21 19:13:31326 main_parts = new ChromeBrowserMainPartsChromeos(parameters);
[email protected]e60c0232011-11-11 19:56:35327#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]50462bf02011-11-21 19:13:31328 main_parts = new ChromeBrowserMainPartsLinux(parameters);
[email protected]6e677a342012-02-11 01:21:14329#elif defined(OS_ANDROID)
330 // Do nothing for Android.
331 // TODO(klobag): Android initialization should use the
332 // *BrowserMainParts class-hierarchy for setting up custom initialization.
333 main_parts = NULL;
[email protected]b48c9182011-10-26 18:03:30334#elif defined(OS_POSIX)
[email protected]50462bf02011-11-21 19:13:31335 main_parts = new ChromeBrowserMainPartsPosix(parameters);
[email protected]f967b722011-09-07 00:58:04336#else
[email protected]b48c9182011-10-26 18:03:30337 NOTREACHED();
[email protected]50462bf02011-11-21 19:13:31338 main_parts = new ChromeBrowserMainParts(parameters);
[email protected]b48c9182011-10-26 18:03:30339#endif
340
[email protected]c7480942011-11-08 19:18:27341 // Construct additional browser parts. Stages are called in the order in
342 // which they are added.
[email protected]b48c9182011-10-26 18:03:30343#if defined(TOOLKIT_USES_GTK)
[email protected]50462bf02011-11-21 19:13:31344 main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk());
[email protected]f967b722011-09-07 00:58:04345#endif
[email protected]c7480942011-11-08 19:18:27346
347#if defined(TOOLKIT_VIEWS)
[email protected]50462bf02011-11-21 19:13:31348 main_parts->AddParts(new ChromeBrowserMainExtraPartsViews());
[email protected]c7480942011-11-08 19:18:27349#endif
350
351#if defined(USE_AURA)
[email protected]50462bf02011-11-21 19:13:31352 main_parts->AddParts(new ChromeBrowserMainExtraPartsAura());
[email protected]c7480942011-11-08 19:18:27353#endif
354
[email protected]50462bf02011-11-21 19:13:31355 return main_parts;
[email protected]f967b722011-09-07 00:58:04356}
357
[email protected]8643e6d2012-01-18 20:26:10358content::WebContentsView* ChromeContentBrowserClient::CreateWebContentsView(
[email protected]8dad546b2012-01-17 21:47:35359 WebContents* web_contents) {
[email protected]080f34f2011-09-20 05:39:26360#if defined(TOOLKIT_VIEWS)
[email protected]8dad546b2012-01-17 21:47:35361 return new TabContentsViewViews(web_contents);
[email protected]c92f4ed2011-10-21 19:50:21362#elif defined(TOOLKIT_USES_GTK)
[email protected]8dad546b2012-01-17 21:47:35363 return new content::TabContentsViewGtk(web_contents,
[email protected]90580422012-01-12 00:26:22364 new ChromeTabContentsViewWrapperGtk);
[email protected]74313b42011-08-24 16:51:32365#elif defined(OS_MACOSX)
[email protected]eb668c92012-02-06 15:35:29366 return web_contents_view_mac::CreateWebContentsView(
[email protected]cce3ab72012-02-04 18:05:16367 web_contents,
368 chrome_web_contents_view_mac_delegate::CreateWebContentsViewMacDelegate(
369 web_contents));
[email protected]6e677a342012-02-11 01:21:14370#elif defined(OS_ANDROID)
[email protected]82c9f44b2012-02-14 21:02:52371 return new WebContentsViewAndroid(web_contents);
[email protected]74313b42011-08-24 16:51:32372#else
[email protected]8643e6d2012-01-18 20:26:10373#error Need to create your platform WebContentsView here.
[email protected]74313b42011-08-24 16:51:32374#endif
375}
376
[email protected]f364d1392011-04-08 21:03:10377void ChromeContentBrowserClient::RenderViewHostCreated(
378 RenderViewHost* render_view_host) {
[email protected]67372ecf2011-09-10 01:30:46379
380 SiteInstance* site_instance = render_view_host->site_instance();
381 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02382 site_instance->GetBrowserContext());
[email protected]67372ecf2011-09-10 01:30:46383
384 new ChromeRenderViewHostObserver(render_view_host,
385 profile->GetNetworkPredictor());
[email protected]f364d1392011-04-08 21:03:10386 new ExtensionMessageHandler(render_view_host);
[email protected]85f0a572012-02-07 22:20:13387
388 if (render_view_host->delegate()->GetRenderViewType() ==
389 content::VIEW_TYPE_INTERSTITIAL_PAGE) {
390 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial(
391 render_view_host->routing_id()));
392 }
[email protected]d977f9c2011-03-14 16:10:26393}
394
[email protected]f3b1a082011-11-18 00:34:30395void ChromeContentBrowserClient::RenderProcessHostCreated(
396 content::RenderProcessHost* host) {
397 int id = host->GetID();
398 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
399 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]c47cfd62011-04-29 21:27:02400 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]f3b1a082011-11-18 00:34:30401 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
402 host->GetChannel()->AddFilter(new PrintingMessageFilter());
403 host->GetChannel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02404 new SearchProviderInstallStateMessageFilter(id, profile));
[email protected]f3b1a082011-11-18 00:34:30405 host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]7ceb99012011-12-21 08:05:56406#if defined(OS_MACOSX)
407 host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac());
408#endif
[email protected]f3b1a082011-11-18 00:34:30409 host->GetChannel()->AddFilter(new ChromeBenchmarkingMessageFilter(
[email protected]6f08af82011-09-15 01:19:03410 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]3e69bc82011-05-26 23:22:38411
[email protected]2ccf45c2011-08-19 23:35:50412 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
413 profile->IsOffTheRecord()));
[email protected]39a5b532011-10-22 01:47:07414
415 SendExtensionWebRequestStatusToHost(host);
[email protected]edece212011-11-16 11:56:56416
417 RendererContentSettingRules rules;
418 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules);
419 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
[email protected]05fcf982011-04-19 00:44:14420}
421
[email protected]863f70a2012-01-27 02:05:50422content::WebUIControllerFactory*
423 ChromeContentBrowserClient::GetWebUIControllerFactory() {
424 return ChromeWebUIControllerFactory::GetInstance();
[email protected]1fd1a502011-03-30 16:55:56425}
426
[email protected]3d7474ff2011-07-27 17:47:37427GURL ChromeContentBrowserClient::GetEffectiveURL(
428 content::BrowserContext* browser_context, const GURL& url) {
429 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]36fb2c7c2011-04-04 15:49:08430 // Get the effective URL for the given actual URL. If the URL is part of an
431 // installed app, the effective URL is an extension URL with the ID of that
432 // extension as the host. This has the effect of grouping apps together in
433 // a common SiteInstance.
434 if (!profile || !profile->GetExtensionService())
435 return url;
436
[email protected]615d88f2011-12-13 01:47:44437 const Extension* extension = profile->GetExtensionService()->extensions()->
438 GetHostedAppByURL(ExtensionURLInfo(url));
[email protected]36fb2c7c2011-04-04 15:49:08439 if (!extension)
440 return url;
441
[email protected]15877ca2011-11-18 22:40:52442 // Bookmark apps do not use the hosted app process model, and should be
443 // treated as normal URLs.
444 if (extension->from_bookmark())
445 return url;
446
[email protected]36fb2c7c2011-04-04 15:49:08447 // If the URL is part of an extension's web extent, convert it to an
448 // extension URL.
449 return extension->GetResourceURL(url.path());
450}
451
[email protected]056ad2a2011-07-12 02:13:55452bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37453 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]056ad2a2011-07-12 02:13:55454 // Non-extension URLs should generally use process-per-site-instance.
[email protected]15877ca2011-11-18 22:40:52455 // Because we expect to use the effective URL, URLs for hosted apps (apart
456 // from bookmark apps) should have an extension scheme by now.
[email protected]056ad2a2011-07-12 02:13:55457 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
458 return false;
459
[email protected]3d7474ff2011-07-27 17:47:37460 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]056ad2a2011-07-12 02:13:55461 if (!profile || !profile->GetExtensionService())
462 return false;
463
[email protected]615d88f2011-12-13 01:47:44464 const Extension* extension = profile->GetExtensionService()->extensions()->
465 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
[email protected]056ad2a2011-07-12 02:13:55466 if (!extension)
467 return false;
468
469 // If the URL is part of a hosted app that does not have the background
470 // permission, we want to give each instance its own process to improve
471 // responsiveness.
472 if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
473 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
474 return false;
475
476 // Hosted apps that have the background permission must use process per site,
477 // since all instances can make synchronous calls to the background window.
478 // Other extensions should use process per site as well.
479 return true;
480}
481
[email protected]46fb9442011-12-09 17:57:47482bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
483 return ProfileIOData::IsHandledURL(url);
484}
485
[email protected]2a5221b2011-09-27 23:07:31486bool ChromeContentBrowserClient::IsSuitableHost(
[email protected]f3b1a082011-11-18 00:34:30487 content::RenderProcessHost* process_host,
[email protected]2a5221b2011-09-27 23:07:31488 const GURL& site_url) {
489 Profile* profile =
[email protected]f3b1a082011-11-18 00:34:30490 Profile::FromBrowserContext(process_host->GetBrowserContext());
[email protected]8d3132f62011-10-12 07:13:42491 ExtensionService* service = profile->GetExtensionService();
[email protected]6f371442011-11-09 06:45:46492 extensions::ProcessMap* process_map = service->process_map();
[email protected]2a5221b2011-09-27 23:07:31493
[email protected]ffa97602011-11-17 17:55:52494 // Don't allow the Task Manager to share a process with anything else.
495 // Otherwise it can affect the renderers it is observing.
496 // Note: we could create another RenderProcessHostPrivilege bucket for
497 // this to allow multiple chrome://tasks instances to share, but that's
498 // a very unlikely case without serious consequences.
499 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin())
500 return false;
501
[email protected]8d3132f62011-10-12 07:13:42502 // These may be NULL during tests. In that case, just assume any site can
503 // share any host.
[email protected]6f371442011-11-09 06:45:46504 if (!service || !process_map)
[email protected]2a5221b2011-09-27 23:07:31505 return true;
506
[email protected]a8c269a2011-10-25 20:17:22507 // Experimental:
508 // If --enable-strict-site-isolation is enabled, do not allow non-WebUI pages
509 // to share a renderer process. (We could allow pages from the same site or
510 // extensions of the same type to share, if we knew what the given process
511 // was dedicated to. Allowing no sharing is simpler for now.) This may
512 // cause resource exhaustion issues if too many sites are open at once.
513 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
514 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation))
515 return false;
516
[email protected]eec0b33c2011-12-05 22:09:45517 // An isolated app is only allowed to share with the exact same app in order
518 // to provide complete renderer process isolation. This also works around
519 // issue http://crbug.com/85588, where different isolated apps in the same
520 // process would end up using the first app's storage contexts.
521 RenderProcessHostPrivilege privilege_required =
[email protected]8d3132f62011-10-12 07:13:42522 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]eec0b33c2011-12-05 22:09:45523 if (privilege_required == PRIV_ISOLATED)
524 return IsIsolatedAppInProcess(site_url, process_host, process_map, service);
525
526 // Otherwise, just make sure the process privilege matches the privilege
527 // required by the site.
528 return GetProcessPrivilege(process_host, process_map, service) ==
529 privilege_required;
[email protected]2a5221b2011-09-27 23:07:31530}
531
[email protected]76411f412012-02-22 18:56:06532// This function is trying to limit the amount of processes used by extensions
533// with background pages. It uses a globally set percentage of processes to
534// run such extensions and if the limit is exceeded, it returns true, to
535// indicate to the content module to group extensions together.
536bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
537 content::BrowserContext* browser_context, const GURL& url) {
538 // It has to be a valid URL for us to check for an extension.
539 if (!url.is_valid())
540 return false;
541
542 Profile* profile = Profile::FromBrowserContext(browser_context);
543 ExtensionService* service = profile->GetExtensionService();
544 if (!service)
545 return false;
546
547 // We have to have a valid extension with background page to proceed.
548 const Extension* extension =
549 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
550 if (!extension)
551 return false;
552 if (!extension->has_background_page())
553 return false;
554
555 std::set<int> process_ids;
556 size_t max_process_count =
557 content::RenderProcessHost::GetMaxRendererProcessCount();
558
559 // Go through all profiles to ensure we have total count of extension
560 // processes containing background pages, otherwise one profile can
561 // starve the other.
562 std::vector<Profile*> profiles = g_browser_process->profile_manager()->
563 GetLoadedProfiles();
564 for (size_t i = 0; i < profiles.size(); ++i) {
565 ExtensionProcessManager* epm = profiles[i]->GetExtensionProcessManager();
566 for (ExtensionProcessManager::const_iterator iter = epm->begin();
567 iter != epm->end();
568 ++iter) {
569 ExtensionHost* host = *iter;
570 if (host->extension()->has_background_page()) {
571 process_ids.insert(host->render_process_host()->GetID());
572 }
573 }
574 }
575
576 if (process_ids.size() >
577 (max_process_count * chrome::kMaxShareOfExtensionProcesses)) {
578 return true;
579 }
580
581 return false;
582}
583
[email protected]6f371442011-11-09 06:45:46584void ChromeContentBrowserClient::SiteInstanceGotProcess(
585 SiteInstance* site_instance) {
586 CHECK(site_instance->HasProcess());
587
588 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02589 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46590 ExtensionService* service = profile->GetExtensionService();
591 if (!service)
592 return;
593
594 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44595 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
[email protected]b6583592012-01-25 19:52:33596 site_instance->GetSite()));
[email protected]6f371442011-11-09 06:45:46597 if (!extension)
598 return;
599
[email protected]6bc04fd82011-12-04 02:29:35600 service->process_map()->Insert(extension->id(),
601 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33602 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46603 BrowserThread::PostTask(
604 BrowserThread::IO, FROM_HERE,
605 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
606 profile->GetExtensionInfoMap(),
607 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35608 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33609 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46610}
611
612void ChromeContentBrowserClient::SiteInstanceDeleting(
613 SiteInstance* site_instance) {
614 if (!site_instance->HasProcess())
615 return;
616
617 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02618 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46619 ExtensionService* service = profile->GetExtensionService();
620 if (!service)
621 return;
622
623 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44624 service->extensions()->GetExtensionOrAppByURL(
[email protected]b6583592012-01-25 19:52:33625 ExtensionURLInfo(site_instance->GetSite()));
[email protected]6f371442011-11-09 06:45:46626 if (!extension)
627 return;
628
[email protected]6bc04fd82011-12-04 02:29:35629 service->process_map()->Remove(extension->id(),
630 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33631 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46632 BrowserThread::PostTask(
633 BrowserThread::IO, FROM_HERE,
634 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
635 profile->GetExtensionInfoMap(),
636 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35637 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33638 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46639}
640
[email protected]e3daf3c2011-10-05 21:17:08641bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
642 const GURL& current_url,
643 const GURL& new_url) {
644 if (current_url.is_empty()) {
645 // Always choose a new process when navigating to extension URLs. The
646 // process grouping logic will combine all of a given extension's pages
647 // into the same process.
648 if (new_url.SchemeIs(chrome::kExtensionScheme))
649 return true;
650
651 return false;
652 }
653
654 // Also, we must switch if one is an extension and the other is not the exact
655 // same extension.
656 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
657 new_url.SchemeIs(chrome::kExtensionScheme)) {
658 if (current_url.GetOrigin() != new_url.GetOrigin())
659 return true;
660 }
661
662 return false;
663}
664
[email protected]763ec4ca2011-04-29 15:48:12665std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
666 const std::string& alias_name) {
667 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
668}
669
[email protected]b80f68432011-05-02 17:22:30670void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
671 CommandLine* command_line, int child_process_id) {
672#if defined(USE_LINUX_BREAKPAD)
673 if (IsCrashReporterEnabled()) {
674 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
675 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
676 }
677#elif defined(OS_MACOSX)
678 if (IsCrashReporterEnabled()) {
679 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
680 child_process_logging::GetClientId());
681 }
682#endif // OS_MACOSX
683
[email protected]f1933792011-06-14 00:49:34684 if (logging::DialogsAreSuppressed())
685 command_line->AppendSwitch(switches::kNoErrorDialogs);
686
[email protected]b80f68432011-05-02 17:22:30687 std::string process_type =
688 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:17689 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]718eab62011-10-05 21:16:52690 if (process_type == switches::kRendererProcess) {
[email protected]b80f68432011-05-02 17:22:30691 FilePath user_data_dir =
692 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
693 if (!user_data_dir.empty())
694 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
695#if defined(OS_CHROMEOS)
696 const std::string& login_profile =
697 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile);
698 if (!login_profile.empty())
699 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile);
700#endif
701
[email protected]f3b1a082011-11-18 00:34:30702 content::RenderProcessHost* process =
703 content::RenderProcessHost::FromID(child_process_id);
[email protected]a8d851f82011-12-21 00:32:37704 if (process) {
705 Profile* profile = Profile::FromBrowserContext(
706 process->GetBrowserContext());
707 extensions::ProcessMap* process_map =
708 profile->GetExtensionService()->process_map();
709 if (process_map && process_map->Contains(process->GetID()))
710 command_line->AppendSwitch(switches::kExtensionProcess);
[email protected]b80f68432011-05-02 17:22:30711
[email protected]a8d851f82011-12-21 00:32:37712 PrefService* prefs = profile->GetPrefs();
713 // Currently this pref is only registered if applied via a policy.
714 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
715 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
716 // Turn this policy into a command line switch.
717 command_line->AppendSwitch(switches::kDisable3DAPIs);
718 }
[email protected]718eab62011-10-05 21:16:52719
[email protected]a8d851f82011-12-21 00:32:37720 // Disable client-side phishing detection in the renderer if it is
721 // disabled in the Profile preferences or the browser process.
722 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
723 !g_browser_process->safe_browsing_detection_service()) {
724 command_line->AppendSwitch(
725 switches::kDisableClientSidePhishingDetection);
726 }
[email protected]8c40da62011-07-13 22:58:46727 }
[email protected]47c7ec82012-01-18 03:29:21728 {
729 PrefService* local_state = g_browser_process->local_state();
730 if (local_state &&
731 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) {
732 command_line->AppendSwitch(switches::kRendererPrintPreview);
733 }
734 }
[email protected]4287a3d2011-06-13 23:56:51735
[email protected]47c7ec82012-01-18 03:29:21736 // Please keep this in alphabetical order.
[email protected]4287a3d2011-06-13 23:56:51737 static const char* const kSwitchNames[] = {
738 switches::kAllowHTTPBackgroundPage,
[email protected]70f48c02011-12-02 21:27:48739 switches::kAllowLegacyExtensionManifests,
[email protected]4287a3d2011-06-13 23:56:51740 switches::kAllowScriptingGallery,
741 switches::kAppsCheckoutURL,
742 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:31743 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:51744 switches::kDebugPrint,
[email protected]382fb0d2012-02-25 00:19:50745 switches::kDisableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51746 switches::kDumpHistogramsOnExit,
[email protected]b7e44ff2012-02-16 03:37:34747 switches::kEnableAsynchronousSpellChecking,
[email protected]47c7ec82012-01-18 03:29:21748 switches::kEnableBenchmarking,
[email protected]b50368b2012-02-18 00:02:13749 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51750 switches::kEnableCrxlessWebApps,
751 switches::kEnableExperimentalExtensionApis,
752 switches::kEnableInBrowserThumbnailing,
753 switches::kEnableIPCFuzzing,
754 switches::kEnableNaCl,
[email protected]bcbe7652012-02-22 00:08:48755 switches::kEnablePasswordGeneration,
[email protected]9776e82e2011-11-15 02:17:53756 switches::kEnablePlatformApps,
[email protected]4287a3d2011-06-13 23:56:51757 switches::kEnableWatchdog,
758 switches::kExperimentalSpellcheckerFeatures,
759 switches::kMemoryProfiling,
760 switches::kMessageLoopHistogrammer,
[email protected]2a6bb0b12011-10-05 19:18:04761 switches::kNoRunningInsecureContent,
[email protected]4287a3d2011-06-13 23:56:51762 switches::kPpapiFlashArgs,
763 switches::kPpapiFlashInProcess,
764 switches::kPpapiFlashPath,
765 switches::kPpapiFlashVersion,
766 switches::kProfilingAtStart,
767 switches::kProfilingFile,
768 switches::kProfilingFlush,
[email protected]4287a3d2011-06-13 23:56:51769 switches::kSilentDumpOnDCHECK,
[email protected]a446534d2012-02-09 00:07:38770 switches::kWhitelistedExtensionID,
[email protected]4287a3d2011-06-13 23:56:51771 };
772
773 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
774 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17775 } else if (process_type == switches::kUtilityProcess) {
[email protected]a446534d2012-02-09 00:07:38776 static const char* const kSwitchNames[] = {
777 switches::kEnableExperimentalExtensionApis,
778 switches::kWhitelistedExtensionID,
779 };
780
781 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
782 arraysize(kSwitchNames));
[email protected]4287a3d2011-06-13 23:56:51783 } else if (process_type == switches::kPluginProcess) {
784 static const char* const kSwitchNames[] = {
785 #if defined(OS_CHROMEOS)
786 switches::kLoginProfile,
787 #endif
788 switches::kMemoryProfiling,
789 switches::kSilentDumpOnDCHECK,
790 switches::kUserDataDir,
791 };
792
793 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
794 arraysize(kSwitchNames));
795 } else if (process_type == switches::kZygoteProcess) {
796 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51797 switches::kUserDataDir, // Make logs go to the right file.
798 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
[email protected]382fb0d2012-02-25 00:19:50799 switches::kDisableBundledPpapiFlash,
[email protected]b50368b2012-02-18 00:02:13800 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:51801 switches::kPpapiFlashInProcess,
802 switches::kPpapiFlashPath,
803 switches::kPpapiFlashVersion,
804 };
805
806 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
807 arraysize(kSwitchNames));
[email protected]d56ecf922012-02-15 16:03:11808 } else if (process_type == switches::kGpuProcess) {
809 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
810 // because GPU is expected to be unreliable.
811 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) &&
812 !command_line->HasSwitch(switches::kDisableBreakpad))
813 command_line->AppendSwitch(switches::kDisableBreakpad);
[email protected]b80f68432011-05-02 17:22:30814 }
[email protected]6f08af82011-09-15 01:19:03815
816 // The command line switch kEnableBenchmarking needs to be specified along
817 // with the kEnableStatsTable switch to ensure that the stats table global
818 // is initialized correctly.
819 if (command_line->HasSwitch(switches::kEnableBenchmarking))
820 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:30821}
822
823std::string ChromeContentBrowserClient::GetApplicationLocale() {
824 return g_browser_process->GetApplicationLocale();
825}
826
[email protected]597a867b2011-11-18 18:31:20827std::string ChromeContentBrowserClient::GetAcceptLangs(
828 content::BrowserContext* context) {
829 Profile* profile = Profile::FromBrowserContext(context);
[email protected]3d7474ff2011-07-27 17:47:37830 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:08831}
832
[email protected]ac55e292011-06-24 05:16:08833SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() {
[email protected]7c3228a2011-11-11 21:35:22834 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
[email protected]ac55e292011-06-24 05:16:08835 return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
836}
837
[email protected]a2176792011-05-08 19:30:49838bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:09839 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:19840 const GURL& first_party,
[email protected]df02aca2012-02-09 21:03:20841 content::ResourceContext* context) {
[email protected]8093a542011-05-13 07:29:32842 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20843 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05844 return io_data->GetCookieSettings()->
845 IsSettingCookieAllowed(manifest_url, first_party);
[email protected]a2176792011-05-08 19:30:49846}
847
[email protected]ed24fad2011-05-10 22:44:01848bool ChromeContentBrowserClient::AllowGetCookie(
849 const GURL& url,
850 const GURL& first_party,
851 const net::CookieList& cookie_list,
[email protected]df02aca2012-02-09 21:03:20852 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:01853 int render_process_id,
854 int render_view_id) {
855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20856 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05857 bool allow = io_data->GetCookieSettings()->
858 IsReadingCookieAllowed(url, first_party);
[email protected]ed24fad2011-05-10 22:44:01859
[email protected]8093a542011-05-13 07:29:32860 BrowserThread::PostTask(
861 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:03862 base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
863 render_view_id, url, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:01864 return allow;
865}
866
867bool ChromeContentBrowserClient::AllowSetCookie(
868 const GURL& url,
869 const GURL& first_party,
870 const std::string& cookie_line,
[email protected]df02aca2012-02-09 21:03:20871 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:01872 int render_process_id,
873 int render_view_id,
874 net::CookieOptions* options) {
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20876 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:05877 CookieSettings* cookie_settings = io_data->GetCookieSettings();
878 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
879
880 if (cookie_settings->IsCookieSessionOnly(url))
[email protected]5b52ad42011-05-26 14:26:09881 options->set_force_session();
[email protected]ed24fad2011-05-10 22:44:01882
[email protected]8093a542011-05-13 07:29:32883 BrowserThread::PostTask(
884 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:03885 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
886 render_view_id, url, cookie_line, *options, !allow));
[email protected]ed24fad2011-05-10 22:44:01887 return allow;
888}
889
[email protected]d5a19162011-06-30 18:51:54890bool ChromeContentBrowserClient::AllowSaveLocalState(
[email protected]df02aca2012-02-09 21:03:20891 content::ResourceContext* context) {
[email protected]d5a19162011-06-30 18:51:54892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20893 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]1848cdc2012-02-17 10:48:26894
895 if (!io_data->clear_local_state_on_exit()->GetValue())
896 return true;
897
[email protected]068b7b52012-02-27 12:41:44898 // Disable clearing the local state on exit if the browsing session is going
[email protected]1848cdc2012-02-17 10:48:26899 // to be restored on the next startup.
900 SessionStartupPref::Type startup_pref =
901 SessionStartupPref::PrefValueToType(
902 io_data->session_startup_pref()->GetValue());
903 return (startup_pref == SessionStartupPref::LAST &&
[email protected]068b7b52012-02-27 12:41:44904 !CommandLine::ForCurrentProcess()->HasSwitch(
905 switches::kDisableRestoreSessionState));
[email protected]d5a19162011-06-30 18:51:54906}
907
[email protected]5c5a88e2011-11-12 00:45:35908bool ChromeContentBrowserClient::AllowWorkerDatabase(
[email protected]5c5a88e2011-11-12 00:45:35909 const GURL& url,
910 const string16& name,
911 const string16& display_name,
912 unsigned long estimated_size,
[email protected]df02aca2012-02-09 21:03:20913 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:48914 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:35915 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20916 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:35917 CookieSettings* cookie_settings = io_data->GetCookieSettings();
918 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
919
[email protected]62151052012-02-01 18:40:48920 // Record access to database for potential display in UI.
921 std::vector<std::pair<int, int> >::const_iterator i;
922 for (i = render_views.begin(); i != render_views.end(); ++i) {
923 BrowserThread::PostTask(
924 BrowserThread::UI, FROM_HERE,
925 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
926 i->first, i->second, url, name, display_name, !allow));
[email protected]5c5a88e2011-11-12 00:45:35927 }
928
929 return allow;
930}
931
932bool ChromeContentBrowserClient::AllowWorkerFileSystem(
[email protected]5c5a88e2011-11-12 00:45:35933 const GURL& url,
[email protected]df02aca2012-02-09 21:03:20934 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:48935 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:35936 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:20937 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:35938 CookieSettings* cookie_settings = io_data->GetCookieSettings();
939 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
940
[email protected]62151052012-02-01 18:40:48941 // Record access to file system for potential display in UI.
942 std::vector<std::pair<int, int> >::const_iterator i;
943 for (i = render_views.begin(); i != render_views.end(); ++i) {
944 BrowserThread::PostTask(
945 BrowserThread::UI, FROM_HERE,
946 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
947 i->first, i->second, url, !allow));
[email protected]5c5a88e2011-11-12 00:45:35948 }
949
950 return allow;
951}
952
[email protected]6133f922011-07-01 21:34:34953net::URLRequestContext*
954ChromeContentBrowserClient::OverrideRequestContextForURL(
[email protected]df02aca2012-02-09 21:03:20955 const GURL& url, content::ResourceContext* context) {
[email protected]6133f922011-07-01 21:34:34956 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
957 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]df02aca2012-02-09 21:03:20958 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]6133f922011-07-01 21:34:34959 return io_data->extensions_request_context();
960 }
961
962 return NULL;
963}
964
[email protected]317f96c92011-05-31 06:53:41965QuotaPermissionContext*
966ChromeContentBrowserClient::CreateQuotaPermissionContext() {
967 return new ChromeQuotaPermissionContext();
968}
969
[email protected]a0ce3282011-08-19 20:49:52970void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:42971 platform_util::OpenItem(path);
[email protected]0609b17f2011-05-31 20:13:42972}
973
[email protected]a0ce3282011-08-19 20:49:52974void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
[email protected]a0ce3282011-08-19 20:49:52975 platform_util::ShowItemInFolder(path);
[email protected]a0ce3282011-08-19 20:49:52976}
977
[email protected]848dd042011-06-04 18:24:03978void ChromeContentBrowserClient::AllowCertificateError(
[email protected]4cf611e32012-02-13 16:06:17979 int render_process_id,
980 int render_view_id,
981 int cert_error,
982 const net::SSLInfo& ssl_info,
983 const GURL& request_url,
[email protected]848dd042011-06-04 18:24:03984 bool overridable,
[email protected]4cf611e32012-02-13 16:06:17985 const base::Callback<void(bool)>& callback,
986 bool* cancel_request) {
[email protected]f9034cf2011-07-21 12:43:41987 // If the tab is being prerendered, cancel the prerender and the request.
[email protected]83ff91c2012-01-05 20:54:13988 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]4cf611e32012-02-13 16:06:17989 render_process_id, render_view_id);
[email protected]f9034cf2011-07-21 12:43:41990 if (!tab) {
991 NOTREACHED();
992 return;
993 }
994 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:50995 prerender::PrerenderManagerFactory::GetForProfile(
[email protected]627e0512011-12-21 22:55:30996 Profile::FromBrowserContext(tab->GetBrowserContext()));
[email protected]ea049a02011-12-25 21:37:09997 if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab)) {
[email protected]f9034cf2011-07-21 12:43:41998 if (prerender_manager->prerender_tracker()->TryCancel(
[email protected]4cf611e32012-02-13 16:06:17999 render_process_id, render_view_id,
[email protected]f9034cf2011-07-21 12:43:411000 prerender::FINAL_STATUS_SSL_ERROR)) {
[email protected]4cf611e32012-02-13 16:06:171001 *cancel_request = true;
[email protected]f9034cf2011-07-21 12:43:411002 return;
1003 }
1004 }
1005
1006 // Otherwise, display an SSL blocking page.
[email protected]4cf611e32012-02-13 16:06:171007 new SSLBlockingPage(
1008 tab, cert_error, ssl_info, request_url, overridable, callback);
[email protected]848dd042011-06-04 18:24:031009}
1010
[email protected]c99c442e2011-08-24 11:37:301011void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:451012 int render_process_id,
1013 int render_view_id,
[email protected]7a593db2012-02-13 21:19:401014 const net::HttpNetworkSession* network_session,
1015 net::SSLCertRequestInfo* cert_request_info,
1016 const base::Callback<void(net::X509Certificate*)>& callback) {
[email protected]83ff91c2012-01-05 20:54:131017 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]8ec26472011-06-06 16:52:451018 render_process_id, render_view_id);
1019 if (!tab) {
1020 NOTREACHED();
1021 return;
1022 }
1023
[email protected]6786bf402011-12-03 15:19:451024 GURL requesting_url("https://" + cert_request_info->host_and_port);
1025 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
1026 << cert_request_info->host_and_port;
1027
[email protected]627e0512011-12-21 22:55:301028 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
[email protected]6786bf402011-12-03 15:19:451029 scoped_ptr<Value> filter(
1030 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1031 requesting_url,
1032 requesting_url,
1033 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1034 std::string(), NULL));
1035
1036 if (filter.get()) {
1037 // Try to automatically select a client certificate.
1038 if (filter->IsType(Value::TYPE_DICTIONARY)) {
1039 DictionaryValue* filter_dict =
1040 static_cast<DictionaryValue*>(filter.get());
1041
1042 const std::vector<scoped_refptr<net::X509Certificate> >&
1043 all_client_certs = cert_request_info->client_certs;
1044 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1045 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
1046 // Use the first certificate that is matched by the filter.
[email protected]7a593db2012-02-13 21:19:401047 callback.Run(all_client_certs[i]);
[email protected]6786bf402011-12-03 15:19:451048 return;
1049 }
1050 }
1051 } else {
1052 NOTREACHED();
1053 }
1054 }
1055
[email protected]8ec26472011-06-06 16:52:451056 TabContentsWrapper* wrapper =
1057 TabContentsWrapper::GetCurrentWrapperForContents(tab);
[email protected]6786bf402011-12-03 15:19:451058 if (!wrapper) {
[email protected]83ff91c2012-01-05 20:54:131059 // If there is no TabContentsWrapper for the given WebContents then we can't
[email protected]6786bf402011-12-03 15:19:451060 // show the user a dialog to select a client certificate. So we simply
[email protected]2a349e92011-12-07 12:00:141061 // proceed with no client certificate.
[email protected]7a593db2012-02-13 21:19:401062 callback.Run(NULL);
[email protected]6786bf402011-12-03 15:19:451063 return;
1064 }
[email protected]7a593db2012-02-13 21:19:401065 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(
1066 network_session, cert_request_info, callback);
[email protected]8ec26472011-06-06 16:52:451067}
1068
1069void ChromeContentBrowserClient::AddNewCertificate(
1070 net::URLRequest* request,
1071 net::X509Certificate* cert,
1072 int render_process_id,
1073 int render_view_id) {
1074 // The handler will run the UI and delete itself when it's finished.
1075 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
1076}
1077
[email protected]a93670ab2012-02-24 03:46:391078void ChromeContentBrowserClient::RequestMediaAccessPermission(
1079 const content::MediaStreamRequest* request,
1080 const content::MediaResponseCallback& callback) {
1081 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1082
[email protected]117b6b42012-02-29 09:11:081083 WebContents* contents = tab_util::GetWebContentsByID(
1084 request->render_process_id, request->render_view_id);
1085 if (!contents) {
1086 // Abort, if the tab was closed after the request was made but before we
1087 // got to this point.
1088 callback.Run(content::MediaStreamDevices());
1089 return;
1090 }
1091
1092 TabContentsWrapper* tab =
1093 TabContentsWrapper::GetCurrentWrapperForContents(contents);
1094 DCHECK(tab);
1095
1096 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
1097 InfoBarDelegate* old_infobar = NULL;
1098 for (size_t i = 0; i < infobar_helper->infobar_count() && !old_infobar; ++i) {
1099 old_infobar =
1100 infobar_helper->GetInfoBarDelegateAt(i)->AsMediaStreamInfobarDelegate();
1101 }
1102
1103#if defined(TOOLKIT_VIEWS)
1104 InfoBarDelegate* infobar = new MediaStreamInfoBarDelegate(infobar_helper,
1105 request,
1106 callback);
1107 if (old_infobar)
1108 infobar_helper->ReplaceInfoBar(old_infobar, infobar);
1109 else
1110 infobar_helper->AddInfoBar(infobar);
1111#elif defined(OS_LINUX) || defined(OS_MACOSX)
1112 // TODO(macourteau): UI is not implemented yet for Linux and OS X. Fallback to
1113 // the default behaviour and allow access to the first device of each
1114 // requested type.
1115 content::MediaStreamDevices devices;
[email protected]a93670ab2012-02-24 03:46:391116 for (content::MediaStreamDeviceMap::const_iterator it =
1117 request->devices.begin(); it != request->devices.end(); ++it) {
[email protected]6c6415a2012-03-01 17:17:281118 if (!it->second.empty())
1119 devices.push_back(*it->second.begin());
[email protected]a93670ab2012-02-24 03:46:391120 }
1121
[email protected]a93670ab2012-02-24 03:46:391122 callback.Run(devices);
[email protected]117b6b42012-02-29 09:11:081123#endif // TOOLKIT_VIEWS
[email protected]a93670ab2012-02-24 03:46:391124}
1125
[email protected]941623e2011-06-07 23:06:041126void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1127 const GURL& source_origin,
1128 int callback_context,
1129 int render_process_id,
1130 int render_view_id) {
[email protected]5fd2e842012-03-01 00:29:111131#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041132 RenderViewHost* rvh = RenderViewHost::FromID(
1133 render_process_id, render_view_id);
1134 if (!rvh) {
1135 NOTREACHED();
1136 return;
1137 }
1138
[email protected]f3b1a082011-11-18 00:34:301139 content::RenderProcessHost* process = rvh->process();
1140 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041141 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371142 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041143 service->RequestPermission(
1144 source_origin, render_process_id, render_view_id, callback_context,
[email protected]83ff91c2012-01-05 20:54:131145 tab_util::GetWebContentsByID(render_process_id, render_view_id));
[email protected]5fd2e842012-03-01 00:29:111146#else
1147 NOTIMPLEMENTED();
1148#endif
[email protected]941623e2011-06-07 23:06:041149}
1150
1151WebKit::WebNotificationPresenter::Permission
1152 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
[email protected]34eec7ffe32011-11-02 23:49:021153 const GURL& source_origin,
[email protected]df02aca2012-02-09 21:03:201154 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021155 int render_process_id) {
[email protected]5fd2e842012-03-01 00:29:111156#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201158 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]34eec7ffe32011-11-02 23:49:021159 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1160 source_origin, render_process_id,
1161 ExtensionAPIPermission::kNotification))
[email protected]941623e2011-06-07 23:06:041162 return WebKit::WebNotificationPresenter::PermissionAllowed;
[email protected]941623e2011-06-07 23:06:041163
1164 // Fall back to the regular notification preferences, which works on an
1165 // origin basis.
1166 return io_data->GetNotificationService() ?
[email protected]c7df61b2011-11-07 22:06:371167 io_data->GetNotificationService()->HasPermission(source_origin) :
[email protected]941623e2011-06-07 23:06:041168 WebKit::WebNotificationPresenter::PermissionNotAllowed;
[email protected]5fd2e842012-03-01 00:29:111169#else
1170 return WebKit::WebNotificationPresenter::PermissionAllowed;
1171#endif
[email protected]941623e2011-06-07 23:06:041172}
1173
1174void ChromeContentBrowserClient::ShowDesktopNotification(
[email protected]0ee57e22011-11-12 01:59:171175 const content::ShowDesktopNotificationHostMsgParams& params,
[email protected]941623e2011-06-07 23:06:041176 int render_process_id,
1177 int render_view_id,
1178 bool worker) {
[email protected]5fd2e842012-03-01 00:29:111179#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041180 RenderViewHost* rvh = RenderViewHost::FromID(
1181 render_process_id, render_view_id);
1182 if (!rvh) {
1183 NOTREACHED();
1184 return;
1185 }
1186
[email protected]f3b1a082011-11-18 00:34:301187 content::RenderProcessHost* process = rvh->process();
1188 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041189 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371190 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041191 service->ShowDesktopNotification(
1192 params, render_process_id, render_view_id,
1193 worker ? DesktopNotificationService::WorkerNotification :
1194 DesktopNotificationService::PageNotification);
[email protected]5fd2e842012-03-01 00:29:111195#else
1196 NOTIMPLEMENTED();
1197#endif
[email protected]941623e2011-06-07 23:06:041198}
1199
1200void ChromeContentBrowserClient::CancelDesktopNotification(
1201 int render_process_id,
1202 int render_view_id,
1203 int notification_id) {
[email protected]5fd2e842012-03-01 00:29:111204#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041205 RenderViewHost* rvh = RenderViewHost::FromID(
1206 render_process_id, render_view_id);
1207 if (!rvh) {
1208 NOTREACHED();
1209 return;
1210 }
1211
[email protected]f3b1a082011-11-18 00:34:301212 content::RenderProcessHost* process = rvh->process();
1213 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041214 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371215 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041216 service->CancelDesktopNotification(
1217 render_process_id, render_view_id, notification_id);
[email protected]5fd2e842012-03-01 00:29:111218#else
1219 NOTIMPLEMENTED();
1220#endif
[email protected]941623e2011-06-07 23:06:041221}
1222
[email protected]9f3fba52011-06-08 20:37:191223bool ChromeContentBrowserClient::CanCreateWindow(
[email protected]34eec7ffe32011-11-02 23:49:021224 const GURL& source_origin,
[email protected]9f3fba52011-06-08 20:37:191225 WindowContainerType container_type,
[email protected]df02aca2012-02-09 21:03:201226 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021227 int render_process_id) {
[email protected]9f3fba52011-06-08 20:37:191228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1229 // If the opener is trying to create a background window but doesn't have
1230 // the appropriate permission, fail the attempt.
1231 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
[email protected]df02aca2012-02-09 21:03:201232 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]34eec7ffe32011-11-02 23:49:021233 return io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1234 source_origin, render_process_id, ExtensionAPIPermission::kBackground);
[email protected]9f3fba52011-06-08 20:37:191235 }
1236 return true;
1237}
1238
1239std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
[email protected]df02aca2012-02-09 21:03:201240 const GURL& url, content::ResourceContext* context) {
[email protected]9f3fba52011-06-08 20:37:191241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1242 // Check if it's an extension-created worker, in which case we want to use
1243 // the name of the extension.
[email protected]df02aca2012-02-09 21:03:201244 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]9f3fba52011-06-08 20:37:191245 const Extension* extension =
1246 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
1247 return extension ? extension->name() : std::string();
1248}
1249
[email protected]99907362012-01-11 05:41:401250void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1251 return g_browser_process->ResourceDispatcherHostCreated();
[email protected]3cb054e62011-06-13 05:21:171252}
1253
[email protected]66cfec62012-02-24 17:57:511254content::SpeechInputManagerDelegate*
1255 ChromeContentBrowserClient::GetSpeechInputManagerDelegate() {
1256 return new speech_input::ChromeSpeechInputManagerDelegate();
1257}
1258
[email protected]3cb054e62011-06-13 05:21:171259ui::Clipboard* ChromeContentBrowserClient::GetClipboard() {
1260 return g_browser_process->clipboard();
1261}
1262
[email protected]8f6a3b852011-07-19 16:48:561263MHTMLGenerationManager*
1264 ChromeContentBrowserClient::GetMHTMLGenerationManager() {
1265 return g_browser_process->mhtml_generation_manager();
1266}
1267
[email protected]ae6e9912011-07-27 01:18:281268net::NetLog* ChromeContentBrowserClient::GetNetLog() {
1269 return g_browser_process->net_log();
1270}
1271
[email protected]32538d92011-08-25 00:09:231272AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
1273 return new ChromeAccessTokenStore();
1274}
1275
[email protected]dbae6b02011-06-29 23:51:411276bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1277 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1278 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1279}
1280
[email protected]64d69de42012-02-06 00:19:541281void ChromeContentBrowserClient::OverrideWebkitPrefs(
1282 RenderViewHost* rvh, WebPreferences* web_prefs) {
[email protected]f3986f82012-01-03 20:00:061283 Profile* profile = Profile::FromBrowserContext(
1284 rvh->process()->GetBrowserContext());
1285 PrefService* prefs = profile->GetPrefs();
[email protected]f3986f82012-01-03 20:00:061286
[email protected]64d69de42012-02-06 00:19:541287 web_prefs->standard_font_family =
[email protected]f3986f82012-01-03 20:00:061288 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
[email protected]64d69de42012-02-06 00:19:541289 web_prefs->fixed_font_family =
[email protected]f3986f82012-01-03 20:00:061290 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
[email protected]64d69de42012-02-06 00:19:541291 web_prefs->serif_font_family =
[email protected]f3986f82012-01-03 20:00:061292 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
[email protected]64d69de42012-02-06 00:19:541293 web_prefs->sans_serif_font_family =
[email protected]f3986f82012-01-03 20:00:061294 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
[email protected]64d69de42012-02-06 00:19:541295 web_prefs->cursive_font_family =
[email protected]f3986f82012-01-03 20:00:061296 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
[email protected]64d69de42012-02-06 00:19:541297 web_prefs->fantasy_font_family =
[email protected]f3986f82012-01-03 20:00:061298 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
1299
1300 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541301 &web_prefs->standard_font_family_map);
[email protected]f3986f82012-01-03 20:00:061302 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541303 &web_prefs->fixed_font_family_map);
[email protected]f3986f82012-01-03 20:00:061304 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541305 &web_prefs->serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061306 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541307 &web_prefs->sans_serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061308 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541309 &web_prefs->cursive_font_family_map);
[email protected]f3986f82012-01-03 20:00:061310 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541311 &web_prefs->fantasy_font_family_map);
[email protected]f3986f82012-01-03 20:00:061312
[email protected]64d69de42012-02-06 00:19:541313 web_prefs->default_font_size =
[email protected]f3986f82012-01-03 20:00:061314 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize);
[email protected]64d69de42012-02-06 00:19:541315 web_prefs->default_fixed_font_size =
[email protected]f3986f82012-01-03 20:00:061316 prefs->GetInteger(prefs::kWebKitGlobalDefaultFixedFontSize);
[email protected]64d69de42012-02-06 00:19:541317 web_prefs->minimum_font_size =
[email protected]f3986f82012-01-03 20:00:061318 prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize);
[email protected]64d69de42012-02-06 00:19:541319 web_prefs->minimum_logical_font_size =
[email protected]f3986f82012-01-03 20:00:061320 prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize);
1321
[email protected]64d69de42012-02-06 00:19:541322 web_prefs->default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061323
[email protected]64d69de42012-02-06 00:19:541324 web_prefs->javascript_can_open_windows_automatically =
[email protected]f3986f82012-01-03 20:00:061325 prefs->GetBoolean(
1326 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically);
[email protected]64d69de42012-02-06 00:19:541327 web_prefs->dom_paste_enabled =
[email protected]f3986f82012-01-03 20:00:061328 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
[email protected]64d69de42012-02-06 00:19:541329 web_prefs->shrinks_standalone_images_to_fit =
[email protected]f3986f82012-01-03 20:00:061330 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
1331 const DictionaryValue* inspector_settings =
1332 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
1333 if (inspector_settings) {
1334 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys());
1335 iter != inspector_settings->end_keys(); ++iter) {
1336 std::string value;
1337 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value))
[email protected]64d69de42012-02-06 00:19:541338 web_prefs->inspector_settings.push_back(
[email protected]f3986f82012-01-03 20:00:061339 std::make_pair(*iter, value));
1340 }
1341 }
[email protected]64d69de42012-02-06 00:19:541342 web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
[email protected]f3986f82012-01-03 20:00:061343
[email protected]64d69de42012-02-06 00:19:541344 if (!prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled))
1345 web_prefs->javascript_enabled = false;
1346 if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled))
1347 web_prefs->web_security_enabled = false;
1348 if (!prefs->GetBoolean(prefs::kWebKitGlobalPluginsEnabled))
1349 web_prefs->plugins_enabled = false;
1350 if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled))
1351 web_prefs->java_enabled = false;
1352 web_prefs->loads_images_automatically =
1353 prefs->GetBoolean(prefs::kWebKitGlobalLoadsImagesAutomatically);
[email protected]f3986f82012-01-03 20:00:061354
[email protected]64d69de42012-02-06 00:19:541355 if (prefs->GetBoolean(prefs::kDisable3DAPIs))
1356 web_prefs->experimental_webgl_enabled = false;
[email protected]f3986f82012-01-03 20:00:061357
[email protected]64d69de42012-02-06 00:19:541358 web_prefs->memory_info_enabled =
1359 prefs->GetBoolean(prefs::kEnableMemoryInfo);
1360 web_prefs->allow_displaying_insecure_content =
1361 prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
1362 web_prefs->allow_running_insecure_content =
1363 prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
[email protected]9d06d88d2012-02-23 22:37:081364 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
[email protected]f3986f82012-01-03 20:00:061365
[email protected]64d69de42012-02-06 00:19:541366 // The user stylesheet watcher may not exist in a testing profile.
1367 if (profile->GetUserStyleSheetWatcher()) {
1368 web_prefs->user_style_sheet_enabled = true;
1369 web_prefs->user_style_sheet_location =
1370 profile->GetUserStyleSheetWatcher()->user_style_sheet();
1371 } else {
1372 web_prefs->user_style_sheet_enabled = false;
[email protected]f3986f82012-01-03 20:00:061373 }
1374
[email protected]b7e44ff2012-02-16 03:37:341375 web_prefs->asynchronous_spell_checking_enabled =
1376 CommandLine::ForCurrentProcess()->
1377 HasSwitch(switches::kEnableAsynchronousSpellChecking);
1378 web_prefs->unified_textchecker_enabled =
1379 web_prefs->asynchronous_spell_checking_enabled ||
1380 CommandLine::ForCurrentProcess()->
1381 HasSwitch(switches::kExperimentalSpellcheckerFeatures);
[email protected]dd5d0fb2012-01-18 03:37:571382
[email protected]64d69de42012-02-06 00:19:541383 web_prefs->uses_universal_detector =
[email protected]f3986f82012-01-03 20:00:061384 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);
[email protected]64d69de42012-02-06 00:19:541385 web_prefs->text_areas_are_resizable =
[email protected]f3986f82012-01-03 20:00:061386 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
[email protected]64d69de42012-02-06 00:19:541387 web_prefs->hyperlink_auditing_enabled =
[email protected]f3986f82012-01-03 20:00:061388 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
1389
1390 // Make sure we will set the default_encoding with canonical encoding name.
[email protected]64d69de42012-02-06 00:19:541391 web_prefs->default_encoding =
[email protected]f3986f82012-01-03 20:00:061392 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
[email protected]64d69de42012-02-06 00:19:541393 web_prefs->default_encoding);
1394 if (web_prefs->default_encoding.empty()) {
[email protected]f3986f82012-01-03 20:00:061395 prefs->ClearPref(prefs::kGlobalDefaultCharset);
[email protected]64d69de42012-02-06 00:19:541396 web_prefs->default_encoding =
1397 prefs->GetString(prefs::kGlobalDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061398 }
[email protected]64d69de42012-02-06 00:19:541399 DCHECK(!web_prefs->default_encoding.empty());
[email protected]f3986f82012-01-03 20:00:061400
1401 ExtensionService* service = profile->GetExtensionService();
1402 if (service) {
1403 const Extension* extension = service->extensions()->GetByID(
[email protected]b6583592012-01-25 19:52:331404 rvh->site_instance()->GetSite().host());
[email protected]f3986f82012-01-03 20:00:061405 extension_webkit_preferences::SetPreferences(
[email protected]64d69de42012-02-06 00:19:541406 extension, rvh->delegate()->GetRenderViewType(), web_prefs);
[email protected]f3986f82012-01-03 20:00:061407 }
1408
1409 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) {
[email protected]64d69de42012-02-06 00:19:541410 web_prefs->allow_scripts_to_close_windows = true;
[email protected]f3986f82012-01-03 20:00:061411 } else if (rvh->delegate()->GetRenderViewType() ==
1412 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1413 // Disable all kinds of acceleration for background pages.
1414 // See http://crbug.com/96005 and http://crbug.com/96006
[email protected]64d69de42012-02-06 00:19:541415 web_prefs->force_compositing_mode = false;
1416 web_prefs->accelerated_compositing_enabled = false;
1417 web_prefs->accelerated_2d_canvas_enabled = false;
1418 web_prefs->accelerated_video_enabled = false;
1419 web_prefs->accelerated_painting_enabled = false;
1420 web_prefs->accelerated_plugins_enabled = false;
[email protected]f3986f82012-01-03 20:00:061421 }
[email protected]181a95ee2011-07-12 19:26:361422}
1423
1424void ChromeContentBrowserClient::UpdateInspectorSetting(
1425 RenderViewHost* rvh, const std::string& key, const std::string& value) {
[email protected]f3986f82012-01-03 20:00:061426 content::BrowserContext* browser_context =
1427 rvh->process()->GetBrowserContext();
1428 DictionaryPrefUpdate update(
1429 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1430 prefs::kWebKitInspectorSettings);
1431 DictionaryValue* inspector_settings = update.Get();
1432 inspector_settings->SetWithoutPathExpansion(key,
1433 Value::CreateStringValue(value));
[email protected]181a95ee2011-07-12 19:26:361434}
1435
1436void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
[email protected]f3986f82012-01-03 20:00:061437 content::BrowserContext* browser_context =
1438 rvh->process()->GetBrowserContext();
1439 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1440 ClearPref(prefs::kWebKitInspectorSettings);
[email protected]181a95ee2011-07-12 19:26:361441}
1442
[email protected]b8148ac2011-07-13 22:03:251443void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1444 BrowserURLHandler* handler) {
1445 // Add the default URL handlers.
1446 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1447 BrowserURLHandler::null_handler());
1448 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1449 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1450
[email protected]b3adbd02011-11-30 22:23:271451 // about: handler. Must come before chrome: handler, since it will
1452 // rewrite about: urls to chrome: URLs and then expect chrome: to
1453 // actually handle them.
[email protected]b8148ac2011-07-13 22:03:251454 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1455 BrowserURLHandler::null_handler());
1456 // chrome: & friends.
1457 handler->AddHandlerPair(&HandleWebUI,
1458 BrowserURLHandler::null_handler());
1459}
1460
1461void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371462 Profile* profile = Profile::FromBrowserContext(
[email protected]f3b1a082011-11-18 00:34:301463 rvh->site_instance()->GetProcess()->GetBrowserContext());
[email protected]b8148ac2011-07-13 22:03:251464 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1465 BrowsingDataRemover::EVERYTHING,
1466 base::Time());
1467 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
1468 // BrowsingDataRemover takes care of deleting itself when done.
1469}
1470
1471void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371472 Profile* profile = Profile::FromBrowserContext(
[email protected]f3b1a082011-11-18 00:34:301473 rvh->site_instance()->GetProcess()->GetBrowserContext());
[email protected]b8148ac2011-07-13 22:03:251474 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1475 BrowsingDataRemover::EVERYTHING,
1476 base::Time());
[email protected]dceaa912011-09-06 17:17:231477 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]b8148ac2011-07-13 22:03:251478 remover->Remove(remove_mask);
1479 // BrowsingDataRemover takes care of deleting itself when done.
1480}
1481
[email protected]e1d16eb92011-08-18 23:19:321482FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1483 return download_util::GetDefaultDownloadDirectory();
1484}
1485
[email protected]c9b6eb62011-10-18 20:49:391486std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
1487 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
1488}
1489
[email protected]e461da2f2012-02-16 19:06:401490bool ChromeContentBrowserClient::AllowSocketAPI(const GURL& url) {
1491 return url.is_valid() &&
1492 allowed_socket_origins_.find(url.host()) != allowed_socket_origins_.end();
1493}
1494
[email protected]e60c0232011-11-11 19:56:351495#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301496int ChromeContentBrowserClient::GetCrashSignalFD(
[email protected]718eab62011-10-05 21:16:521497 const CommandLine& command_line) {
[email protected]6e677a342012-02-11 01:21:141498#if defined(OS_ANDROID)
1499 // TODO(carlosvaldivia): Upstream breakpad code for Android and remove this
1500 // fork. http://crbug.com/113560
1501 NOTIMPLEMENTED();
1502#else
[email protected]718eab62011-10-05 21:16:521503 if (command_line.HasSwitch(switches::kExtensionProcess)) {
[email protected]9dbfff12011-07-01 19:37:071504 ExtensionCrashHandlerHostLinux* crash_handler =
1505 ExtensionCrashHandlerHostLinux::GetInstance();
1506 return crash_handler->GetDeathSignalSocket();
1507 }
1508
[email protected]718eab62011-10-05 21:16:521509 std::string process_type =
1510 command_line.GetSwitchValueASCII(switches::kProcessType);
1511
1512 if (process_type == switches::kRendererProcess)
1513 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1514
[email protected]b80f68432011-05-02 17:22:301515 if (process_type == switches::kPluginProcess)
1516 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1517
1518 if (process_type == switches::kPpapiPluginProcess)
1519 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
1520
1521 if (process_type == switches::kGpuProcess)
1522 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
[email protected]6e677a342012-02-11 01:21:141523#endif // defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:301524
1525 return -1;
1526}
[email protected]e60c0232011-11-11 19:56:351527#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301528
[email protected]4a65826d2011-08-25 16:04:011529#if defined(OS_WIN)
1530const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
1531 return chrome::kBrowserResourcesDll;
1532}
1533#endif
1534
[email protected]37a72af2011-06-13 05:42:011535#if defined(USE_NSS)
1536crypto::CryptoModuleBlockingPasswordDelegate*
1537 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1538 const GURL& url) {
1539 return browser::NewCryptoModuleBlockingDialogDelegate(
1540 browser::kCryptoModulePasswordKeygen, url.host());
1541}
1542#endif
1543
[email protected]d977f9c2011-03-14 16:10:261544} // namespace chrome