blob: e123ba5242eff9428aeaf6b9f963a32f2594c4cc [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]29699c22012-10-03 23:57:3913#include "base/path_service.h"
[email protected]e461da2f2012-02-16 19:06:4014#include "base/string_tokenizer.h"
[email protected]f3986f82012-01-03 20:00:0615#include "base/utf_string_conversions.h"
[email protected]b80f68432011-05-02 17:22:3016#include "chrome/app/breakpad_mac.h"
[email protected]b8148ac2011-07-13 22:03:2517#include "chrome/browser/browser_about_handler.h"
[email protected]b80f68432011-05-02 17:22:3018#include "chrome/browser/browser_process.h"
[email protected]b0cb5e82012-07-19 19:22:4719#include "chrome/browser/browsing_data/browsing_data_helper.h"
20#include "chrome/browser/browsing_data/browsing_data_remover.h"
[email protected]763ec4ca2011-04-29 15:48:1221#include "chrome/browser/character_encoding.h"
[email protected]6f08af82011-09-15 01:19:0322#include "chrome/browser/chrome_benchmarking_message_filter.h"
[email protected]317f96c92011-05-31 06:53:4123#include "chrome/browser/chrome_quota_permission_context.h"
[email protected]edece212011-11-16 11:56:5624#include "chrome/browser/content_settings/content_settings_utils.h"
[email protected]30fde822011-10-28 09:49:0525#include "chrome/browser/content_settings/cookie_settings.h"
[email protected]6786bf402011-12-03 15:19:4526#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]8093a542011-05-13 07:29:3227#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]9d06d88d2012-02-23 22:37:0828#include "chrome/browser/defaults.h"
[email protected]e1d16eb92011-08-18 23:19:3229#include "chrome/browser/download/download_util.h"
[email protected]2b33dcd02012-03-18 01:34:1630#include "chrome/browser/extensions/api/web_request/web_request_api.h"
[email protected]76411f412012-02-22 18:56:0631#include "chrome/browser/extensions/extension_host.h"
[email protected]941623e2011-06-07 23:06:0432#include "chrome/browser/extensions/extension_info_map.h"
[email protected]9c1662b2012-03-06 15:44:3333#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]d977f9c2011-03-14 16:10:2634#include "chrome/browser/extensions/extension_service.h"
[email protected]31d8f5f22012-04-02 15:22:0835#include "chrome/browser/extensions/extension_system.h"
[email protected]b8148ac2011-07-13 22:03:2536#include "chrome/browser/extensions/extension_web_ui.h"
[email protected]f3986f82012-01-03 20:00:0637#include "chrome/browser/extensions/extension_webkit_preferences.h"
[email protected]40404bc2012-07-25 17:40:4938#include "chrome/browser/extensions/message_handler.h"
[email protected]32538d92011-08-25 00:09:2339#include "chrome/browser/geolocation/chrome_access_token_store.h"
[email protected]763ec4ca2011-04-29 15:48:1240#include "chrome/browser/google/google_util.h"
[email protected]117b6b42012-02-29 09:11:0841#include "chrome/browser/infobars/infobar_tab_helper.h"
[email protected]dc73a7b2012-03-25 15:27:1842#include "chrome/browser/media/media_internals.h"
[email protected]0c7193742012-11-07 19:05:0343#include "chrome/browser/nacl_host/nacl_process_host.h"
[email protected]ae6e9912011-07-27 01:18:2844#include "chrome/browser/net/chrome_net_log.h"
[email protected]941623e2011-06-07 23:06:0445#include "chrome/browser/notifications/desktop_notification_service.h"
46#include "chrome/browser/notifications/desktop_notification_service_factory.h"
[email protected]e0ada9c2012-03-20 03:54:4347#include "chrome/browser/pepper_gtalk_message_filter.h"
[email protected]0609b17f2011-05-31 20:13:4248#include "chrome/browser/platform_util.h"
[email protected]763ec4ca2011-04-29 15:48:1249#include "chrome/browser/prefs/pref_service.h"
[email protected]f3986f82012-01-03 20:00:0650#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]f9034cf2011-07-21 12:43:4151#include "chrome/browser/prerender/prerender_manager.h"
[email protected]3085c502011-10-05 17:50:5052#include "chrome/browser/prerender/prerender_manager_factory.h"
[email protected]2736c032012-05-11 18:06:0753#include "chrome/browser/prerender/prerender_message_filter.h"
[email protected]f9034cf2011-07-21 12:43:4154#include "chrome/browser/prerender/prerender_tracker.h"
[email protected]05fcf982011-04-19 00:44:1455#include "chrome/browser/printing/printing_message_filter.h"
56#include "chrome/browser/profiles/profile.h"
[email protected]8093a542011-05-13 07:29:3257#include "chrome/browser/profiles/profile_io_data.h"
[email protected]76411f412012-02-22 18:56:0658#include "chrome/browser/profiles/profile_manager.h"
[email protected]05fcf982011-04-19 00:44:1459#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
[email protected]53a0afa2011-04-28 02:09:3360#include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
[email protected]b7631cc2012-09-15 05:08:3861#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
[email protected]8aa7a412011-11-07 12:33:4262#include "chrome/browser/renderer_host/plugin_info_message_filter.h"
[email protected]05fcf982011-04-19 00:44:1463#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
[email protected]c52b2892012-03-07 11:01:0264#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
[email protected]8ec71262011-07-28 08:12:4665#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
[email protected]8ec26472011-06-06 16:52:4566#include "chrome/browser/ssl/ssl_add_cert_handler.h"
[email protected]848dd042011-06-04 18:24:0367#include "chrome/browser/ssl/ssl_blocking_page.h"
[email protected]11feec322012-09-18 03:58:5268#include "chrome/browser/ssl/ssl_tab_helper.h"
[email protected]8ec26472011-06-06 16:52:4569#include "chrome/browser/tab_contents/tab_util.h"
[email protected]c27541f2012-05-24 19:25:5470#include "chrome/browser/toolkit_extra_parts.h"
[email protected]b5d73422012-06-02 23:46:4471#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
[email protected]871dc682012-06-11 19:35:3372#include "chrome/browser/ui/tab_contents/tab_contents.h"
[email protected]863f70a2012-01-27 02:05:5073#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
[email protected]f3986f82012-01-03 20:00:0674#include "chrome/browser/user_style_sheet_watcher.h"
[email protected]13169ab2012-04-06 07:48:1575#include "chrome/browser/user_style_sheet_watcher_factory.h"
[email protected]9ec0f452012-05-31 15:58:5376#include "chrome/browser/view_type_utils.h"
[email protected]b80f68432011-05-02 17:22:3077#include "chrome/common/child_process_logging.h"
[email protected]4a65826d2011-08-25 16:04:0178#include "chrome/common/chrome_constants.h"
[email protected]a7944aa2012-10-15 10:12:1479#include "chrome/common/chrome_paths.h"
[email protected]b80f68432011-05-02 17:22:3080#include "chrome/common/chrome_switches.h"
[email protected]941623e2011-06-07 23:06:0481#include "chrome/common/extensions/extension.h"
[email protected]395045c2012-05-22 15:04:3882#include "chrome/common/extensions/extension_process_policy.h"
[email protected]615d88f2011-12-13 01:47:4483#include "chrome/common/extensions/extension_set.h"
[email protected]157cc902012-11-02 06:31:5884#include "chrome/common/extensions/permissions/socket_permission.h"
[email protected]f1933792011-06-14 00:49:3485#include "chrome/common/logging_chrome.h"
[email protected]763ec4ca2011-04-29 15:48:1286#include "chrome/common/pref_names.h"
[email protected]3e69bc82011-05-26 23:22:3887#include "chrome/common/render_messages.h"
[email protected]c5dbef02011-05-13 05:06:0988#include "chrome/common/url_constants.h"
[email protected]e0ada9c2012-03-20 03:54:4389#include "content/public/browser/browser_child_process_host.h"
[email protected]b48c9182011-10-26 18:03:3090#include "content/public/browser/browser_main_parts.h"
[email protected]b7631cc2012-09-15 05:08:3891#include "content/public/browser/browser_ppapi_host.h"
[email protected]825b1662012-03-12 19:07:3192#include "content/public/browser/browser_url_handler.h"
[email protected]0c7193742012-11-07 19:05:0393#include "content/public/browser/child_process_data.h"
[email protected]b9535422012-02-09 01:47:5994#include "content/public/browser/child_process_security_policy.h"
[email protected]cb6430932012-10-31 00:53:3695#include "content/public/browser/compositor_util.h"
[email protected]f3b1a082011-11-18 00:34:3096#include "content/public/browser/render_process_host.h"
[email protected]9c1662b2012-03-06 15:44:3397#include "content/public/browser/render_view_host.h"
[email protected]ce967862012-02-09 22:47:0598#include "content/public/browser/resource_context.h"
[email protected]b6583592012-01-25 19:52:3399#include "content/public/browser/site_instance.h"
[email protected]91ee3682012-01-19 15:02:19100#include "content/public/browser/web_contents.h"
[email protected]8643e6d2012-01-18 20:26:10101#include "content/public/browser/web_contents_view.h"
[email protected]e0ada9c2012-03-20 03:54:43102#include "content/public/common/child_process_host.h"
[email protected]a1733df2012-06-22 11:24:18103#include "content/public/common/content_descriptors.h"
[email protected]c9b6eb62011-10-18 20:49:39104#include "grit/generated_resources.h"
[email protected]2a281332012-07-11 22:20:23105#include "grit/ui_resources.h"
[email protected]1bc28312012-11-08 08:31:53106#include "net/base/escape.h"
[email protected]7a593db2012-02-13 21:19:40107#include "net/base/ssl_cert_request_info.h"
[email protected]5b9bc352012-07-18 13:13:34108#include "net/cookies/canonical_cookie.h"
[email protected]aa84a7e2012-03-15 21:29:06109#include "net/cookies/cookie_options.h"
[email protected]b7631cc2012-09-15 05:08:38110#include "ppapi/host/ppapi_host.h"
[email protected]c9b6eb62011-10-18 20:49:39111#include "ui/base/l10n/l10n_util.h"
[email protected]ac55e292011-06-24 05:16:08112#include "ui/base/resource/resource_bundle.h"
[email protected]4fdf6742012-01-10 20:14:36113#include "webkit/glue/webpreferences.h"
[email protected]a085aed72012-04-24 05:32:04114#include "webkit/plugins/plugin_switches.h"
[email protected]d977f9c2011-03-14 16:10:26115
[email protected]b48c9182011-10-26 18:03:30116#if defined(OS_WIN)
[email protected]199fc7a2011-09-28 22:45:38117#include "chrome/browser/chrome_browser_main_win.h"
118#elif defined(OS_MACOSX)
119#include "chrome/browser/chrome_browser_main_mac.h"
[email protected]7ceb99012011-12-21 08:05:56120#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
[email protected]b48c9182011-10-26 18:03:30121#elif defined(OS_CHROMEOS)
122#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
[email protected]fe69558d2012-03-12 11:34:49123#include "chrome/browser/chromeos/login/user_manager.h"
[email protected]81ce2c42012-03-24 01:43:26124#elif defined(OS_LINUX)
[email protected]b48c9182011-10-26 18:03:30125#include "chrome/browser/chrome_browser_main_linux.h"
[email protected]81054f812012-08-30 00:47:09126#elif defined(OS_ANDROID)
[email protected]40da3e0c2012-10-24 22:03:38127#include "chrome/browser/android/crash_dump_manager.h"
[email protected]81054f812012-08-30 00:47:09128#include "chrome/browser/chrome_browser_main_android.h"
[email protected]29699c22012-10-03 23:57:39129#include "chrome/common/descriptors_android.h"
[email protected]b48c9182011-10-26 18:03:30130#elif defined(OS_POSIX)
131#include "chrome/browser/chrome_browser_main_posix.h"
132#endif
133
[email protected]6653c192012-04-10 22:52:44134#if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:30135#include "base/linux_util.h"
[email protected]1602cde2012-06-26 15:09:12136#include "chrome/browser/crash_handler_host_linux.h"
[email protected]1fd5302c2011-05-28 04:06:43137#endif
[email protected]b80f68432011-05-02 17:22:30138
[email protected]1e87df32012-09-12 04:53:19139#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
140#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
141#endif
142
[email protected]29699c22012-10-03 23:57:39143#if defined(OS_ANDROID)
144#include "ui/base/ui_base_paths.h"
145#endif
146
[email protected]37a72af2011-06-13 05:42:01147#if defined(USE_NSS)
148#include "chrome/browser/ui/crypto_module_password_dialog.h"
149#endif
150
[email protected]c7abd422012-09-25 00:20:08151using base::FileDescriptor;
[email protected]c8c77182011-12-21 15:04:47152using content::AccessTokenStore;
[email protected]0c7193742012-11-07 19:05:03153using content::BrowserChildProcessHostIterator;
[email protected]631bb742011-11-02 11:29:39154using content::BrowserThread;
[email protected]825b1662012-03-12 19:07:31155using content::BrowserURLHandler;
[email protected]b9535422012-02-09 01:47:59156using content::ChildProcessSecurityPolicy;
[email protected]c7abd422012-09-25 00:20:08157using content::FileDescriptorInfo;
[email protected]9f9749a2012-03-02 19:37:00158using content::QuotaPermissionContext;
[email protected]eaabba22012-03-07 15:02:11159using content::RenderViewHost;
[email protected]b6583592012-01-25 19:52:33160using content::SiteInstance;
[email protected]83ff91c2012-01-05 20:54:13161using content::WebContents;
[email protected]c2e66e12012-06-27 06:27:06162using extensions::APIPermission;
[email protected]1c321ee2012-05-21 03:02:34163using extensions::Extension;
[email protected]6717bf272012-05-11 23:31:25164using webkit_glue::WebPreferences;
[email protected]631bb742011-11-02 11:29:39165
[email protected]c5dbef02011-05-13 05:06:09166namespace {
167
[email protected]e461da2f2012-02-16 19:06:40168const char* kPredefinedAllowedSocketOrigins[] = {
169 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
[email protected]b95bf502012-04-06 07:41:18170 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client)
[email protected]99132682012-04-24 19:00:45171 "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126
172 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
173 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop
174 "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
[email protected]a450b6be2012-05-22 19:30:35175 "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
[email protected]9040a0c22012-06-22 19:06:54176 "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089
177 "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099
178 "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099
179 "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099
180 "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099
181 "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099
[email protected]4dc30b82012-08-15 00:24:38182 "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099
183 "jdfhpkjeckflbbleddjlpimecpbjdeep" // see crbug.com/142514
[email protected]e461da2f2012-02-16 19:06:40184};
185
[email protected]f8f93eb2012-09-25 03:06:24186// Returns a copy of the given url with its host set to given host and path set
187// to given path. Other parts of the url will be the same.
188GURL ReplaceURLHostAndPath(const GURL& url,
189 const std::string& host,
190 const std::string& path) {
191 url_canon::Replacements<char> replacements;
192 replacements.SetHost(host.c_str(),
193 url_parse::Component(0, host.length()));
194 replacements.SetPath(path.c_str(),
195 url_parse::Component(0, path.length()));
196 return url.ReplaceComponents(replacements);
197}
198
199// Maps "foo://bar/baz/" to "foo://chrome/bar/baz/".
200GURL AddUberHost(const GURL& url) {
201 const std::string uber_host = chrome::kChromeUIUberHost;
202 const std::string new_path = url.host() + url.path();
203
204 return ReplaceURLHostAndPath(url, uber_host, new_path);
205}
206
[email protected]045bf7c2012-09-28 20:27:36207// If url->host() is "chrome" and url->path() has characters other than the
208// first slash, changes the url from "foo://chrome/bar/" to "foo://bar/" and
209// returns true. Otherwise returns false.
[email protected]f8f93eb2012-09-25 03:06:24210bool RemoveUberHost(GURL* url) {
211 if (url->host() != chrome::kChromeUIUberHost)
212 return false;
213
[email protected]045bf7c2012-09-28 20:27:36214 if (url->path().empty() || url->path() == "/")
215 return false;
216
[email protected]f8f93eb2012-09-25 03:06:24217 const std::string old_path = url->path();
218
219 const std::string::size_type separator = old_path.find('/', 1);
220 std::string new_host;
221 std::string new_path;
222 if (separator == std::string::npos) {
[email protected]045bf7c2012-09-28 20:27:36223 new_host = old_path.substr(1);
[email protected]f8f93eb2012-09-25 03:06:24224 } else {
225 new_host = old_path.substr(1, separator - 1);
226 new_path = old_path.substr(separator);
227 }
228
229 *url = ReplaceURLHostAndPath(*url, new_host, new_path);
230
231 return true;
232}
233
[email protected]b8148ac2011-07-13 22:03:25234// Handles rewriting Web UI URLs.
[email protected]8d3132f62011-10-12 07:13:42235bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
[email protected]f8f93eb2012-09-25 03:06:24236 // Do not handle special URLs such as "about:foo"
237 if (!url->host().empty()) {
238 const GURL chrome_url = AddUberHost(*url);
239
240 // Handle valid "chrome://chrome/foo" URLs so the reverse handler will
241 // be called.
242 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
243 browser_context, chrome_url))
244 return true;
245 }
246
[email protected]863f70a2012-01-27 02:05:50247 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
248 browser_context, *url))
[email protected]b8148ac2011-07-13 22:03:25249 return false;
250
[email protected]fe69558d2012-03-12 11:34:49251#if defined(OS_CHROMEOS)
252 // Special case : in ChromeOS in Guest mode bookmarks and history are
253 // disabled for security reasons. New tab page explains the reasons, so
254 // we redirect user to new tab page.
255 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
256 if (url->SchemeIs(chrome::kChromeUIScheme) &&
257 (url->DomainIs(chrome::kChromeUIBookmarksHost) ||
258 url->DomainIs(chrome::kChromeUIHistoryHost))) {
259 // Rewrite with new tab URL
260 *url = GURL(chrome::kChromeUINewTabURL);
261 }
262 }
263#endif
264
[email protected]b8148ac2011-07-13 22:03:25265 // Special case the new tab page. In older versions of Chrome, the new tab
266 // page was hosted at chrome-internal:<blah>. This might be in people's saved
267 // sessions or bookmarks, so we say any URL with that scheme triggers the new
268 // tab page.
269 if (url->SchemeIs(chrome::kChromeInternalScheme)) {
270 // Rewrite it with the proper new tab URL.
271 *url = GURL(chrome::kChromeUINewTabURL);
272 }
273
274 return true;
275}
276
[email protected]f8f93eb2012-09-25 03:06:24277// Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to
278// "chrome://foo/".
279bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) {
280 if (!url->is_valid() || !url->SchemeIs(chrome::kChromeUIScheme))
281 return false;
282
283 return RemoveUberHost(url);
284}
285
[email protected]8d3132f62011-10-12 07:13:42286// Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
287// below. Extension, and isolated apps require different privileges to be
288// granted to their RenderProcessHosts. This classification allows us to make
289// sure URLs are served by hosts with the right set of privileges.
290enum RenderProcessHostPrivilege {
291 PRIV_NORMAL,
[email protected]eec0b33c2011-12-05 22:09:45292 PRIV_HOSTED,
[email protected]8d3132f62011-10-12 07:13:42293 PRIV_ISOLATED,
[email protected]eec0b33c2011-12-05 22:09:45294 PRIV_EXTENSION,
[email protected]8d3132f62011-10-12 07:13:42295};
296
297RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
298 const GURL& url,
299 ExtensionService* service) {
300 // Default to a normal renderer cause it is lower privileged. This should only
301 // occur if the URL on a site instance is either malformed, or uninitialized.
302 // If it is malformed, then there is no need for better privileges anyways.
303 // If it is uninitialized, but eventually settles on being an a scheme other
304 // than normal webrenderer, the navigation logic will correct us out of band
305 // anyways.
306 if (!url.is_valid())
307 return PRIV_NORMAL;
308
309 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]615d88f2011-12-13 01:47:44310 const Extension* extension =
311 service->extensions()->GetByID(url.host());
[email protected]eec0b33c2011-12-05 22:09:45312 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42313 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45314 if (extension && extension->is_hosted_app())
315 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42316
317 return PRIV_EXTENSION;
318 }
319
320 return PRIV_NORMAL;
321}
322
323RenderProcessHostPrivilege GetProcessPrivilege(
[email protected]f3b1a082011-11-18 00:34:30324 content::RenderProcessHost* process_host,
[email protected]6f371442011-11-09 06:45:46325 extensions::ProcessMap* process_map,
326 ExtensionService* service) {
[email protected]6f371442011-11-09 06:45:46327 std::set<std::string> extension_ids =
[email protected]f3b1a082011-11-18 00:34:30328 process_map->GetExtensionsInProcess(process_host->GetID());
[email protected]6f371442011-11-09 06:45:46329 if (extension_ids.empty())
[email protected]676f6ab2011-10-19 20:23:21330 return PRIV_NORMAL;
331
[email protected]6f371442011-11-09 06:45:46332 for (std::set<std::string>::iterator iter = extension_ids.begin();
333 iter != extension_ids.end(); ++iter) {
334 const Extension* extension = service->GetExtensionById(*iter, false);
335 if (extension && extension->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42336 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45337 if (extension && extension->is_hosted_app())
338 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42339 }
340
[email protected]676f6ab2011-10-19 20:23:21341 return PRIV_EXTENSION;
[email protected]8d3132f62011-10-12 07:13:42342}
343
[email protected]6786bf402011-12-03 15:19:45344bool CertMatchesFilter(const net::X509Certificate& cert,
345 const base::DictionaryValue& filter) {
346 // TODO(markusheintz): This is the minimal required filter implementation.
347 // Implement a better matcher.
348
349 // An empty filter matches any client certificate since no requirements are
350 // specified at all.
351 if (filter.empty())
352 return true;
353
354 std::string common_name;
355 if (filter.GetString("ISSUER.CN", &common_name) &&
356 (cert.issuer().common_name == common_name)) {
357 return true;
358 }
359 return false;
360}
361
[email protected]f3986f82012-01-03 20:00:06362// Fills |map| with the per-script font prefs under path |map_name|.
363void FillFontFamilyMap(const PrefService* prefs,
364 const char* map_name,
365 WebPreferences::ScriptFontFamilyMap* map) {
366 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
367 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
368 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
369 std::string font_family = prefs->GetString(pref_name.c_str());
[email protected]d0471062012-10-26 09:00:23370 if (!font_family.empty())
371 (*map)[script] = UTF8ToUTF16(font_family);
[email protected]f3986f82012-01-03 20:00:06372 }
373}
374
[email protected]a1733df2012-06-22 11:24:18375#if defined(OS_POSIX) && !defined(OS_MACOSX)
376int GetCrashSignalFD(const CommandLine& command_line) {
377 if (command_line.HasSwitch(switches::kExtensionProcess)) {
378 ExtensionCrashHandlerHostLinux* crash_handler =
379 ExtensionCrashHandlerHostLinux::GetInstance();
380 return crash_handler->GetDeathSignalSocket();
381 }
382
383 std::string process_type =
384 command_line.GetSwitchValueASCII(switches::kProcessType);
385
386 if (process_type == switches::kRendererProcess)
387 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
388
389 if (process_type == switches::kPluginProcess)
390 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
391
392 if (process_type == switches::kPpapiPluginProcess)
393 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
394
395 if (process_type == switches::kGpuProcess)
396 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
397
398 return -1;
399}
400#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
401
[email protected]9dbfff12011-07-01 19:37:07402} // namespace
[email protected]c5dbef02011-05-13 05:06:09403
[email protected]d977f9c2011-03-14 16:10:26404namespace chrome {
405
[email protected]e461da2f2012-02-16 19:06:40406ChromeContentBrowserClient::ChromeContentBrowserClient() {
407 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
408 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
[email protected]e461da2f2012-02-16 19:06:40409}
410
411ChromeContentBrowserClient::~ChromeContentBrowserClient() {
412}
413
[email protected]bca18382012-06-25 19:15:23414// static
415void ChromeContentBrowserClient::RegisterUserPrefs(PrefService* prefs) {
416 prefs->RegisterBooleanPref(prefs::kDisable3DAPIs,
417 false,
418 PrefService::UNSYNCABLE_PREF);
419 prefs->RegisterBooleanPref(prefs::kEnableHyperlinkAuditing,
420 true,
421 PrefService::UNSYNCABLE_PREF);
422 prefs->RegisterBooleanPref(prefs::kEnableMemoryInfo,
423 false,
424 PrefService::UNSYNCABLE_PREF);
425}
426
[email protected]50462bf02011-11-21 19:13:31427content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
428 const content::MainFunctionParams& parameters) {
429 ChromeBrowserMainParts* main_parts;
[email protected]b48c9182011-10-26 18:03:30430 // Construct the Main browser parts based on the OS type.
431#if defined(OS_WIN)
[email protected]50462bf02011-11-21 19:13:31432 main_parts = new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04433#elif defined(OS_MACOSX)
[email protected]50462bf02011-11-21 19:13:31434 main_parts = new ChromeBrowserMainPartsMac(parameters);
[email protected]b48c9182011-10-26 18:03:30435#elif defined(OS_CHROMEOS)
[email protected]50462bf02011-11-21 19:13:31436 main_parts = new ChromeBrowserMainPartsChromeos(parameters);
[email protected]81ce2c42012-03-24 01:43:26437#elif defined(OS_LINUX)
[email protected]50462bf02011-11-21 19:13:31438 main_parts = new ChromeBrowserMainPartsLinux(parameters);
[email protected]6e677a342012-02-11 01:21:14439#elif defined(OS_ANDROID)
[email protected]81054f812012-08-30 00:47:09440 main_parts = new ChromeBrowserMainPartsAndroid(parameters);
[email protected]b48c9182011-10-26 18:03:30441#elif defined(OS_POSIX)
[email protected]50462bf02011-11-21 19:13:31442 main_parts = new ChromeBrowserMainPartsPosix(parameters);
[email protected]f967b722011-09-07 00:58:04443#else
[email protected]b48c9182011-10-26 18:03:30444 NOTREACHED();
[email protected]50462bf02011-11-21 19:13:31445 main_parts = new ChromeBrowserMainParts(parameters);
[email protected]b48c9182011-10-26 18:03:30446#endif
447
[email protected]c7480942011-11-08 19:18:27448 // Construct additional browser parts. Stages are called in the order in
449 // which they are added.
[email protected]a13283cc2012-04-05 00:21:22450#if defined(TOOLKIT_GTK)
[email protected]684dace42012-07-01 14:30:41451 chrome::AddGtkToolkitExtraParts(main_parts);
[email protected]f967b722011-09-07 00:58:04452#endif
[email protected]c7480942011-11-08 19:18:27453
454#if defined(TOOLKIT_VIEWS)
[email protected]684dace42012-07-01 14:30:41455 chrome::AddViewsToolkitExtraParts(main_parts);
[email protected]c7480942011-11-08 19:18:27456#endif
457
[email protected]dc04be7c2012-03-15 23:57:49458#if defined(USE_ASH)
[email protected]684dace42012-07-01 14:30:41459 chrome::AddAshToolkitExtraParts(main_parts);
[email protected]dc04be7c2012-03-15 23:57:49460#endif
461
[email protected]e050ef142012-03-21 01:04:24462#if defined(USE_AURA)
[email protected]684dace42012-07-01 14:30:41463 chrome::AddAuraToolkitExtraParts(main_parts);
[email protected]e050ef142012-03-21 01:04:24464#endif
465
[email protected]50462bf02011-11-21 19:13:31466 return main_parts;
[email protected]f967b722011-09-07 00:58:04467}
468
[email protected]38b098f2012-03-14 21:11:57469content::WebContentsView*
470 ChromeContentBrowserClient::OverrideCreateWebContentsView(
[email protected]5a3bdf52012-05-24 15:12:57471 WebContents* web_contents,
472 content::RenderViewHostDelegateView** render_view_host_delegate_view) {
[email protected]38b098f2012-03-14 21:11:57473 return NULL;
474}
475
[email protected]e94bbcb2012-09-07 05:33:57476std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite(
[email protected]d1198fd2012-08-13 22:50:19477 content::BrowserContext* browser_context,
[email protected]e94bbcb2012-09-07 05:33:57478 const GURL& site) {
[email protected]1bc28312012-11-08 08:31:53479 std::string partition_id;
480
481 // The partition ID for webview guest processes is the string value of its
482 // SiteInstance URL - "chrome-guest://app_id/persist?partition".
483 if (site.SchemeIs(chrome::kGuestScheme))
484 partition_id = site.spec();
485
486 DCHECK(IsValidStoragePartitionId(browser_context,partition_id));
487 return partition_id;
488}
489
490bool ChromeContentBrowserClient::IsValidStoragePartitionId(
491 content::BrowserContext* browser_context,
492 const std::string& partition_id) {
493 // The default ID is empty and is always valid.
494 if (partition_id.empty())
495 return true;
496
497 return GURL(partition_id).is_valid();
498}
499
500void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
501 content::BrowserContext* browser_context,
502 const GURL& site,
503 std::string* partition_domain,
504 std::string* partition_name,
505 bool* in_memory) {
506 // For the webview tag, we create special guest processes, which host the
507 // tag content separately from the main application that embeds the tag.
508 // A webview tag can specify both the partition name and whether the storage
509 // for that partition should be persisted. Each tag gets a SiteInstance with
510 // a specially formatted URL, based on the application it is hosted by and
511 // the partition requested by it. The format for that URL is:
512 // chrome-guest://partition_domain/persist?partition_name
513 if (site.SchemeIs(chrome::kGuestScheme)) {
514 // Since guest URLs are only used for packaged apps, there must be an app
515 // id in the URL.
516 CHECK(site.has_host());
517 *partition_domain = site.host();
518 // Since persistence is optional, the path must either be empty or the
519 // literal string.
520 *in_memory = (site.path() != "/persist");
521 // The partition name is user supplied value, which we have encoded when the
522 // URL was created, so it needs to be decoded.
523 *partition_name = net::UnescapeURLComponent(site.query(),
524 net::UnescapeRule::NORMAL);
525 return;
526 }
527
[email protected]d1198fd2012-08-13 22:50:19528 const Extension* extension = NULL;
529 Profile* profile = Profile::FromBrowserContext(browser_context);
530 ExtensionService* extension_service =
531 extensions::ExtensionSystem::Get(profile)->extension_service();
532 if (extension_service) {
533 extension = extension_service->extensions()->
[email protected]e94bbcb2012-09-07 05:33:57534 GetExtensionOrAppByURL(ExtensionURLInfo(site));
[email protected]1bc28312012-11-08 08:31:53535 if (extension && extension->is_storage_isolated()) {
536 // Extensions which have storage isolation enabled (e.g., apps), use
537 // the extension id as the |partition_domain|.
538 *partition_domain = extension->id();
539 partition_name->clear();
540 *in_memory = false;
541 return;
542 }
[email protected]d1198fd2012-08-13 22:50:19543 }
544
[email protected]1bc28312012-11-08 08:31:53545 // All other cases use the default, browser-wide, storage partition.
546 partition_domain->clear();
547 partition_name->clear();
548 *in_memory = false;
[email protected]d7c7c98a2012-07-12 21:27:44549}
550
[email protected]38b098f2012-03-14 21:11:57551content::WebContentsViewDelegate*
552 ChromeContentBrowserClient::GetWebContentsViewDelegate(
553 content::WebContents* web_contents) {
[email protected]d33220292012-07-04 01:41:27554 return chrome::CreateWebContentsViewDelegate(web_contents);
[email protected]74313b42011-08-24 16:51:32555}
556
[email protected]f364d1392011-04-08 21:03:10557void ChromeContentBrowserClient::RenderViewHostCreated(
558 RenderViewHost* render_view_host) {
[email protected]67372ecf2011-09-10 01:30:46559
[email protected]9f76c1e2012-03-05 15:15:58560 SiteInstance* site_instance = render_view_host->GetSiteInstance();
[email protected]67372ecf2011-09-10 01:30:46561 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02562 site_instance->GetBrowserContext());
[email protected]67372ecf2011-09-10 01:30:46563
564 new ChromeRenderViewHostObserver(render_view_host,
565 profile->GetNetworkPredictor());
[email protected]40404bc2012-07-25 17:40:49566 new extensions::MessageHandler(render_view_host);
[email protected]d977f9c2011-03-14 16:10:26567}
568
[email protected]f3b1a082011-11-18 00:34:30569void ChromeContentBrowserClient::RenderProcessHostCreated(
570 content::RenderProcessHost* host) {
571 int id = host->GetID();
572 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
573 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]c47cfd62011-04-29 21:27:02574 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]f3b1a082011-11-18 00:34:30575 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
[email protected]658677f2012-06-09 06:04:02576#if defined(ENABLE_PRINTING)
[email protected]0045b0f42012-07-26 11:52:08577 host->GetChannel()->AddFilter(new PrintingMessageFilter(id, profile));
[email protected]058e5732012-03-01 22:48:03578#endif
[email protected]f3b1a082011-11-18 00:34:30579 host->GetChannel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02580 new SearchProviderInstallStateMessageFilter(id, profile));
[email protected]f3b1a082011-11-18 00:34:30581 host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]7ceb99012011-12-21 08:05:56582#if defined(OS_MACOSX)
583 host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac());
584#endif
[email protected]f3b1a082011-11-18 00:34:30585 host->GetChannel()->AddFilter(new ChromeBenchmarkingMessageFilter(
[email protected]6f08af82011-09-15 01:19:03586 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]2736c032012-05-11 18:06:07587 host->GetChannel()->AddFilter(
588 new prerender::PrerenderMessageFilter(id, profile));
[email protected]3e69bc82011-05-26 23:22:38589
[email protected]2ccf45c2011-08-19 23:35:50590 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
591 profile->IsOffTheRecord()));
[email protected]39a5b532011-10-22 01:47:07592
593 SendExtensionWebRequestStatusToHost(host);
[email protected]edece212011-11-16 11:56:56594
595 RendererContentSettingRules rules;
596 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules);
597 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
[email protected]40da3e0c2012-10-24 22:03:38598
599#if defined(OS_ANDROID) && defined(USE_LINUX_BREAKPAD)
600 InitCrashDumpManager();
601#endif
[email protected]05fcf982011-04-19 00:44:14602}
603
[email protected]e0ada9c2012-03-20 03:54:43604void ChromeContentBrowserClient::BrowserChildProcessHostCreated(
605 content::BrowserChildProcessHost* host) {
606 host->GetHost()->AddFilter(new PepperGtalkMessageFilter());
607}
608
[email protected]863f70a2012-01-27 02:05:50609content::WebUIControllerFactory*
610 ChromeContentBrowserClient::GetWebUIControllerFactory() {
611 return ChromeWebUIControllerFactory::GetInstance();
[email protected]1fd1a502011-03-30 16:55:56612}
613
[email protected]3d7474ff2011-07-27 17:47:37614GURL ChromeContentBrowserClient::GetEffectiveURL(
615 content::BrowserContext* browser_context, const GURL& url) {
616 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]36fb2c7c2011-04-04 15:49:08617 // Get the effective URL for the given actual URL. If the URL is part of an
618 // installed app, the effective URL is an extension URL with the ID of that
619 // extension as the host. This has the effect of grouping apps together in
620 // a common SiteInstance.
621 if (!profile || !profile->GetExtensionService())
622 return url;
623
[email protected]615d88f2011-12-13 01:47:44624 const Extension* extension = profile->GetExtensionService()->extensions()->
625 GetHostedAppByURL(ExtensionURLInfo(url));
[email protected]36fb2c7c2011-04-04 15:49:08626 if (!extension)
627 return url;
628
[email protected]15877ca2011-11-18 22:40:52629 // Bookmark apps do not use the hosted app process model, and should be
630 // treated as normal URLs.
631 if (extension->from_bookmark())
632 return url;
633
[email protected]36fb2c7c2011-04-04 15:49:08634 // If the URL is part of an extension's web extent, convert it to an
635 // extension URL.
636 return extension->GetResourceURL(url.path());
637}
638
[email protected]056ad2a2011-07-12 02:13:55639bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37640 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]056ad2a2011-07-12 02:13:55641 // Non-extension URLs should generally use process-per-site-instance.
[email protected]15877ca2011-11-18 22:40:52642 // Because we expect to use the effective URL, URLs for hosted apps (apart
643 // from bookmark apps) should have an extension scheme by now.
[email protected]056ad2a2011-07-12 02:13:55644 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
645 return false;
646
[email protected]3d7474ff2011-07-27 17:47:37647 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]056ad2a2011-07-12 02:13:55648 if (!profile || !profile->GetExtensionService())
649 return false;
650
[email protected]615d88f2011-12-13 01:47:44651 const Extension* extension = profile->GetExtensionService()->extensions()->
652 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
[email protected]056ad2a2011-07-12 02:13:55653 if (!extension)
654 return false;
655
656 // If the URL is part of a hosted app that does not have the background
[email protected]7b54ca02012-03-02 18:06:53657 // permission, or that does not allow JavaScript access to the background
658 // page, we want to give each instance its own process to improve
[email protected]056ad2a2011-07-12 02:13:55659 // responsiveness.
[email protected]7b54ca02012-03-02 18:06:53660 if (extension->GetType() == Extension::TYPE_HOSTED_APP) {
[email protected]c2e66e12012-06-27 06:27:06661 if (!extension->HasAPIPermission(APIPermission::kBackground) ||
[email protected]7b54ca02012-03-02 18:06:53662 !extension->allow_background_js_access()) {
663 return false;
664 }
665 }
[email protected]056ad2a2011-07-12 02:13:55666
[email protected]7b54ca02012-03-02 18:06:53667 // Hosted apps that have script access to their background page must use
668 // process per site, since all instances can make synchronous calls to the
669 // background window. Other extensions should use process per site as well.
[email protected]056ad2a2011-07-12 02:13:55670 return true;
671}
672
[email protected]46fb9442011-12-09 17:57:47673bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
674 return ProfileIOData::IsHandledURL(url);
675}
676
[email protected]2a5221b2011-09-27 23:07:31677bool ChromeContentBrowserClient::IsSuitableHost(
[email protected]f3b1a082011-11-18 00:34:30678 content::RenderProcessHost* process_host,
[email protected]2a5221b2011-09-27 23:07:31679 const GURL& site_url) {
680 Profile* profile =
[email protected]f3b1a082011-11-18 00:34:30681 Profile::FromBrowserContext(process_host->GetBrowserContext());
[email protected]8d3132f62011-10-12 07:13:42682 ExtensionService* service = profile->GetExtensionService();
[email protected]6f371442011-11-09 06:45:46683 extensions::ProcessMap* process_map = service->process_map();
[email protected]2a5221b2011-09-27 23:07:31684
[email protected]ffa97602011-11-17 17:55:52685 // Don't allow the Task Manager to share a process with anything else.
686 // Otherwise it can affect the renderers it is observing.
687 // Note: we could create another RenderProcessHostPrivilege bucket for
688 // this to allow multiple chrome://tasks instances to share, but that's
689 // a very unlikely case without serious consequences.
690 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin())
691 return false;
692
[email protected]8d3132f62011-10-12 07:13:42693 // These may be NULL during tests. In that case, just assume any site can
694 // share any host.
[email protected]6f371442011-11-09 06:45:46695 if (!service || !process_map)
[email protected]2a5221b2011-09-27 23:07:31696 return true;
697
[email protected]a8c269a2011-10-25 20:17:22698 // Experimental:
699 // If --enable-strict-site-isolation is enabled, do not allow non-WebUI pages
700 // to share a renderer process. (We could allow pages from the same site or
701 // extensions of the same type to share, if we knew what the given process
702 // was dedicated to. Allowing no sharing is simpler for now.) This may
703 // cause resource exhaustion issues if too many sites are open at once.
704 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
705 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation))
706 return false;
707
[email protected]eec0b33c2011-12-05 22:09:45708 // Otherwise, just make sure the process privilege matches the privilege
709 // required by the site.
[email protected]e94bbcb2012-09-07 05:33:57710 RenderProcessHostPrivilege privilege_required =
711 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]eec0b33c2011-12-05 22:09:45712 return GetProcessPrivilege(process_host, process_map, service) ==
713 privilege_required;
[email protected]2a5221b2011-09-27 23:07:31714}
715
[email protected]76411f412012-02-22 18:56:06716// This function is trying to limit the amount of processes used by extensions
717// with background pages. It uses a globally set percentage of processes to
718// run such extensions and if the limit is exceeded, it returns true, to
719// indicate to the content module to group extensions together.
720bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
721 content::BrowserContext* browser_context, const GURL& url) {
722 // It has to be a valid URL for us to check for an extension.
723 if (!url.is_valid())
724 return false;
725
726 Profile* profile = Profile::FromBrowserContext(browser_context);
727 ExtensionService* service = profile->GetExtensionService();
728 if (!service)
729 return false;
730
731 // We have to have a valid extension with background page to proceed.
732 const Extension* extension =
733 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
734 if (!extension)
735 return false;
736 if (!extension->has_background_page())
737 return false;
738
739 std::set<int> process_ids;
740 size_t max_process_count =
741 content::RenderProcessHost::GetMaxRendererProcessCount();
742
743 // Go through all profiles to ensure we have total count of extension
744 // processes containing background pages, otherwise one profile can
745 // starve the other.
746 std::vector<Profile*> profiles = g_browser_process->profile_manager()->
747 GetLoadedProfiles();
748 for (size_t i = 0; i < profiles.size(); ++i) {
[email protected]be93bba02012-10-24 16:44:03749 ExtensionProcessManager* epm =
750 extensions::ExtensionSystem::Get(profiles[i])->process_manager();
[email protected]d1fe1352012-04-26 00:47:32751 for (ExtensionProcessManager::const_iterator iter =
752 epm->background_hosts().begin();
753 iter != epm->background_hosts().end(); ++iter) {
[email protected]3a1dc572012-07-31 22:25:13754 const extensions::ExtensionHost* host = *iter;
[email protected]d1fe1352012-04-26 00:47:32755 process_ids.insert(host->render_process_host()->GetID());
[email protected]76411f412012-02-22 18:56:06756 }
757 }
758
759 if (process_ids.size() >
760 (max_process_count * chrome::kMaxShareOfExtensionProcesses)) {
761 return true;
762 }
763
764 return false;
765}
766
[email protected]6f371442011-11-09 06:45:46767void ChromeContentBrowserClient::SiteInstanceGotProcess(
768 SiteInstance* site_instance) {
769 CHECK(site_instance->HasProcess());
770
771 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02772 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46773 ExtensionService* service = profile->GetExtensionService();
774 if (!service)
775 return;
776
777 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44778 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
[email protected]77ab17312012-09-28 15:34:59779 site_instance->GetSiteURL()));
[email protected]6f371442011-11-09 06:45:46780 if (!extension)
781 return;
782
[email protected]6bc04fd82011-12-04 02:29:35783 service->process_map()->Insert(extension->id(),
784 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33785 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46786 BrowserThread::PostTask(
787 BrowserThread::IO, FROM_HERE,
788 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
[email protected]bd306722012-07-11 20:43:59789 extensions::ExtensionSystem::Get(profile)->info_map(),
[email protected]6f371442011-11-09 06:45:46790 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35791 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33792 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46793}
794
795void ChromeContentBrowserClient::SiteInstanceDeleting(
796 SiteInstance* site_instance) {
797 if (!site_instance->HasProcess())
798 return;
799
800 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:02801 site_instance->GetBrowserContext());
[email protected]6f371442011-11-09 06:45:46802 ExtensionService* service = profile->GetExtensionService();
803 if (!service)
804 return;
805
806 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44807 service->extensions()->GetExtensionOrAppByURL(
[email protected]77ab17312012-09-28 15:34:59808 ExtensionURLInfo(site_instance->GetSiteURL()));
[email protected]6f371442011-11-09 06:45:46809 if (!extension)
810 return;
811
[email protected]6bc04fd82011-12-04 02:29:35812 service->process_map()->Remove(extension->id(),
813 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33814 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:46815 BrowserThread::PostTask(
816 BrowserThread::IO, FROM_HERE,
817 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
[email protected]bd306722012-07-11 20:43:59818 extensions::ExtensionSystem::Get(profile)->info_map(),
[email protected]6f371442011-11-09 06:45:46819 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:35820 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:33821 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:46822}
823
[email protected]f05763972012-06-06 18:17:26824bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
[email protected]e3daf3c2011-10-05 21:17:08825 const GURL& current_url,
826 const GURL& new_url) {
[email protected]f05763972012-06-06 18:17:26827 if (current_url.is_empty()) {
828 // Always choose a new process when navigating to extension URLs. The
829 // process grouping logic will combine all of a given extension's pages
830 // into the same process.
831 if (new_url.SchemeIs(chrome::kExtensionScheme))
832 return true;
[email protected]e3daf3c2011-10-05 21:17:08833
[email protected]f05763972012-06-06 18:17:26834 return false;
835 }
836
837 // Also, we must switch if one is an extension and the other is not the exact
838 // same extension.
839 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
840 new_url.SchemeIs(chrome::kExtensionScheme)) {
841 if (current_url.GetOrigin() != new_url.GetOrigin())
842 return true;
843 }
844
845 return false;
[email protected]e3daf3c2011-10-05 21:17:08846}
847
[email protected]395045c2012-05-22 15:04:38848bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
849 content::ResourceContext* resource_context, const GURL& current_url,
850 const GURL& new_url) {
851 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
852 return extensions::CrossesExtensionProcessBoundary(
853 io_data->GetExtensionInfoMap()->extensions(),
[email protected]ea7b7d82012-05-25 17:29:17854 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
[email protected]395045c2012-05-22 15:04:38855}
856
[email protected]763ec4ca2011-04-29 15:48:12857std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
858 const std::string& alias_name) {
859 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
860}
861
[email protected]b80f68432011-05-02 17:22:30862void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
863 CommandLine* command_line, int child_process_id) {
864#if defined(USE_LINUX_BREAKPAD)
865 if (IsCrashReporterEnabled()) {
866 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
867 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
868 }
869#elif defined(OS_MACOSX)
870 if (IsCrashReporterEnabled()) {
871 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
872 child_process_logging::GetClientId());
873 }
874#endif // OS_MACOSX
875
[email protected]f1933792011-06-14 00:49:34876 if (logging::DialogsAreSuppressed())
877 command_line->AppendSwitch(switches::kNoErrorDialogs);
878
[email protected]b80f68432011-05-02 17:22:30879 std::string process_type =
880 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:17881 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]718eab62011-10-05 21:16:52882 if (process_type == switches::kRendererProcess) {
[email protected]b80f68432011-05-02 17:22:30883 FilePath user_data_dir =
884 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
885 if (!user_data_dir.empty())
886 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
887#if defined(OS_CHROMEOS)
888 const std::string& login_profile =
889 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile);
890 if (!login_profile.empty())
891 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile);
892#endif
893
[email protected]f3b1a082011-11-18 00:34:30894 content::RenderProcessHost* process =
895 content::RenderProcessHost::FromID(child_process_id);
[email protected]a8d851f82011-12-21 00:32:37896 if (process) {
897 Profile* profile = Profile::FromBrowserContext(
898 process->GetBrowserContext());
[email protected]c8598d42012-09-25 21:17:00899 if (profile->GetExtensionService()) {
900 extensions::ProcessMap* process_map =
901 profile->GetExtensionService()->process_map();
902 if (process_map && process_map->Contains(process->GetID()))
903 command_line->AppendSwitch(switches::kExtensionProcess);
904 }
[email protected]b80f68432011-05-02 17:22:30905
[email protected]a8d851f82011-12-21 00:32:37906 PrefService* prefs = profile->GetPrefs();
907 // Currently this pref is only registered if applied via a policy.
908 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
909 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
910 // Turn this policy into a command line switch.
911 command_line->AppendSwitch(switches::kDisable3DAPIs);
912 }
[email protected]718eab62011-10-05 21:16:52913
[email protected]a8d851f82011-12-21 00:32:37914 // Disable client-side phishing detection in the renderer if it is
915 // disabled in the Profile preferences or the browser process.
916 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
917 !g_browser_process->safe_browsing_detection_service()) {
918 command_line->AppendSwitch(
919 switches::kDisableClientSidePhishingDetection);
920 }
[email protected]0045b0f42012-07-26 11:52:08921
922 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled))
[email protected]47c7ec82012-01-18 03:29:21923 command_line->AppendSwitch(switches::kRendererPrintPreview);
[email protected]47c7ec82012-01-18 03:29:21924 }
[email protected]4287a3d2011-06-13 23:56:51925
[email protected]87552982012-11-02 17:21:40926 if (content::IsThreadedCompositingEnabled())
927 command_line->AppendSwitch(switches::kEnableThreadedCompositing);
928
[email protected]47c7ec82012-01-18 03:29:21929 // Please keep this in alphabetical order.
[email protected]4287a3d2011-06-13 23:56:51930 static const char* const kSwitchNames[] = {
931 switches::kAllowHTTPBackgroundPage,
[email protected]70f48c02011-12-02 21:27:48932 switches::kAllowLegacyExtensionManifests,
[email protected]4287a3d2011-06-13 23:56:51933 switches::kAllowScriptingGallery,
934 switches::kAppsCheckoutURL,
935 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:31936 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:51937 switches::kDebugPrint,
[email protected]382fb0d2012-02-25 00:19:50938 switches::kDisableBundledPpapiFlash,
[email protected]e9dfe222012-05-11 22:05:53939 switches::kDisableExtensionsResourceWhitelist,
[email protected]b0553c7e2012-09-19 21:36:11940 switches::kDisableScriptedPrintThrottling,
[email protected]4287a3d2011-06-13 23:56:51941 switches::kDumpHistogramsOnExit,
[email protected]47c7ec82012-01-18 03:29:21942 switches::kEnableBenchmarking,
[email protected]b50368b2012-02-18 00:02:13943 switches::kEnableBundledPpapiFlash,
[email protected]4e7d1a22012-11-06 13:57:03944 switches::kEnableChromeStyleDialogs,
[email protected]4287a3d2011-06-13 23:56:51945 switches::kEnableCrxlessWebApps,
946 switches::kEnableExperimentalExtensionApis,
[email protected]4287a3d2011-06-13 23:56:51947 switches::kEnableIPCFuzzing,
[email protected]aa75e4ed2012-11-08 23:51:51948 switches::kEnableInteractiveAutocomplete,
[email protected]4287a3d2011-06-13 23:56:51949 switches::kEnableNaCl,
[email protected]45a9c0a2012-11-08 21:00:29950 switches::kEnableNaClSRPCProxy,
[email protected]bcbe7652012-02-22 00:08:48951 switches::kEnablePasswordGeneration,
[email protected]284b03c2012-08-13 17:55:05952 switches::kEnablePnacl,
[email protected]4287a3d2011-06-13 23:56:51953 switches::kEnableWatchdog,
[email protected]4287a3d2011-06-13 23:56:51954 switches::kMemoryProfiling,
955 switches::kMessageLoopHistogrammer,
[email protected]f45c5f32012-04-18 19:26:37956 switches::kNoJsRandomness,
[email protected]732b1604e2012-10-26 19:59:58957 switches::kPerformCrashAnalysis,
[email protected]f45c5f32012-04-18 19:26:37958 switches::kPlaybackMode,
[email protected]4287a3d2011-06-13 23:56:51959 switches::kPpapiFlashArgs,
960 switches::kPpapiFlashInProcess,
961 switches::kPpapiFlashPath,
962 switches::kPpapiFlashVersion,
963 switches::kProfilingAtStart,
964 switches::kProfilingFile,
965 switches::kProfilingFlush,
[email protected]f45c5f32012-04-18 19:26:37966 switches::kRecordMode,
[email protected]4287a3d2011-06-13 23:56:51967 switches::kSilentDumpOnDCHECK,
[email protected]c79d9492012-10-04 19:56:30968 switches::kSpdyProxyOrigin,
[email protected]a446534d2012-02-09 00:07:38969 switches::kWhitelistedExtensionID,
[email protected]4287a3d2011-06-13 23:56:51970 };
971
972 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
973 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17974 } else if (process_type == switches::kUtilityProcess) {
[email protected]a446534d2012-02-09 00:07:38975 static const char* const kSwitchNames[] = {
[email protected]eb653f82012-05-24 02:31:35976 switches::kAllowHTTPBackgroundPage,
[email protected]a446534d2012-02-09 00:07:38977 switches::kEnableExperimentalExtensionApis,
978 switches::kWhitelistedExtensionID,
979 };
980
981 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
982 arraysize(kSwitchNames));
[email protected]4287a3d2011-06-13 23:56:51983 } else if (process_type == switches::kPluginProcess) {
984 static const char* const kSwitchNames[] = {
985 #if defined(OS_CHROMEOS)
986 switches::kLoginProfile,
987 #endif
988 switches::kMemoryProfiling,
989 switches::kSilentDumpOnDCHECK,
990 switches::kUserDataDir,
991 };
992
993 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
994 arraysize(kSwitchNames));
995 } else if (process_type == switches::kZygoteProcess) {
996 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51997 switches::kUserDataDir, // Make logs go to the right file.
998 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
[email protected]382fb0d2012-02-25 00:19:50999 switches::kDisableBundledPpapiFlash,
[email protected]b50368b2012-02-18 00:02:131000 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:511001 switches::kPpapiFlashInProcess,
1002 switches::kPpapiFlashPath,
1003 switches::kPpapiFlashVersion,
1004 };
1005
1006 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1007 arraysize(kSwitchNames));
[email protected]d56ecf922012-02-15 16:03:111008 } else if (process_type == switches::kGpuProcess) {
1009 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
1010 // because GPU is expected to be unreliable.
1011 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) &&
1012 !command_line->HasSwitch(switches::kDisableBreakpad))
1013 command_line->AppendSwitch(switches::kDisableBreakpad);
[email protected]b80f68432011-05-02 17:22:301014 }
[email protected]6f08af82011-09-15 01:19:031015
1016 // The command line switch kEnableBenchmarking needs to be specified along
1017 // with the kEnableStatsTable switch to ensure that the stats table global
1018 // is initialized correctly.
1019 if (command_line->HasSwitch(switches::kEnableBenchmarking))
1020 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:301021}
1022
1023std::string ChromeContentBrowserClient::GetApplicationLocale() {
[email protected]e9a32a52012-06-14 23:32:431024 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
1025 return io_thread_application_locale_;
[email protected]b80f68432011-05-02 17:22:301026 return g_browser_process->GetApplicationLocale();
1027}
1028
[email protected]597a867b2011-11-18 18:31:201029std::string ChromeContentBrowserClient::GetAcceptLangs(
1030 content::BrowserContext* context) {
1031 Profile* profile = Profile::FromBrowserContext(context);
[email protected]3d7474ff2011-07-27 17:47:371032 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:081033}
1034
[email protected]9ec0f452012-05-31 15:58:531035gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() {
[email protected]7c3228a2011-11-11 21:35:221036 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
[email protected]9ec0f452012-05-31 15:58:531037 return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
[email protected]ac55e292011-06-24 05:16:081038}
1039
[email protected]a2176792011-05-08 19:30:491040bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:091041 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:191042 const GURL& first_party,
[email protected]df02aca2012-02-09 21:03:201043 content::ResourceContext* context) {
[email protected]8093a542011-05-13 07:29:321044 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201045 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051046 return io_data->GetCookieSettings()->
1047 IsSettingCookieAllowed(manifest_url, first_party);
[email protected]a2176792011-05-08 19:30:491048}
1049
[email protected]ed24fad2011-05-10 22:44:011050bool ChromeContentBrowserClient::AllowGetCookie(
1051 const GURL& url,
1052 const GURL& first_party,
1053 const net::CookieList& cookie_list,
[email protected]df02aca2012-02-09 21:03:201054 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011055 int render_process_id,
1056 int render_view_id) {
1057 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201058 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051059 bool allow = io_data->GetCookieSettings()->
1060 IsReadingCookieAllowed(url, first_party);
[email protected]ed24fad2011-05-10 22:44:011061
[email protected]8093a542011-05-13 07:29:321062 BrowserThread::PostTask(
1063 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031064 base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
[email protected]fd473d12012-04-05 11:38:431065 render_view_id, url, first_party, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:011066 return allow;
1067}
1068
1069bool ChromeContentBrowserClient::AllowSetCookie(
1070 const GURL& url,
1071 const GURL& first_party,
1072 const std::string& cookie_line,
[email protected]df02aca2012-02-09 21:03:201073 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011074 int render_process_id,
1075 int render_view_id,
1076 net::CookieOptions* options) {
1077 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201078 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051079 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1080 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
1081
[email protected]8093a542011-05-13 07:29:321082 BrowserThread::PostTask(
1083 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031084 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
[email protected]fd473d12012-04-05 11:38:431085 render_view_id, url, first_party, cookie_line, *options,
1086 !allow));
[email protected]ed24fad2011-05-10 22:44:011087 return allow;
1088}
1089
[email protected]ea628e32012-08-02 21:50:161090bool ChromeContentBrowserClient::AllowPluginLocalDataAccess(
1091 const GURL& document_url,
1092 const GURL& plugin_url,
1093 content::ResourceContext* context) {
1094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1095 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1096 return io_data->GetCookieSettings()->IsReadingCookieAllowed(document_url,
1097 plugin_url);
1098}
1099
1100bool ChromeContentBrowserClient::AllowPluginLocalDataSessionOnly(
1101 const GURL& url,
1102 content::ResourceContext* context) {
1103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1104 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1105 return io_data->GetCookieSettings()->IsCookieSessionOnly(url);
1106}
1107
[email protected]d5a19162011-06-30 18:51:541108bool ChromeContentBrowserClient::AllowSaveLocalState(
[email protected]df02aca2012-02-09 21:03:201109 content::ResourceContext* context) {
[email protected]d5a19162011-06-30 18:51:541110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201111 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]bf510ed2012-06-05 08:31:431112 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1113 ContentSetting setting = cookie_settings->GetDefaultCookieSetting(NULL);
[email protected]1848cdc2012-02-17 10:48:261114
[email protected]bf510ed2012-06-05 08:31:431115 // TODO(bauerb): Should we also disallow local state if the default is BLOCK?
1116 // Could we even support per-origin settings?
1117 return setting != CONTENT_SETTING_SESSION_ONLY;
[email protected]d5a19162011-06-30 18:51:541118}
1119
[email protected]5c5a88e2011-11-12 00:45:351120bool ChromeContentBrowserClient::AllowWorkerDatabase(
[email protected]5c5a88e2011-11-12 00:45:351121 const GURL& url,
1122 const string16& name,
1123 const string16& display_name,
1124 unsigned long estimated_size,
[email protected]df02aca2012-02-09 21:03:201125 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481126 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201128 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351129 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1130 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1131
[email protected]62151052012-02-01 18:40:481132 // Record access to database for potential display in UI.
1133 std::vector<std::pair<int, int> >::const_iterator i;
1134 for (i = render_views.begin(); i != render_views.end(); ++i) {
1135 BrowserThread::PostTask(
1136 BrowserThread::UI, FROM_HERE,
1137 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
1138 i->first, i->second, url, name, display_name, !allow));
[email protected]5c5a88e2011-11-12 00:45:351139 }
1140
1141 return allow;
1142}
1143
1144bool ChromeContentBrowserClient::AllowWorkerFileSystem(
[email protected]5c5a88e2011-11-12 00:45:351145 const GURL& url,
[email protected]df02aca2012-02-09 21:03:201146 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481147 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201149 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351150 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1151 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1152
[email protected]62151052012-02-01 18:40:481153 // Record access to file system for potential display in UI.
1154 std::vector<std::pair<int, int> >::const_iterator i;
1155 for (i = render_views.begin(); i != render_views.end(); ++i) {
1156 BrowserThread::PostTask(
1157 BrowserThread::UI, FROM_HERE,
1158 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
1159 i->first, i->second, url, !allow));
[email protected]5c5a88e2011-11-12 00:45:351160 }
1161
1162 return allow;
1163}
1164
[email protected]7c5ff9a2012-03-02 07:42:491165bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
1166 const GURL& url,
1167 const string16& name,
1168 content::ResourceContext* context,
1169 const std::vector<std::pair<int, int> >& render_views) {
1170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1171 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1172 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1173 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1174
1175 // Record access to IndexedDB for potential display in UI.
1176 std::vector<std::pair<int, int> >::const_iterator i;
1177 for (i = render_views.begin(); i != render_views.end(); ++i) {
1178 BrowserThread::PostTask(
1179 BrowserThread::UI, FROM_HERE,
1180 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
1181 i->first, i->second, url, name, !allow));
1182 }
1183
1184 return allow;
1185}
1186
[email protected]6133f922011-07-01 21:34:341187net::URLRequestContext*
1188ChromeContentBrowserClient::OverrideRequestContextForURL(
[email protected]df02aca2012-02-09 21:03:201189 const GURL& url, content::ResourceContext* context) {
[email protected]6133f922011-07-01 21:34:341190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1191 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]df02aca2012-02-09 21:03:201192 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]6133f922011-07-01 21:34:341193 return io_data->extensions_request_context();
1194 }
1195
1196 return NULL;
1197}
1198
[email protected]317f96c92011-05-31 06:53:411199QuotaPermissionContext*
1200ChromeContentBrowserClient::CreateQuotaPermissionContext() {
1201 return new ChromeQuotaPermissionContext();
1202}
1203
[email protected]a0ce3282011-08-19 20:49:521204void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:421205 platform_util::OpenItem(path);
[email protected]0609b17f2011-05-31 20:13:421206}
1207
[email protected]a0ce3282011-08-19 20:49:521208void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
[email protected]a0ce3282011-08-19 20:49:521209 platform_util::ShowItemInFolder(path);
[email protected]a0ce3282011-08-19 20:49:521210}
1211
[email protected]848dd042011-06-04 18:24:031212void ChromeContentBrowserClient::AllowCertificateError(
[email protected]4cf611e32012-02-13 16:06:171213 int render_process_id,
1214 int render_view_id,
1215 int cert_error,
1216 const net::SSLInfo& ssl_info,
1217 const GURL& request_url,
[email protected]848dd042011-06-04 18:24:031218 bool overridable,
[email protected]d9be47702012-05-16 03:41:221219 bool strict_enforcement,
[email protected]4cf611e32012-02-13 16:06:171220 const base::Callback<void(bool)>& callback,
1221 bool* cancel_request) {
[email protected]f9034cf2011-07-21 12:43:411222 // If the tab is being prerendered, cancel the prerender and the request.
[email protected]83ff91c2012-01-05 20:54:131223 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]4cf611e32012-02-13 16:06:171224 render_process_id, render_view_id);
[email protected]f9034cf2011-07-21 12:43:411225 if (!tab) {
1226 NOTREACHED();
1227 return;
1228 }
1229 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:501230 prerender::PrerenderManagerFactory::GetForProfile(
[email protected]627e0512011-12-21 22:55:301231 Profile::FromBrowserContext(tab->GetBrowserContext()));
[email protected]3a6ec762012-10-17 16:01:011232 if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab,
1233 NULL)) {
[email protected]f9034cf2011-07-21 12:43:411234 if (prerender_manager->prerender_tracker()->TryCancel(
[email protected]4cf611e32012-02-13 16:06:171235 render_process_id, render_view_id,
[email protected]f9034cf2011-07-21 12:43:411236 prerender::FINAL_STATUS_SSL_ERROR)) {
[email protected]4cf611e32012-02-13 16:06:171237 *cancel_request = true;
[email protected]f9034cf2011-07-21 12:43:411238 return;
1239 }
1240 }
1241
[email protected]1e87df32012-09-12 04:53:191242#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
[email protected]eb0b9dd2012-09-19 21:36:231243 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
1244 captive_portal::CaptivePortalTabHelper::FromWebContents(tab);
1245 if (captive_portal_tab_helper)
1246 captive_portal_tab_helper->OnSSLCertError(ssl_info);
[email protected]1e87df32012-09-12 04:53:191247#endif
1248
[email protected]f9034cf2011-07-21 12:43:411249 // Otherwise, display an SSL blocking page.
[email protected]d9be47702012-05-16 03:41:221250 new SSLBlockingPage(tab, cert_error, ssl_info, request_url, overridable,
1251 strict_enforcement, callback);
[email protected]848dd042011-06-04 18:24:031252}
1253
[email protected]c99c442e2011-08-24 11:37:301254void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:451255 int render_process_id,
1256 int render_view_id,
[email protected]7a593db2012-02-13 21:19:401257 const net::HttpNetworkSession* network_session,
1258 net::SSLCertRequestInfo* cert_request_info,
1259 const base::Callback<void(net::X509Certificate*)>& callback) {
[email protected]83ff91c2012-01-05 20:54:131260 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]8ec26472011-06-06 16:52:451261 render_process_id, render_view_id);
1262 if (!tab) {
1263 NOTREACHED();
1264 return;
1265 }
1266
[email protected]6786bf402011-12-03 15:19:451267 GURL requesting_url("https://" + cert_request_info->host_and_port);
1268 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
1269 << cert_request_info->host_and_port;
1270
[email protected]627e0512011-12-21 22:55:301271 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
[email protected]6786bf402011-12-03 15:19:451272 scoped_ptr<Value> filter(
1273 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1274 requesting_url,
1275 requesting_url,
1276 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1277 std::string(), NULL));
1278
1279 if (filter.get()) {
1280 // Try to automatically select a client certificate.
1281 if (filter->IsType(Value::TYPE_DICTIONARY)) {
1282 DictionaryValue* filter_dict =
1283 static_cast<DictionaryValue*>(filter.get());
1284
1285 const std::vector<scoped_refptr<net::X509Certificate> >&
1286 all_client_certs = cert_request_info->client_certs;
1287 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1288 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
1289 // Use the first certificate that is matched by the filter.
[email protected]7a593db2012-02-13 21:19:401290 callback.Run(all_client_certs[i]);
[email protected]6786bf402011-12-03 15:19:451291 return;
1292 }
1293 }
1294 } else {
1295 NOTREACHED();
1296 }
1297 }
1298
[email protected]11feec322012-09-18 03:58:521299 SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab);
1300 if (!ssl_tab_helper) {
1301 // If there is no SSLTabHelper for the given WebContents then we can't
[email protected]6786bf402011-12-03 15:19:451302 // show the user a dialog to select a client certificate. So we simply
[email protected]2a349e92011-12-07 12:00:141303 // proceed with no client certificate.
[email protected]7a593db2012-02-13 21:19:401304 callback.Run(NULL);
[email protected]6786bf402011-12-03 15:19:451305 return;
1306 }
[email protected]11feec322012-09-18 03:58:521307 ssl_tab_helper->ShowClientCertificateRequestDialog(
[email protected]7a593db2012-02-13 21:19:401308 network_session, cert_request_info, callback);
[email protected]8ec26472011-06-06 16:52:451309}
1310
1311void ChromeContentBrowserClient::AddNewCertificate(
1312 net::URLRequest* request,
1313 net::X509Certificate* cert,
1314 int render_process_id,
1315 int render_view_id) {
1316 // The handler will run the UI and delete itself when it's finished.
1317 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
1318}
1319
[email protected]dc73a7b2012-03-25 15:27:181320content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
1321 return MediaInternals::GetInstance();
1322}
1323
[email protected]941623e2011-06-07 23:06:041324void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1325 const GURL& source_origin,
1326 int callback_context,
1327 int render_process_id,
1328 int render_view_id) {
[email protected]5fd2e842012-03-01 00:29:111329#if defined(ENABLE_NOTIFICATIONS)
[email protected]d0d9c3ee2012-06-19 03:07:021330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1331 WebContents* contents =
1332 tab_util::GetWebContentsByID(render_process_id, render_view_id);
1333 if (!contents) {
[email protected]941623e2011-06-07 23:06:041334 NOTREACHED();
1335 return;
1336 }
1337
[email protected]d0d9c3ee2012-06-19 03:07:021338 // Skip showing the infobar if the request comes from an extension, and that
1339 // extension has the 'notify' permission. (If the extension does not have the
1340 // permission, the user will still be prompted.)
1341 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
1342 ExtensionService* service = profile->GetExtensionService();
1343 const Extension* extension = !service ? NULL :
1344 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
1345 source_origin));
1346 if (extension &&
[email protected]c2e66e12012-06-27 06:27:061347 extension->HasAPIPermission(APIPermission::kNotification)) {
[email protected]d0d9c3ee2012-06-19 03:07:021348 RenderViewHost* rvh =
1349 RenderViewHost::FromID(render_process_id, render_view_id);
1350 if (rvh)
1351 rvh->DesktopNotificationPermissionRequestDone(callback_context);
1352 return;
1353 }
1354
1355 DesktopNotificationService* notifications =
[email protected]3d7474ff2011-07-27 17:47:371356 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]d0d9c3ee2012-06-19 03:07:021357 notifications->RequestPermission(source_origin, render_process_id,
1358 render_view_id, callback_context, contents);
[email protected]5fd2e842012-03-01 00:29:111359#else
1360 NOTIMPLEMENTED();
1361#endif
[email protected]941623e2011-06-07 23:06:041362}
1363
1364WebKit::WebNotificationPresenter::Permission
1365 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
[email protected]34eec7ffe32011-11-02 23:49:021366 const GURL& source_origin,
[email protected]df02aca2012-02-09 21:03:201367 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021368 int render_process_id) {
[email protected]5fd2e842012-03-01 00:29:111369#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201371 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]34eec7ffe32011-11-02 23:49:021372 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1373 source_origin, render_process_id,
[email protected]c2e66e12012-06-27 06:27:061374 APIPermission::kNotification))
[email protected]941623e2011-06-07 23:06:041375 return WebKit::WebNotificationPresenter::PermissionAllowed;
[email protected]941623e2011-06-07 23:06:041376
1377 // Fall back to the regular notification preferences, which works on an
1378 // origin basis.
1379 return io_data->GetNotificationService() ?
[email protected]c7df61b2011-11-07 22:06:371380 io_data->GetNotificationService()->HasPermission(source_origin) :
[email protected]941623e2011-06-07 23:06:041381 WebKit::WebNotificationPresenter::PermissionNotAllowed;
[email protected]5fd2e842012-03-01 00:29:111382#else
1383 return WebKit::WebNotificationPresenter::PermissionAllowed;
1384#endif
[email protected]941623e2011-06-07 23:06:041385}
1386
1387void ChromeContentBrowserClient::ShowDesktopNotification(
[email protected]0ee57e22011-11-12 01:59:171388 const content::ShowDesktopNotificationHostMsgParams& params,
[email protected]941623e2011-06-07 23:06:041389 int render_process_id,
1390 int render_view_id,
1391 bool worker) {
[email protected]5fd2e842012-03-01 00:29:111392#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041393 RenderViewHost* rvh = RenderViewHost::FromID(
1394 render_process_id, render_view_id);
1395 if (!rvh) {
1396 NOTREACHED();
1397 return;
1398 }
1399
[email protected]9f76c1e2012-03-05 15:15:581400 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301401 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041402 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371403 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041404 service->ShowDesktopNotification(
1405 params, render_process_id, render_view_id,
1406 worker ? DesktopNotificationService::WorkerNotification :
1407 DesktopNotificationService::PageNotification);
[email protected]5fd2e842012-03-01 00:29:111408#else
1409 NOTIMPLEMENTED();
1410#endif
[email protected]941623e2011-06-07 23:06:041411}
1412
1413void ChromeContentBrowserClient::CancelDesktopNotification(
1414 int render_process_id,
1415 int render_view_id,
1416 int notification_id) {
[email protected]5fd2e842012-03-01 00:29:111417#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041418 RenderViewHost* rvh = RenderViewHost::FromID(
1419 render_process_id, render_view_id);
1420 if (!rvh) {
1421 NOTREACHED();
1422 return;
1423 }
1424
[email protected]9f76c1e2012-03-05 15:15:581425 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301426 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041427 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371428 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041429 service->CancelDesktopNotification(
1430 render_process_id, render_view_id, notification_id);
[email protected]5fd2e842012-03-01 00:29:111431#else
1432 NOTIMPLEMENTED();
1433#endif
[email protected]941623e2011-06-07 23:06:041434}
1435
[email protected]9f3fba52011-06-08 20:37:191436bool ChromeContentBrowserClient::CanCreateWindow(
[email protected]2b751a12012-03-06 03:00:351437 const GURL& opener_url,
[email protected]34eec7ffe32011-11-02 23:49:021438 const GURL& source_origin,
[email protected]9f3fba52011-06-08 20:37:191439 WindowContainerType container_type,
[email protected]df02aca2012-02-09 21:03:201440 content::ResourceContext* context,
[email protected]03b6d552012-03-29 04:03:011441 int render_process_id,
1442 bool* no_javascript_access) {
[email protected]9f3fba52011-06-08 20:37:191443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]03b6d552012-03-29 04:03:011444
1445 *no_javascript_access = false;
1446
[email protected]9f3fba52011-06-08 20:37:191447 // If the opener is trying to create a background window but doesn't have
1448 // the appropriate permission, fail the attempt.
1449 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
[email protected]df02aca2012-02-09 21:03:201450 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]7b54ca02012-03-02 18:06:531451 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1452
[email protected]03b6d552012-03-29 04:03:011453 if (!map->SecurityOriginHasAPIPermission(
1454 source_origin,
1455 render_process_id,
[email protected]c2e66e12012-06-27 06:27:061456 APIPermission::kBackground)) {
[email protected]03b6d552012-03-29 04:03:011457 return false;
1458 }
1459
[email protected]7b54ca02012-03-02 18:06:531460 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1461 // return a recently installed Extension even if this CanCreateWindow call
1462 // was made by an old copy of the page in a normal web process. That's ok,
[email protected]03b6d552012-03-29 04:03:011463 // because the permission check above would have caused an early return
1464 // already. We must use the full URL to find hosted apps, though, and not
1465 // just the origin.
[email protected]7b54ca02012-03-02 18:06:531466 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
[email protected]2b751a12012-03-06 03:00:351467 ExtensionURLInfo(opener_url));
[email protected]7b54ca02012-03-02 18:06:531468 if (extension && !extension->allow_background_js_access())
[email protected]03b6d552012-03-29 04:03:011469 *no_javascript_access = true;
[email protected]9f3fba52011-06-08 20:37:191470 }
1471 return true;
1472}
1473
1474std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
[email protected]df02aca2012-02-09 21:03:201475 const GURL& url, content::ResourceContext* context) {
[email protected]9f3fba52011-06-08 20:37:191476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1477 // Check if it's an extension-created worker, in which case we want to use
1478 // the name of the extension.
[email protected]df02aca2012-02-09 21:03:201479 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]9f3fba52011-06-08 20:37:191480 const Extension* extension =
1481 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
1482 return extension ? extension->name() : std::string();
1483}
1484
[email protected]99907362012-01-11 05:41:401485void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1486 return g_browser_process->ResourceDispatcherHostCreated();
[email protected]3cb054e62011-06-13 05:21:171487}
1488
[email protected]c52b2892012-03-07 11:01:021489content::SpeechRecognitionManagerDelegate*
1490 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
[email protected]a03f2d32012-03-14 00:26:321491#if defined(ENABLE_INPUT_SPEECH)
[email protected]c52b2892012-03-07 11:01:021492 return new speech::ChromeSpeechRecognitionManagerDelegate();
[email protected]a03f2d32012-03-14 00:26:321493#else
1494 return NULL;
1495#endif
[email protected]66cfec62012-02-24 17:57:511496}
1497
[email protected]ae6e9912011-07-27 01:18:281498net::NetLog* ChromeContentBrowserClient::GetNetLog() {
1499 return g_browser_process->net_log();
1500}
1501
[email protected]32538d92011-08-25 00:09:231502AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
1503 return new ChromeAccessTokenStore();
1504}
1505
[email protected]dbae6b02011-06-29 23:51:411506bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1507 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1508 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1509}
1510
[email protected]64d69de42012-02-06 00:19:541511void ChromeContentBrowserClient::OverrideWebkitPrefs(
[email protected]2e21fe292012-03-02 22:52:321512 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) {
[email protected]f3986f82012-01-03 20:00:061513 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581514 rvh->GetProcess()->GetBrowserContext());
[email protected]f3986f82012-01-03 20:00:061515 PrefService* prefs = profile->GetPrefs();
[email protected]f3986f82012-01-03 20:00:061516
[email protected]f3986f82012-01-03 20:00:061517 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541518 &web_prefs->standard_font_family_map);
[email protected]f3986f82012-01-03 20:00:061519 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541520 &web_prefs->fixed_font_family_map);
[email protected]f3986f82012-01-03 20:00:061521 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541522 &web_prefs->serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061523 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541524 &web_prefs->sans_serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061525 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541526 &web_prefs->cursive_font_family_map);
[email protected]f3986f82012-01-03 20:00:061527 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541528 &web_prefs->fantasy_font_family_map);
[email protected]85edc232012-10-05 08:56:031529 FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap,
1530 &web_prefs->pictograph_font_family_map);
[email protected]f3986f82012-01-03 20:00:061531
[email protected]64d69de42012-02-06 00:19:541532 web_prefs->default_font_size =
[email protected]ddf72142012-05-22 04:52:401533 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
[email protected]64d69de42012-02-06 00:19:541534 web_prefs->default_fixed_font_size =
[email protected]ddf72142012-05-22 04:52:401535 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
[email protected]64d69de42012-02-06 00:19:541536 web_prefs->minimum_font_size =
[email protected]ddf72142012-05-22 04:52:401537 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
[email protected]64d69de42012-02-06 00:19:541538 web_prefs->minimum_logical_font_size =
[email protected]ddf72142012-05-22 04:52:401539 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
[email protected]f3986f82012-01-03 20:00:061540
[email protected]ddf72142012-05-22 04:52:401541 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061542
[email protected]64d69de42012-02-06 00:19:541543 web_prefs->javascript_can_open_windows_automatically =
[email protected]ddf72142012-05-22 04:52:401544 prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically);
[email protected]64d69de42012-02-06 00:19:541545 web_prefs->dom_paste_enabled =
[email protected]f3986f82012-01-03 20:00:061546 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
[email protected]64d69de42012-02-06 00:19:541547 web_prefs->shrinks_standalone_images_to_fit =
[email protected]f3986f82012-01-03 20:00:061548 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
1549 const DictionaryValue* inspector_settings =
1550 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
1551 if (inspector_settings) {
1552 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys());
1553 iter != inspector_settings->end_keys(); ++iter) {
1554 std::string value;
1555 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value))
[email protected]64d69de42012-02-06 00:19:541556 web_prefs->inspector_settings.push_back(
[email protected]f3986f82012-01-03 20:00:061557 std::make_pair(*iter, value));
1558 }
1559 }
[email protected]64d69de42012-02-06 00:19:541560 web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
[email protected]f3986f82012-01-03 20:00:061561
[email protected]ddf72142012-05-22 04:52:401562 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled))
[email protected]64d69de42012-02-06 00:19:541563 web_prefs->javascript_enabled = false;
1564 if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled))
1565 web_prefs->web_security_enabled = false;
[email protected]ddf72142012-05-22 04:52:401566 if (!prefs->GetBoolean(prefs::kWebKitPluginsEnabled))
[email protected]64d69de42012-02-06 00:19:541567 web_prefs->plugins_enabled = false;
1568 if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled))
1569 web_prefs->java_enabled = false;
1570 web_prefs->loads_images_automatically =
[email protected]ddf72142012-05-22 04:52:401571 prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically);
[email protected]f3986f82012-01-03 20:00:061572
[email protected]64d69de42012-02-06 00:19:541573 if (prefs->GetBoolean(prefs::kDisable3DAPIs))
1574 web_prefs->experimental_webgl_enabled = false;
[email protected]f3986f82012-01-03 20:00:061575
[email protected]64d69de42012-02-06 00:19:541576 web_prefs->memory_info_enabled =
1577 prefs->GetBoolean(prefs::kEnableMemoryInfo);
1578 web_prefs->allow_displaying_insecure_content =
1579 prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
1580 web_prefs->allow_running_insecure_content =
1581 prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
[email protected]d3b935f2012-10-19 23:14:321582#if defined(OS_ANDROID)
1583 web_prefs->font_scale_factor =
1584 static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor));
1585 web_prefs->force_enable_zoom =
1586 prefs->GetBoolean(prefs::kWebKitForceEnableZoom);
1587#endif
[email protected]9d06d88d2012-02-23 22:37:081588 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
[email protected]f3986f82012-01-03 20:00:061589
[email protected]64d69de42012-02-06 00:19:541590 // The user stylesheet watcher may not exist in a testing profile.
[email protected]13169ab2012-04-06 07:48:151591 UserStyleSheetWatcher* user_style_sheet_watcher =
1592 UserStyleSheetWatcherFactory::GetForProfile(profile);
1593 if (user_style_sheet_watcher) {
[email protected]64d69de42012-02-06 00:19:541594 web_prefs->user_style_sheet_enabled = true;
1595 web_prefs->user_style_sheet_location =
[email protected]13169ab2012-04-06 07:48:151596 user_style_sheet_watcher->user_style_sheet();
[email protected]64d69de42012-02-06 00:19:541597 } else {
1598 web_prefs->user_style_sheet_enabled = false;
[email protected]f3986f82012-01-03 20:00:061599 }
1600
[email protected]b7e44ff2012-02-16 03:37:341601 web_prefs->asynchronous_spell_checking_enabled =
[email protected]37b928e2012-05-30 09:01:101602#if defined(OS_MACOSX)
1603 // TODO(hbono): Bug 107371: Implement asynchronous spellchecking API for
1604 // Mac so it uses NSSpellChecker in the background.
1605 false;
1606#else
1607 !CommandLine::ForCurrentProcess()->
[email protected]57890242012-10-23 17:46:521608 HasSwitch(switches::kForceSyncSpellCheck);
[email protected]37b928e2012-05-30 09:01:101609#endif
[email protected]b7e44ff2012-02-16 03:37:341610 web_prefs->unified_textchecker_enabled =
[email protected]57890242012-10-23 17:46:521611 web_prefs->asynchronous_spell_checking_enabled;
[email protected]dd5d0fb2012-01-18 03:37:571612
[email protected]64d69de42012-02-06 00:19:541613 web_prefs->uses_universal_detector =
[email protected]f3986f82012-01-03 20:00:061614 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);
[email protected]64d69de42012-02-06 00:19:541615 web_prefs->text_areas_are_resizable =
[email protected]f3986f82012-01-03 20:00:061616 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
[email protected]64d69de42012-02-06 00:19:541617 web_prefs->hyperlink_auditing_enabled =
[email protected]f3986f82012-01-03 20:00:061618 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
1619
1620 // Make sure we will set the default_encoding with canonical encoding name.
[email protected]64d69de42012-02-06 00:19:541621 web_prefs->default_encoding =
[email protected]f3986f82012-01-03 20:00:061622 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
[email protected]64d69de42012-02-06 00:19:541623 web_prefs->default_encoding);
1624 if (web_prefs->default_encoding.empty()) {
[email protected]ddf72142012-05-22 04:52:401625 prefs->ClearPref(prefs::kDefaultCharset);
1626 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061627 }
[email protected]64d69de42012-02-06 00:19:541628 DCHECK(!web_prefs->default_encoding.empty());
[email protected]f3986f82012-01-03 20:00:061629
[email protected]299d7f12012-05-23 05:31:151630 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
1631 chrome::ViewType view_type = chrome::GetViewType(web_contents);
[email protected]f3986f82012-01-03 20:00:061632 ExtensionService* service = profile->GetExtensionService();
1633 if (service) {
[email protected]1bc28312012-11-08 08:31:531634 const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
1635 const Extension* extension = service->extensions()->GetByID(url.host());
1636 // Ensure that we are only granting extension preferences to URLs with
1637 // the correct scheme. Without this check, chrome-guest:// schemes used by
1638 // webview tags as well as hosts that happen to match the id of an
1639 // installed extension would get the wrong preferences.
1640 if (url.SchemeIs(chrome::kExtensionScheme)) {
1641 extension_webkit_preferences::SetPreferences(
1642 extension, view_type, web_prefs);
1643 }
[email protected]f3986f82012-01-03 20:00:061644 }
1645
[email protected]b7c4f032012-08-07 16:38:561646 if (content::IsForceCompositingModeEnabled())
[email protected]4abe58d2012-06-08 03:09:091647 web_prefs->force_compositing_mode = true;
1648
[email protected]299d7f12012-05-23 05:31:151649 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) {
[email protected]64d69de42012-02-06 00:19:541650 web_prefs->allow_scripts_to_close_windows = true;
[email protected]299d7f12012-05-23 05:31:151651 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
[email protected]f3986f82012-01-03 20:00:061652 // Disable all kinds of acceleration for background pages.
1653 // See http://crbug.com/96005 and http://crbug.com/96006
[email protected]64d69de42012-02-06 00:19:541654 web_prefs->force_compositing_mode = false;
1655 web_prefs->accelerated_compositing_enabled = false;
1656 web_prefs->accelerated_2d_canvas_enabled = false;
1657 web_prefs->accelerated_video_enabled = false;
1658 web_prefs->accelerated_painting_enabled = false;
1659 web_prefs->accelerated_plugins_enabled = false;
[email protected]f3986f82012-01-03 20:00:061660 }
[email protected]2e21fe292012-03-02 22:52:321661
1662#if defined(FILE_MANAGER_EXTENSION)
1663 // Override the default of suppressing HW compositing for WebUI pages for the
1664 // file manager, which is implemented using WebUI but wants HW acceleration
1665 // for video decode & render.
1666 if (url.spec() == chrome::kChromeUIFileManagerURL) {
1667 web_prefs->accelerated_compositing_enabled = true;
1668 web_prefs->accelerated_2d_canvas_enabled = true;
1669 }
1670#endif
[email protected]181a95ee2011-07-12 19:26:361671}
1672
1673void ChromeContentBrowserClient::UpdateInspectorSetting(
1674 RenderViewHost* rvh, const std::string& key, const std::string& value) {
[email protected]f3986f82012-01-03 20:00:061675 content::BrowserContext* browser_context =
[email protected]9f76c1e2012-03-05 15:15:581676 rvh->GetProcess()->GetBrowserContext();
[email protected]f3986f82012-01-03 20:00:061677 DictionaryPrefUpdate update(
1678 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1679 prefs::kWebKitInspectorSettings);
1680 DictionaryValue* inspector_settings = update.Get();
1681 inspector_settings->SetWithoutPathExpansion(key,
1682 Value::CreateStringValue(value));
[email protected]181a95ee2011-07-12 19:26:361683}
1684
1685void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
[email protected]f3986f82012-01-03 20:00:061686 content::BrowserContext* browser_context =
[email protected]9f76c1e2012-03-05 15:15:581687 rvh->GetProcess()->GetBrowserContext();
[email protected]f3986f82012-01-03 20:00:061688 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1689 ClearPref(prefs::kWebKitInspectorSettings);
[email protected]181a95ee2011-07-12 19:26:361690}
1691
[email protected]b8148ac2011-07-13 22:03:251692void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1693 BrowserURLHandler* handler) {
1694 // Add the default URL handlers.
1695 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1696 BrowserURLHandler::null_handler());
1697 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1698 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1699
[email protected]b3adbd02011-11-30 22:23:271700 // about: handler. Must come before chrome: handler, since it will
1701 // rewrite about: urls to chrome: URLs and then expect chrome: to
1702 // actually handle them.
[email protected]b8148ac2011-07-13 22:03:251703 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1704 BrowserURLHandler::null_handler());
1705 // chrome: & friends.
[email protected]f8f93eb2012-09-25 03:06:241706 handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
[email protected]b8148ac2011-07-13 22:03:251707}
1708
1709void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371710 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581711 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:471712 BrowsingDataRemover* remover =
1713 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]3d4d4cf2012-06-04 10:40:551714 remover->Remove(BrowsingDataRemover::REMOVE_CACHE,
1715 BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:251716 // BrowsingDataRemover takes care of deleting itself when done.
1717}
1718
1719void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371720 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581721 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:471722 BrowsingDataRemover* remover =
1723 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]dceaa912011-09-06 17:17:231724 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]3d4d4cf2012-06-04 10:40:551725 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:251726 // BrowsingDataRemover takes care of deleting itself when done.
1727}
1728
[email protected]e1d16eb92011-08-18 23:19:321729FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1730 return download_util::GetDefaultDownloadDirectory();
1731}
1732
[email protected]c9b6eb62011-10-18 20:49:391733std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
1734 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
1735}
1736
[email protected]b7631cc2012-09-15 05:08:381737void ChromeContentBrowserClient::DidCreatePpapiPlugin(
1738 content::BrowserPpapiHost* browser_host) {
1739 browser_host->GetPpapiHost()->AddHostFactoryFilter(
1740 scoped_ptr<ppapi::host::HostFactory>(
1741 new ChromeBrowserPepperHostFactory(browser_host)));
1742}
1743
[email protected]0c7193742012-11-07 19:05:031744content::BrowserPpapiHost*
1745 ChromeContentBrowserClient::GetExternalBrowserPpapiHost(
1746 int plugin_process_id) {
1747 BrowserChildProcessHostIterator iter(content::PROCESS_TYPE_NACL_LOADER);
1748 while (!iter.Done()) {
1749 NaClProcessHost* host = static_cast<NaClProcessHost*>(iter.GetDelegate());
1750 if (host->process() &&
1751 host->process()->GetData().id == plugin_process_id) {
1752 // Found the plugin.
1753 return host->browser_ppapi_host();
1754 }
1755 ++iter;
1756 }
1757 return NULL;
1758}
1759
[email protected]38cd8f7f2012-06-15 22:06:071760bool ChromeContentBrowserClient::AllowPepperSocketAPI(
[email protected]157cc902012-11-02 06:31:581761 content::BrowserContext* browser_context,
1762 const GURL& url,
1763 const content::SocketPermissionRequest& params) {
[email protected]a658d452012-03-02 12:45:291764 if (!url.is_valid())
1765 return false;
1766
1767 std::string host = url.host();
[email protected]92444942012-06-16 09:05:281768 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host))
[email protected]a658d452012-03-02 12:45:291769 return true;
1770
[email protected]9a5940d2012-04-27 19:16:231771 Profile* profile = Profile::FromBrowserContext(browser_context);
1772 const Extension* extension = NULL;
1773 if (profile && profile->GetExtensionService()) {
1774 extension = profile->GetExtensionService()->extensions()->
1775 GetExtensionOrAppByURL(ExtensionURLInfo(url));
1776 }
1777
[email protected]f237c0f2012-03-10 07:49:101778 // Need to check this now and not on construction because otherwise it won't
1779 // work with browser_tests.
1780 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1781 std::string allowed_list =
1782 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
[email protected]9a5940d2012-04-27 19:16:231783 if (allowed_list == "*") {
1784 // The wildcard allows socket API only for packaged and platform apps.
1785 return extension &&
[email protected]c4f459d2012-09-28 04:40:101786 (extension->GetType() == Extension::TYPE_LEGACY_PACKAGED_APP ||
[email protected]9a5940d2012-04-27 19:16:231787 extension->GetType() == Extension::TYPE_PLATFORM_APP);
1788 } else if (!allowed_list.empty()) {
[email protected]f237c0f2012-03-10 07:49:101789 StringTokenizer t(allowed_list, ",");
1790 while (t.GetNext()) {
1791 if (t.token() == host)
1792 return true;
1793 }
1794 }
1795
[email protected]a658d452012-03-02 12:45:291796 if (!extension)
1797 return false;
1798
[email protected]157cc902012-11-02 06:31:581799 extensions::SocketPermission::CheckParam extension_params(
1800 params.type, params.host, params.port);
1801 if (extension->CheckAPIPermissionWithParam(APIPermission::kSocket,
1802 &extension_params))
[email protected]a658d452012-03-02 12:45:291803 return true;
1804
1805 return false;
[email protected]e461da2f2012-02-16 19:06:401806}
1807
[email protected]38cd8f7f2012-06-15 22:06:071808bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() {
1809 return CommandLine::ForCurrentProcess()->HasSwitch(
1810 switches::kPpapiFlashInProcess);
1811}
1812
[email protected]a7944aa2012-10-15 10:12:141813FilePath ChromeContentBrowserClient::GetHyphenDictionaryDirectory() {
1814 FilePath directory;
1815 PathService::Get(chrome::DIR_APP_DICTIONARIES, &directory);
1816 return directory.Append(FILE_PATH_LITERAL("Hyphen"));
1817}
1818
[email protected]e60c0232011-11-11 19:56:351819#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]a1733df2012-06-22 11:24:181820void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
1821 const CommandLine& command_line,
[email protected]40da3e0c2012-10-24 22:03:381822 int child_process_id,
[email protected]c7abd422012-09-25 00:20:081823 std::vector<FileDescriptorInfo>* mappings) {
[email protected]29699c22012-10-03 23:57:391824#if defined(OS_ANDROID)
1825 FilePath data_path;
1826 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
1827 DCHECK(!data_path.empty());
1828
1829 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
1830 FilePath chrome_pak = data_path.AppendASCII("chrome.pak");
1831 base::PlatformFile f =
1832 base::CreatePlatformFile(chrome_pak, flags, NULL, NULL);
1833 DCHECK(f != base::kInvalidPlatformFileValue);
1834 mappings->push_back(FileDescriptorInfo(kAndroidChromePakDescriptor,
1835 FileDescriptor(f, true)));
1836
1837 FilePath chrome_resources_pak =
1838 data_path.AppendASCII("chrome_100_percent.pak");
1839 f = base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL);
1840 DCHECK(f != base::kInvalidPlatformFileValue);
1841 mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor,
1842 FileDescriptor(f, true)));
1843
1844 const std::string locale = GetApplicationLocale();
1845 FilePath locale_pak = ResourceBundle::GetSharedInstance().
1846 GetLocaleFilePath(locale, false);
1847 f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL);
1848 DCHECK(f != base::kInvalidPlatformFileValue);
1849 mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor,
1850 FileDescriptor(f, true)));
[email protected]40da3e0c2012-10-24 22:03:381851
1852#if defined(USE_LINUX_BREAKPAD)
1853 f = crash_dump_manager_->CreateMinidumpFile(child_process_id);
1854 if (f == base::kInvalidPlatformFileValue) {
1855 LOG(ERROR) << "Failed to create file for minidump, crash reporting will be "
1856 "disabled for this process.";
1857 } else {
1858 mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor,
1859 FileDescriptor(f, true)));
1860 }
1861#endif // defined(USE_LINUX_BREAKPAD)
1862
1863#else
1864 int crash_signal_fd = GetCrashSignalFD(command_line);
1865 if (crash_signal_fd >= 0) {
1866 mappings->push_back(FileDescriptorInfo(kCrashDumpSignal,
1867 FileDescriptor(crash_signal_fd,
1868 false)));
1869 }
[email protected]29699c22012-10-03 23:57:391870#endif // defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:301871}
[email protected]e60c0232011-11-11 19:56:351872#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301873
[email protected]4a65826d2011-08-25 16:04:011874#if defined(OS_WIN)
1875const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
1876 return chrome::kBrowserResourcesDll;
1877}
1878#endif
1879
[email protected]40da3e0c2012-10-24 22:03:381880#if defined(OS_ANDROID)
1881void ChromeContentBrowserClient::InitCrashDumpManager() {
1882 if (!crash_dump_manager_.get())
1883 crash_dump_manager_.reset(new CrashDumpManager());
1884}
1885#endif
1886
[email protected]37a72af2011-06-13 05:42:011887#if defined(USE_NSS)
1888crypto::CryptoModuleBlockingPasswordDelegate*
1889 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1890 const GURL& url) {
[email protected]6246ac52012-09-24 01:55:291891 return chrome::NewCryptoModuleBlockingDialogDelegate(
1892 chrome::kCryptoModulePasswordKeygen, url.host());
[email protected]37a72af2011-06-13 05:42:011893}
1894#endif
1895
[email protected]e9a32a52012-06-14 23:32:431896void ChromeContentBrowserClient::SetApplicationLocale(
1897 const std::string& locale) {
1898 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1899
1900 // This object is guaranteed to outlive all threads so we don't have to
1901 // worry about the lack of refcounting and can just post as Unretained.
1902 //
1903 // The common case is that this function is called early in Chrome startup
1904 // before any threads are created (it will also be called later if the user
1905 // changes the pref). In this case, there will be no threads created and
1906 // posting will fail. When there are no threads, we can just set the string
1907 // without worrying about threadsafety.
1908 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1909 base::Bind(
1910 &ChromeContentBrowserClient::SetApplicationLocaleOnIOThread,
1911 base::Unretained(this), locale)))
1912 io_thread_application_locale_ = locale;
1913}
1914
1915void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
1916 const std::string& locale) {
1917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1918 io_thread_application_locale_ = locale;
1919}
1920
[email protected]d977f9c2011-03-14 16:10:261921} // namespace chrome