blob: 758eb518a8a436cdbc9f54101a00ceef8f2dcfb8 [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,
948 switches::kEnableNaCl,
[email protected]9c8b116b2012-05-10 23:07:05949 switches::kEnableNaClIPCProxy,
[email protected]bcbe7652012-02-22 00:08:48950 switches::kEnablePasswordGeneration,
[email protected]284b03c2012-08-13 17:55:05951 switches::kEnablePnacl,
[email protected]4287a3d2011-06-13 23:56:51952 switches::kEnableWatchdog,
[email protected]4287a3d2011-06-13 23:56:51953 switches::kMemoryProfiling,
954 switches::kMessageLoopHistogrammer,
[email protected]f45c5f32012-04-18 19:26:37955 switches::kNoJsRandomness,
[email protected]732b1604e2012-10-26 19:59:58956 switches::kPerformCrashAnalysis,
[email protected]f45c5f32012-04-18 19:26:37957 switches::kPlaybackMode,
[email protected]4287a3d2011-06-13 23:56:51958 switches::kPpapiFlashArgs,
959 switches::kPpapiFlashInProcess,
960 switches::kPpapiFlashPath,
961 switches::kPpapiFlashVersion,
962 switches::kProfilingAtStart,
963 switches::kProfilingFile,
964 switches::kProfilingFlush,
[email protected]f45c5f32012-04-18 19:26:37965 switches::kRecordMode,
[email protected]4287a3d2011-06-13 23:56:51966 switches::kSilentDumpOnDCHECK,
[email protected]c79d9492012-10-04 19:56:30967 switches::kSpdyProxyOrigin,
[email protected]a446534d2012-02-09 00:07:38968 switches::kWhitelistedExtensionID,
[email protected]4287a3d2011-06-13 23:56:51969 };
970
971 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
972 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17973 } else if (process_type == switches::kUtilityProcess) {
[email protected]a446534d2012-02-09 00:07:38974 static const char* const kSwitchNames[] = {
[email protected]eb653f82012-05-24 02:31:35975 switches::kAllowHTTPBackgroundPage,
[email protected]a446534d2012-02-09 00:07:38976 switches::kEnableExperimentalExtensionApis,
977 switches::kWhitelistedExtensionID,
978 };
979
980 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
981 arraysize(kSwitchNames));
[email protected]4287a3d2011-06-13 23:56:51982 } else if (process_type == switches::kPluginProcess) {
983 static const char* const kSwitchNames[] = {
984 #if defined(OS_CHROMEOS)
985 switches::kLoginProfile,
986 #endif
987 switches::kMemoryProfiling,
988 switches::kSilentDumpOnDCHECK,
989 switches::kUserDataDir,
990 };
991
992 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
993 arraysize(kSwitchNames));
994 } else if (process_type == switches::kZygoteProcess) {
995 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51996 switches::kUserDataDir, // Make logs go to the right file.
997 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
[email protected]382fb0d2012-02-25 00:19:50998 switches::kDisableBundledPpapiFlash,
[email protected]b50368b2012-02-18 00:02:13999 switches::kEnableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:511000 switches::kPpapiFlashInProcess,
1001 switches::kPpapiFlashPath,
1002 switches::kPpapiFlashVersion,
1003 };
1004
1005 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1006 arraysize(kSwitchNames));
[email protected]d56ecf922012-02-15 16:03:111007 } else if (process_type == switches::kGpuProcess) {
1008 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
1009 // because GPU is expected to be unreliable.
1010 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) &&
1011 !command_line->HasSwitch(switches::kDisableBreakpad))
1012 command_line->AppendSwitch(switches::kDisableBreakpad);
[email protected]b80f68432011-05-02 17:22:301013 }
[email protected]6f08af82011-09-15 01:19:031014
1015 // The command line switch kEnableBenchmarking needs to be specified along
1016 // with the kEnableStatsTable switch to ensure that the stats table global
1017 // is initialized correctly.
1018 if (command_line->HasSwitch(switches::kEnableBenchmarking))
1019 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:301020}
1021
1022std::string ChromeContentBrowserClient::GetApplicationLocale() {
[email protected]e9a32a52012-06-14 23:32:431023 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
1024 return io_thread_application_locale_;
[email protected]b80f68432011-05-02 17:22:301025 return g_browser_process->GetApplicationLocale();
1026}
1027
[email protected]597a867b2011-11-18 18:31:201028std::string ChromeContentBrowserClient::GetAcceptLangs(
1029 content::BrowserContext* context) {
1030 Profile* profile = Profile::FromBrowserContext(context);
[email protected]3d7474ff2011-07-27 17:47:371031 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:081032}
1033
[email protected]9ec0f452012-05-31 15:58:531034gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() {
[email protected]7c3228a2011-11-11 21:35:221035 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
[email protected]9ec0f452012-05-31 15:58:531036 return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
[email protected]ac55e292011-06-24 05:16:081037}
1038
[email protected]a2176792011-05-08 19:30:491039bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:091040 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:191041 const GURL& first_party,
[email protected]df02aca2012-02-09 21:03:201042 content::ResourceContext* context) {
[email protected]8093a542011-05-13 07:29:321043 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201044 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051045 return io_data->GetCookieSettings()->
1046 IsSettingCookieAllowed(manifest_url, first_party);
[email protected]a2176792011-05-08 19:30:491047}
1048
[email protected]ed24fad2011-05-10 22:44:011049bool ChromeContentBrowserClient::AllowGetCookie(
1050 const GURL& url,
1051 const GURL& first_party,
1052 const net::CookieList& cookie_list,
[email protected]df02aca2012-02-09 21:03:201053 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011054 int render_process_id,
1055 int render_view_id) {
1056 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201057 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051058 bool allow = io_data->GetCookieSettings()->
1059 IsReadingCookieAllowed(url, first_party);
[email protected]ed24fad2011-05-10 22:44:011060
[email protected]8093a542011-05-13 07:29:321061 BrowserThread::PostTask(
1062 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031063 base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
[email protected]fd473d12012-04-05 11:38:431064 render_view_id, url, first_party, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:011065 return allow;
1066}
1067
1068bool ChromeContentBrowserClient::AllowSetCookie(
1069 const GURL& url,
1070 const GURL& first_party,
1071 const std::string& cookie_line,
[email protected]df02aca2012-02-09 21:03:201072 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011073 int render_process_id,
1074 int render_view_id,
1075 net::CookieOptions* options) {
1076 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201077 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051078 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1079 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
1080
[email protected]8093a542011-05-13 07:29:321081 BrowserThread::PostTask(
1082 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031083 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
[email protected]fd473d12012-04-05 11:38:431084 render_view_id, url, first_party, cookie_line, *options,
1085 !allow));
[email protected]ed24fad2011-05-10 22:44:011086 return allow;
1087}
1088
[email protected]ea628e32012-08-02 21:50:161089bool ChromeContentBrowserClient::AllowPluginLocalDataAccess(
1090 const GURL& document_url,
1091 const GURL& plugin_url,
1092 content::ResourceContext* context) {
1093 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1094 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1095 return io_data->GetCookieSettings()->IsReadingCookieAllowed(document_url,
1096 plugin_url);
1097}
1098
1099bool ChromeContentBrowserClient::AllowPluginLocalDataSessionOnly(
1100 const GURL& url,
1101 content::ResourceContext* context) {
1102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1103 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1104 return io_data->GetCookieSettings()->IsCookieSessionOnly(url);
1105}
1106
[email protected]d5a19162011-06-30 18:51:541107bool ChromeContentBrowserClient::AllowSaveLocalState(
[email protected]df02aca2012-02-09 21:03:201108 content::ResourceContext* context) {
[email protected]d5a19162011-06-30 18:51:541109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201110 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]bf510ed2012-06-05 08:31:431111 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1112 ContentSetting setting = cookie_settings->GetDefaultCookieSetting(NULL);
[email protected]1848cdc2012-02-17 10:48:261113
[email protected]bf510ed2012-06-05 08:31:431114 // TODO(bauerb): Should we also disallow local state if the default is BLOCK?
1115 // Could we even support per-origin settings?
1116 return setting != CONTENT_SETTING_SESSION_ONLY;
[email protected]d5a19162011-06-30 18:51:541117}
1118
[email protected]5c5a88e2011-11-12 00:45:351119bool ChromeContentBrowserClient::AllowWorkerDatabase(
[email protected]5c5a88e2011-11-12 00:45:351120 const GURL& url,
1121 const string16& name,
1122 const string16& display_name,
1123 unsigned long estimated_size,
[email protected]df02aca2012-02-09 21:03:201124 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481125 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201127 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351128 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1129 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1130
[email protected]62151052012-02-01 18:40:481131 // Record access to database for potential display in UI.
1132 std::vector<std::pair<int, int> >::const_iterator i;
1133 for (i = render_views.begin(); i != render_views.end(); ++i) {
1134 BrowserThread::PostTask(
1135 BrowserThread::UI, FROM_HERE,
1136 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
1137 i->first, i->second, url, name, display_name, !allow));
[email protected]5c5a88e2011-11-12 00:45:351138 }
1139
1140 return allow;
1141}
1142
1143bool ChromeContentBrowserClient::AllowWorkerFileSystem(
[email protected]5c5a88e2011-11-12 00:45:351144 const GURL& url,
[email protected]df02aca2012-02-09 21:03:201145 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481146 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201148 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351149 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1150 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1151
[email protected]62151052012-02-01 18:40:481152 // Record access to file system for potential display in UI.
1153 std::vector<std::pair<int, int> >::const_iterator i;
1154 for (i = render_views.begin(); i != render_views.end(); ++i) {
1155 BrowserThread::PostTask(
1156 BrowserThread::UI, FROM_HERE,
1157 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
1158 i->first, i->second, url, !allow));
[email protected]5c5a88e2011-11-12 00:45:351159 }
1160
1161 return allow;
1162}
1163
[email protected]7c5ff9a2012-03-02 07:42:491164bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
1165 const GURL& url,
1166 const string16& name,
1167 content::ResourceContext* context,
1168 const std::vector<std::pair<int, int> >& render_views) {
1169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1170 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1171 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1172 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1173
1174 // Record access to IndexedDB for potential display in UI.
1175 std::vector<std::pair<int, int> >::const_iterator i;
1176 for (i = render_views.begin(); i != render_views.end(); ++i) {
1177 BrowserThread::PostTask(
1178 BrowserThread::UI, FROM_HERE,
1179 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
1180 i->first, i->second, url, name, !allow));
1181 }
1182
1183 return allow;
1184}
1185
[email protected]6133f922011-07-01 21:34:341186net::URLRequestContext*
1187ChromeContentBrowserClient::OverrideRequestContextForURL(
[email protected]df02aca2012-02-09 21:03:201188 const GURL& url, content::ResourceContext* context) {
[email protected]6133f922011-07-01 21:34:341189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1190 if (url.SchemeIs(chrome::kExtensionScheme)) {
[email protected]df02aca2012-02-09 21:03:201191 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]6133f922011-07-01 21:34:341192 return io_data->extensions_request_context();
1193 }
1194
1195 return NULL;
1196}
1197
[email protected]317f96c92011-05-31 06:53:411198QuotaPermissionContext*
1199ChromeContentBrowserClient::CreateQuotaPermissionContext() {
1200 return new ChromeQuotaPermissionContext();
1201}
1202
[email protected]a0ce3282011-08-19 20:49:521203void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:421204 platform_util::OpenItem(path);
[email protected]0609b17f2011-05-31 20:13:421205}
1206
[email protected]a0ce3282011-08-19 20:49:521207void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
[email protected]a0ce3282011-08-19 20:49:521208 platform_util::ShowItemInFolder(path);
[email protected]a0ce3282011-08-19 20:49:521209}
1210
[email protected]848dd042011-06-04 18:24:031211void ChromeContentBrowserClient::AllowCertificateError(
[email protected]4cf611e32012-02-13 16:06:171212 int render_process_id,
1213 int render_view_id,
1214 int cert_error,
1215 const net::SSLInfo& ssl_info,
1216 const GURL& request_url,
[email protected]848dd042011-06-04 18:24:031217 bool overridable,
[email protected]d9be47702012-05-16 03:41:221218 bool strict_enforcement,
[email protected]4cf611e32012-02-13 16:06:171219 const base::Callback<void(bool)>& callback,
1220 bool* cancel_request) {
[email protected]f9034cf2011-07-21 12:43:411221 // If the tab is being prerendered, cancel the prerender and the request.
[email protected]83ff91c2012-01-05 20:54:131222 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]4cf611e32012-02-13 16:06:171223 render_process_id, render_view_id);
[email protected]f9034cf2011-07-21 12:43:411224 if (!tab) {
1225 NOTREACHED();
1226 return;
1227 }
1228 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:501229 prerender::PrerenderManagerFactory::GetForProfile(
[email protected]627e0512011-12-21 22:55:301230 Profile::FromBrowserContext(tab->GetBrowserContext()));
[email protected]3a6ec762012-10-17 16:01:011231 if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab,
1232 NULL)) {
[email protected]f9034cf2011-07-21 12:43:411233 if (prerender_manager->prerender_tracker()->TryCancel(
[email protected]4cf611e32012-02-13 16:06:171234 render_process_id, render_view_id,
[email protected]f9034cf2011-07-21 12:43:411235 prerender::FINAL_STATUS_SSL_ERROR)) {
[email protected]4cf611e32012-02-13 16:06:171236 *cancel_request = true;
[email protected]f9034cf2011-07-21 12:43:411237 return;
1238 }
1239 }
1240
[email protected]1e87df32012-09-12 04:53:191241#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
[email protected]eb0b9dd2012-09-19 21:36:231242 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
1243 captive_portal::CaptivePortalTabHelper::FromWebContents(tab);
1244 if (captive_portal_tab_helper)
1245 captive_portal_tab_helper->OnSSLCertError(ssl_info);
[email protected]1e87df32012-09-12 04:53:191246#endif
1247
[email protected]f9034cf2011-07-21 12:43:411248 // Otherwise, display an SSL blocking page.
[email protected]d9be47702012-05-16 03:41:221249 new SSLBlockingPage(tab, cert_error, ssl_info, request_url, overridable,
1250 strict_enforcement, callback);
[email protected]848dd042011-06-04 18:24:031251}
1252
[email protected]c99c442e2011-08-24 11:37:301253void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:451254 int render_process_id,
1255 int render_view_id,
[email protected]7a593db2012-02-13 21:19:401256 const net::HttpNetworkSession* network_session,
1257 net::SSLCertRequestInfo* cert_request_info,
1258 const base::Callback<void(net::X509Certificate*)>& callback) {
[email protected]83ff91c2012-01-05 20:54:131259 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]8ec26472011-06-06 16:52:451260 render_process_id, render_view_id);
1261 if (!tab) {
1262 NOTREACHED();
1263 return;
1264 }
1265
[email protected]6786bf402011-12-03 15:19:451266 GURL requesting_url("https://" + cert_request_info->host_and_port);
1267 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
1268 << cert_request_info->host_and_port;
1269
[email protected]627e0512011-12-21 22:55:301270 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
[email protected]6786bf402011-12-03 15:19:451271 scoped_ptr<Value> filter(
1272 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1273 requesting_url,
1274 requesting_url,
1275 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1276 std::string(), NULL));
1277
1278 if (filter.get()) {
1279 // Try to automatically select a client certificate.
1280 if (filter->IsType(Value::TYPE_DICTIONARY)) {
1281 DictionaryValue* filter_dict =
1282 static_cast<DictionaryValue*>(filter.get());
1283
1284 const std::vector<scoped_refptr<net::X509Certificate> >&
1285 all_client_certs = cert_request_info->client_certs;
1286 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1287 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
1288 // Use the first certificate that is matched by the filter.
[email protected]7a593db2012-02-13 21:19:401289 callback.Run(all_client_certs[i]);
[email protected]6786bf402011-12-03 15:19:451290 return;
1291 }
1292 }
1293 } else {
1294 NOTREACHED();
1295 }
1296 }
1297
[email protected]11feec322012-09-18 03:58:521298 SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab);
1299 if (!ssl_tab_helper) {
1300 // If there is no SSLTabHelper for the given WebContents then we can't
[email protected]6786bf402011-12-03 15:19:451301 // show the user a dialog to select a client certificate. So we simply
[email protected]2a349e92011-12-07 12:00:141302 // proceed with no client certificate.
[email protected]7a593db2012-02-13 21:19:401303 callback.Run(NULL);
[email protected]6786bf402011-12-03 15:19:451304 return;
1305 }
[email protected]11feec322012-09-18 03:58:521306 ssl_tab_helper->ShowClientCertificateRequestDialog(
[email protected]7a593db2012-02-13 21:19:401307 network_session, cert_request_info, callback);
[email protected]8ec26472011-06-06 16:52:451308}
1309
1310void ChromeContentBrowserClient::AddNewCertificate(
1311 net::URLRequest* request,
1312 net::X509Certificate* cert,
1313 int render_process_id,
1314 int render_view_id) {
1315 // The handler will run the UI and delete itself when it's finished.
1316 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
1317}
1318
[email protected]dc73a7b2012-03-25 15:27:181319content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
1320 return MediaInternals::GetInstance();
1321}
1322
[email protected]941623e2011-06-07 23:06:041323void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1324 const GURL& source_origin,
1325 int callback_context,
1326 int render_process_id,
1327 int render_view_id) {
[email protected]5fd2e842012-03-01 00:29:111328#if defined(ENABLE_NOTIFICATIONS)
[email protected]d0d9c3ee2012-06-19 03:07:021329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1330 WebContents* contents =
1331 tab_util::GetWebContentsByID(render_process_id, render_view_id);
1332 if (!contents) {
[email protected]941623e2011-06-07 23:06:041333 NOTREACHED();
1334 return;
1335 }
1336
[email protected]d0d9c3ee2012-06-19 03:07:021337 // Skip showing the infobar if the request comes from an extension, and that
1338 // extension has the 'notify' permission. (If the extension does not have the
1339 // permission, the user will still be prompted.)
1340 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
1341 ExtensionService* service = profile->GetExtensionService();
1342 const Extension* extension = !service ? NULL :
1343 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
1344 source_origin));
1345 if (extension &&
[email protected]c2e66e12012-06-27 06:27:061346 extension->HasAPIPermission(APIPermission::kNotification)) {
[email protected]d0d9c3ee2012-06-19 03:07:021347 RenderViewHost* rvh =
1348 RenderViewHost::FromID(render_process_id, render_view_id);
1349 if (rvh)
1350 rvh->DesktopNotificationPermissionRequestDone(callback_context);
1351 return;
1352 }
1353
1354 DesktopNotificationService* notifications =
[email protected]3d7474ff2011-07-27 17:47:371355 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]d0d9c3ee2012-06-19 03:07:021356 notifications->RequestPermission(source_origin, render_process_id,
1357 render_view_id, callback_context, contents);
[email protected]5fd2e842012-03-01 00:29:111358#else
1359 NOTIMPLEMENTED();
1360#endif
[email protected]941623e2011-06-07 23:06:041361}
1362
1363WebKit::WebNotificationPresenter::Permission
1364 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
[email protected]34eec7ffe32011-11-02 23:49:021365 const GURL& source_origin,
[email protected]df02aca2012-02-09 21:03:201366 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021367 int render_process_id) {
[email protected]5fd2e842012-03-01 00:29:111368#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201370 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]34eec7ffe32011-11-02 23:49:021371 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1372 source_origin, render_process_id,
[email protected]c2e66e12012-06-27 06:27:061373 APIPermission::kNotification))
[email protected]941623e2011-06-07 23:06:041374 return WebKit::WebNotificationPresenter::PermissionAllowed;
[email protected]941623e2011-06-07 23:06:041375
1376 // Fall back to the regular notification preferences, which works on an
1377 // origin basis.
1378 return io_data->GetNotificationService() ?
[email protected]c7df61b2011-11-07 22:06:371379 io_data->GetNotificationService()->HasPermission(source_origin) :
[email protected]941623e2011-06-07 23:06:041380 WebKit::WebNotificationPresenter::PermissionNotAllowed;
[email protected]5fd2e842012-03-01 00:29:111381#else
1382 return WebKit::WebNotificationPresenter::PermissionAllowed;
1383#endif
[email protected]941623e2011-06-07 23:06:041384}
1385
1386void ChromeContentBrowserClient::ShowDesktopNotification(
[email protected]0ee57e22011-11-12 01:59:171387 const content::ShowDesktopNotificationHostMsgParams& params,
[email protected]941623e2011-06-07 23:06:041388 int render_process_id,
1389 int render_view_id,
1390 bool worker) {
[email protected]5fd2e842012-03-01 00:29:111391#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041392 RenderViewHost* rvh = RenderViewHost::FromID(
1393 render_process_id, render_view_id);
1394 if (!rvh) {
1395 NOTREACHED();
1396 return;
1397 }
1398
[email protected]9f76c1e2012-03-05 15:15:581399 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301400 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041401 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371402 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041403 service->ShowDesktopNotification(
1404 params, render_process_id, render_view_id,
1405 worker ? DesktopNotificationService::WorkerNotification :
1406 DesktopNotificationService::PageNotification);
[email protected]5fd2e842012-03-01 00:29:111407#else
1408 NOTIMPLEMENTED();
1409#endif
[email protected]941623e2011-06-07 23:06:041410}
1411
1412void ChromeContentBrowserClient::CancelDesktopNotification(
1413 int render_process_id,
1414 int render_view_id,
1415 int notification_id) {
[email protected]5fd2e842012-03-01 00:29:111416#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041417 RenderViewHost* rvh = RenderViewHost::FromID(
1418 render_process_id, render_view_id);
1419 if (!rvh) {
1420 NOTREACHED();
1421 return;
1422 }
1423
[email protected]9f76c1e2012-03-05 15:15:581424 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301425 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041426 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371427 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041428 service->CancelDesktopNotification(
1429 render_process_id, render_view_id, notification_id);
[email protected]5fd2e842012-03-01 00:29:111430#else
1431 NOTIMPLEMENTED();
1432#endif
[email protected]941623e2011-06-07 23:06:041433}
1434
[email protected]9f3fba52011-06-08 20:37:191435bool ChromeContentBrowserClient::CanCreateWindow(
[email protected]2b751a12012-03-06 03:00:351436 const GURL& opener_url,
[email protected]34eec7ffe32011-11-02 23:49:021437 const GURL& source_origin,
[email protected]9f3fba52011-06-08 20:37:191438 WindowContainerType container_type,
[email protected]df02aca2012-02-09 21:03:201439 content::ResourceContext* context,
[email protected]03b6d552012-03-29 04:03:011440 int render_process_id,
1441 bool* no_javascript_access) {
[email protected]9f3fba52011-06-08 20:37:191442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]03b6d552012-03-29 04:03:011443
1444 *no_javascript_access = false;
1445
[email protected]9f3fba52011-06-08 20:37:191446 // If the opener is trying to create a background window but doesn't have
1447 // the appropriate permission, fail the attempt.
1448 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
[email protected]df02aca2012-02-09 21:03:201449 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]7b54ca02012-03-02 18:06:531450 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1451
[email protected]03b6d552012-03-29 04:03:011452 if (!map->SecurityOriginHasAPIPermission(
1453 source_origin,
1454 render_process_id,
[email protected]c2e66e12012-06-27 06:27:061455 APIPermission::kBackground)) {
[email protected]03b6d552012-03-29 04:03:011456 return false;
1457 }
1458
[email protected]7b54ca02012-03-02 18:06:531459 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1460 // return a recently installed Extension even if this CanCreateWindow call
1461 // was made by an old copy of the page in a normal web process. That's ok,
[email protected]03b6d552012-03-29 04:03:011462 // because the permission check above would have caused an early return
1463 // already. We must use the full URL to find hosted apps, though, and not
1464 // just the origin.
[email protected]7b54ca02012-03-02 18:06:531465 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
[email protected]2b751a12012-03-06 03:00:351466 ExtensionURLInfo(opener_url));
[email protected]7b54ca02012-03-02 18:06:531467 if (extension && !extension->allow_background_js_access())
[email protected]03b6d552012-03-29 04:03:011468 *no_javascript_access = true;
[email protected]9f3fba52011-06-08 20:37:191469 }
1470 return true;
1471}
1472
1473std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
[email protected]df02aca2012-02-09 21:03:201474 const GURL& url, content::ResourceContext* context) {
[email protected]9f3fba52011-06-08 20:37:191475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1476 // Check if it's an extension-created worker, in which case we want to use
1477 // the name of the extension.
[email protected]df02aca2012-02-09 21:03:201478 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]9f3fba52011-06-08 20:37:191479 const Extension* extension =
1480 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
1481 return extension ? extension->name() : std::string();
1482}
1483
[email protected]99907362012-01-11 05:41:401484void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1485 return g_browser_process->ResourceDispatcherHostCreated();
[email protected]3cb054e62011-06-13 05:21:171486}
1487
[email protected]c52b2892012-03-07 11:01:021488content::SpeechRecognitionManagerDelegate*
1489 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
[email protected]a03f2d32012-03-14 00:26:321490#if defined(ENABLE_INPUT_SPEECH)
[email protected]c52b2892012-03-07 11:01:021491 return new speech::ChromeSpeechRecognitionManagerDelegate();
[email protected]a03f2d32012-03-14 00:26:321492#else
1493 return NULL;
1494#endif
[email protected]66cfec62012-02-24 17:57:511495}
1496
[email protected]ae6e9912011-07-27 01:18:281497net::NetLog* ChromeContentBrowserClient::GetNetLog() {
1498 return g_browser_process->net_log();
1499}
1500
[email protected]32538d92011-08-25 00:09:231501AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
1502 return new ChromeAccessTokenStore();
1503}
1504
[email protected]dbae6b02011-06-29 23:51:411505bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1506 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1507 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1508}
1509
[email protected]64d69de42012-02-06 00:19:541510void ChromeContentBrowserClient::OverrideWebkitPrefs(
[email protected]2e21fe292012-03-02 22:52:321511 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) {
[email protected]f3986f82012-01-03 20:00:061512 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581513 rvh->GetProcess()->GetBrowserContext());
[email protected]f3986f82012-01-03 20:00:061514 PrefService* prefs = profile->GetPrefs();
[email protected]f3986f82012-01-03 20:00:061515
[email protected]f3986f82012-01-03 20:00:061516 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541517 &web_prefs->standard_font_family_map);
[email protected]f3986f82012-01-03 20:00:061518 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541519 &web_prefs->fixed_font_family_map);
[email protected]f3986f82012-01-03 20:00:061520 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541521 &web_prefs->serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061522 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541523 &web_prefs->sans_serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061524 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541525 &web_prefs->cursive_font_family_map);
[email protected]f3986f82012-01-03 20:00:061526 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541527 &web_prefs->fantasy_font_family_map);
[email protected]85edc232012-10-05 08:56:031528 FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap,
1529 &web_prefs->pictograph_font_family_map);
[email protected]f3986f82012-01-03 20:00:061530
[email protected]64d69de42012-02-06 00:19:541531 web_prefs->default_font_size =
[email protected]ddf72142012-05-22 04:52:401532 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
[email protected]64d69de42012-02-06 00:19:541533 web_prefs->default_fixed_font_size =
[email protected]ddf72142012-05-22 04:52:401534 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
[email protected]64d69de42012-02-06 00:19:541535 web_prefs->minimum_font_size =
[email protected]ddf72142012-05-22 04:52:401536 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
[email protected]64d69de42012-02-06 00:19:541537 web_prefs->minimum_logical_font_size =
[email protected]ddf72142012-05-22 04:52:401538 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
[email protected]f3986f82012-01-03 20:00:061539
[email protected]ddf72142012-05-22 04:52:401540 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061541
[email protected]64d69de42012-02-06 00:19:541542 web_prefs->javascript_can_open_windows_automatically =
[email protected]ddf72142012-05-22 04:52:401543 prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically);
[email protected]64d69de42012-02-06 00:19:541544 web_prefs->dom_paste_enabled =
[email protected]f3986f82012-01-03 20:00:061545 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
[email protected]64d69de42012-02-06 00:19:541546 web_prefs->shrinks_standalone_images_to_fit =
[email protected]f3986f82012-01-03 20:00:061547 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
1548 const DictionaryValue* inspector_settings =
1549 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
1550 if (inspector_settings) {
1551 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys());
1552 iter != inspector_settings->end_keys(); ++iter) {
1553 std::string value;
1554 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value))
[email protected]64d69de42012-02-06 00:19:541555 web_prefs->inspector_settings.push_back(
[email protected]f3986f82012-01-03 20:00:061556 std::make_pair(*iter, value));
1557 }
1558 }
[email protected]64d69de42012-02-06 00:19:541559 web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
[email protected]f3986f82012-01-03 20:00:061560
[email protected]ddf72142012-05-22 04:52:401561 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled))
[email protected]64d69de42012-02-06 00:19:541562 web_prefs->javascript_enabled = false;
1563 if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled))
1564 web_prefs->web_security_enabled = false;
[email protected]ddf72142012-05-22 04:52:401565 if (!prefs->GetBoolean(prefs::kWebKitPluginsEnabled))
[email protected]64d69de42012-02-06 00:19:541566 web_prefs->plugins_enabled = false;
1567 if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled))
1568 web_prefs->java_enabled = false;
1569 web_prefs->loads_images_automatically =
[email protected]ddf72142012-05-22 04:52:401570 prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically);
[email protected]f3986f82012-01-03 20:00:061571
[email protected]64d69de42012-02-06 00:19:541572 if (prefs->GetBoolean(prefs::kDisable3DAPIs))
1573 web_prefs->experimental_webgl_enabled = false;
[email protected]f3986f82012-01-03 20:00:061574
[email protected]64d69de42012-02-06 00:19:541575 web_prefs->memory_info_enabled =
1576 prefs->GetBoolean(prefs::kEnableMemoryInfo);
1577 web_prefs->allow_displaying_insecure_content =
1578 prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
1579 web_prefs->allow_running_insecure_content =
1580 prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
[email protected]d3b935f2012-10-19 23:14:321581#if defined(OS_ANDROID)
1582 web_prefs->font_scale_factor =
1583 static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor));
1584 web_prefs->force_enable_zoom =
1585 prefs->GetBoolean(prefs::kWebKitForceEnableZoom);
1586#endif
[email protected]9d06d88d2012-02-23 22:37:081587 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
[email protected]f3986f82012-01-03 20:00:061588
[email protected]64d69de42012-02-06 00:19:541589 // The user stylesheet watcher may not exist in a testing profile.
[email protected]13169ab2012-04-06 07:48:151590 UserStyleSheetWatcher* user_style_sheet_watcher =
1591 UserStyleSheetWatcherFactory::GetForProfile(profile);
1592 if (user_style_sheet_watcher) {
[email protected]64d69de42012-02-06 00:19:541593 web_prefs->user_style_sheet_enabled = true;
1594 web_prefs->user_style_sheet_location =
[email protected]13169ab2012-04-06 07:48:151595 user_style_sheet_watcher->user_style_sheet();
[email protected]64d69de42012-02-06 00:19:541596 } else {
1597 web_prefs->user_style_sheet_enabled = false;
[email protected]f3986f82012-01-03 20:00:061598 }
1599
[email protected]b7e44ff2012-02-16 03:37:341600 web_prefs->asynchronous_spell_checking_enabled =
[email protected]37b928e2012-05-30 09:01:101601#if defined(OS_MACOSX)
1602 // TODO(hbono): Bug 107371: Implement asynchronous spellchecking API for
1603 // Mac so it uses NSSpellChecker in the background.
1604 false;
1605#else
1606 !CommandLine::ForCurrentProcess()->
[email protected]57890242012-10-23 17:46:521607 HasSwitch(switches::kForceSyncSpellCheck);
[email protected]37b928e2012-05-30 09:01:101608#endif
[email protected]b7e44ff2012-02-16 03:37:341609 web_prefs->unified_textchecker_enabled =
[email protected]57890242012-10-23 17:46:521610 web_prefs->asynchronous_spell_checking_enabled;
[email protected]dd5d0fb2012-01-18 03:37:571611
[email protected]64d69de42012-02-06 00:19:541612 web_prefs->uses_universal_detector =
[email protected]f3986f82012-01-03 20:00:061613 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);
[email protected]64d69de42012-02-06 00:19:541614 web_prefs->text_areas_are_resizable =
[email protected]f3986f82012-01-03 20:00:061615 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
[email protected]64d69de42012-02-06 00:19:541616 web_prefs->hyperlink_auditing_enabled =
[email protected]f3986f82012-01-03 20:00:061617 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
1618
1619 // Make sure we will set the default_encoding with canonical encoding name.
[email protected]64d69de42012-02-06 00:19:541620 web_prefs->default_encoding =
[email protected]f3986f82012-01-03 20:00:061621 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
[email protected]64d69de42012-02-06 00:19:541622 web_prefs->default_encoding);
1623 if (web_prefs->default_encoding.empty()) {
[email protected]ddf72142012-05-22 04:52:401624 prefs->ClearPref(prefs::kDefaultCharset);
1625 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061626 }
[email protected]64d69de42012-02-06 00:19:541627 DCHECK(!web_prefs->default_encoding.empty());
[email protected]f3986f82012-01-03 20:00:061628
[email protected]299d7f12012-05-23 05:31:151629 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
1630 chrome::ViewType view_type = chrome::GetViewType(web_contents);
[email protected]f3986f82012-01-03 20:00:061631 ExtensionService* service = profile->GetExtensionService();
1632 if (service) {
[email protected]1bc28312012-11-08 08:31:531633 const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
1634 const Extension* extension = service->extensions()->GetByID(url.host());
1635 // Ensure that we are only granting extension preferences to URLs with
1636 // the correct scheme. Without this check, chrome-guest:// schemes used by
1637 // webview tags as well as hosts that happen to match the id of an
1638 // installed extension would get the wrong preferences.
1639 if (url.SchemeIs(chrome::kExtensionScheme)) {
1640 extension_webkit_preferences::SetPreferences(
1641 extension, view_type, web_prefs);
1642 }
[email protected]f3986f82012-01-03 20:00:061643 }
1644
[email protected]b7c4f032012-08-07 16:38:561645 if (content::IsForceCompositingModeEnabled())
[email protected]4abe58d2012-06-08 03:09:091646 web_prefs->force_compositing_mode = true;
1647
[email protected]299d7f12012-05-23 05:31:151648 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) {
[email protected]64d69de42012-02-06 00:19:541649 web_prefs->allow_scripts_to_close_windows = true;
[email protected]299d7f12012-05-23 05:31:151650 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
[email protected]f3986f82012-01-03 20:00:061651 // Disable all kinds of acceleration for background pages.
1652 // See http://crbug.com/96005 and http://crbug.com/96006
[email protected]64d69de42012-02-06 00:19:541653 web_prefs->force_compositing_mode = false;
1654 web_prefs->accelerated_compositing_enabled = false;
1655 web_prefs->accelerated_2d_canvas_enabled = false;
1656 web_prefs->accelerated_video_enabled = false;
1657 web_prefs->accelerated_painting_enabled = false;
1658 web_prefs->accelerated_plugins_enabled = false;
[email protected]f3986f82012-01-03 20:00:061659 }
[email protected]2e21fe292012-03-02 22:52:321660
1661#if defined(FILE_MANAGER_EXTENSION)
1662 // Override the default of suppressing HW compositing for WebUI pages for the
1663 // file manager, which is implemented using WebUI but wants HW acceleration
1664 // for video decode & render.
1665 if (url.spec() == chrome::kChromeUIFileManagerURL) {
1666 web_prefs->accelerated_compositing_enabled = true;
1667 web_prefs->accelerated_2d_canvas_enabled = true;
1668 }
1669#endif
[email protected]181a95ee2011-07-12 19:26:361670}
1671
1672void ChromeContentBrowserClient::UpdateInspectorSetting(
1673 RenderViewHost* rvh, const std::string& key, const std::string& value) {
[email protected]f3986f82012-01-03 20:00:061674 content::BrowserContext* browser_context =
[email protected]9f76c1e2012-03-05 15:15:581675 rvh->GetProcess()->GetBrowserContext();
[email protected]f3986f82012-01-03 20:00:061676 DictionaryPrefUpdate update(
1677 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1678 prefs::kWebKitInspectorSettings);
1679 DictionaryValue* inspector_settings = update.Get();
1680 inspector_settings->SetWithoutPathExpansion(key,
1681 Value::CreateStringValue(value));
[email protected]181a95ee2011-07-12 19:26:361682}
1683
1684void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
[email protected]f3986f82012-01-03 20:00:061685 content::BrowserContext* browser_context =
[email protected]9f76c1e2012-03-05 15:15:581686 rvh->GetProcess()->GetBrowserContext();
[email protected]f3986f82012-01-03 20:00:061687 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1688 ClearPref(prefs::kWebKitInspectorSettings);
[email protected]181a95ee2011-07-12 19:26:361689}
1690
[email protected]b8148ac2011-07-13 22:03:251691void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1692 BrowserURLHandler* handler) {
1693 // Add the default URL handlers.
1694 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1695 BrowserURLHandler::null_handler());
1696 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1697 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1698
[email protected]b3adbd02011-11-30 22:23:271699 // about: handler. Must come before chrome: handler, since it will
1700 // rewrite about: urls to chrome: URLs and then expect chrome: to
1701 // actually handle them.
[email protected]b8148ac2011-07-13 22:03:251702 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1703 BrowserURLHandler::null_handler());
1704 // chrome: & friends.
[email protected]f8f93eb2012-09-25 03:06:241705 handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
[email protected]b8148ac2011-07-13 22:03:251706}
1707
1708void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371709 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581710 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:471711 BrowsingDataRemover* remover =
1712 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]3d4d4cf2012-06-04 10:40:551713 remover->Remove(BrowsingDataRemover::REMOVE_CACHE,
1714 BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:251715 // BrowsingDataRemover takes care of deleting itself when done.
1716}
1717
1718void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:371719 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581720 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:471721 BrowsingDataRemover* remover =
1722 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]dceaa912011-09-06 17:17:231723 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]3d4d4cf2012-06-04 10:40:551724 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:251725 // BrowsingDataRemover takes care of deleting itself when done.
1726}
1727
[email protected]e1d16eb92011-08-18 23:19:321728FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1729 return download_util::GetDefaultDownloadDirectory();
1730}
1731
[email protected]c9b6eb62011-10-18 20:49:391732std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
1733 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
1734}
1735
[email protected]b7631cc2012-09-15 05:08:381736void ChromeContentBrowserClient::DidCreatePpapiPlugin(
1737 content::BrowserPpapiHost* browser_host) {
1738 browser_host->GetPpapiHost()->AddHostFactoryFilter(
1739 scoped_ptr<ppapi::host::HostFactory>(
1740 new ChromeBrowserPepperHostFactory(browser_host)));
1741}
1742
[email protected]0c7193742012-11-07 19:05:031743content::BrowserPpapiHost*
1744 ChromeContentBrowserClient::GetExternalBrowserPpapiHost(
1745 int plugin_process_id) {
1746 BrowserChildProcessHostIterator iter(content::PROCESS_TYPE_NACL_LOADER);
1747 while (!iter.Done()) {
1748 NaClProcessHost* host = static_cast<NaClProcessHost*>(iter.GetDelegate());
1749 if (host->process() &&
1750 host->process()->GetData().id == plugin_process_id) {
1751 // Found the plugin.
1752 return host->browser_ppapi_host();
1753 }
1754 ++iter;
1755 }
1756 return NULL;
1757}
1758
[email protected]38cd8f7f2012-06-15 22:06:071759bool ChromeContentBrowserClient::AllowPepperSocketAPI(
[email protected]157cc902012-11-02 06:31:581760 content::BrowserContext* browser_context,
1761 const GURL& url,
1762 const content::SocketPermissionRequest& params) {
[email protected]a658d452012-03-02 12:45:291763 if (!url.is_valid())
1764 return false;
1765
1766 std::string host = url.host();
[email protected]92444942012-06-16 09:05:281767 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host))
[email protected]a658d452012-03-02 12:45:291768 return true;
1769
[email protected]9a5940d2012-04-27 19:16:231770 Profile* profile = Profile::FromBrowserContext(browser_context);
1771 const Extension* extension = NULL;
1772 if (profile && profile->GetExtensionService()) {
1773 extension = profile->GetExtensionService()->extensions()->
1774 GetExtensionOrAppByURL(ExtensionURLInfo(url));
1775 }
1776
[email protected]f237c0f2012-03-10 07:49:101777 // Need to check this now and not on construction because otherwise it won't
1778 // work with browser_tests.
1779 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1780 std::string allowed_list =
1781 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
[email protected]9a5940d2012-04-27 19:16:231782 if (allowed_list == "*") {
1783 // The wildcard allows socket API only for packaged and platform apps.
1784 return extension &&
[email protected]c4f459d2012-09-28 04:40:101785 (extension->GetType() == Extension::TYPE_LEGACY_PACKAGED_APP ||
[email protected]9a5940d2012-04-27 19:16:231786 extension->GetType() == Extension::TYPE_PLATFORM_APP);
1787 } else if (!allowed_list.empty()) {
[email protected]f237c0f2012-03-10 07:49:101788 StringTokenizer t(allowed_list, ",");
1789 while (t.GetNext()) {
1790 if (t.token() == host)
1791 return true;
1792 }
1793 }
1794
[email protected]a658d452012-03-02 12:45:291795 if (!extension)
1796 return false;
1797
[email protected]157cc902012-11-02 06:31:581798 extensions::SocketPermission::CheckParam extension_params(
1799 params.type, params.host, params.port);
1800 if (extension->CheckAPIPermissionWithParam(APIPermission::kSocket,
1801 &extension_params))
[email protected]a658d452012-03-02 12:45:291802 return true;
1803
1804 return false;
[email protected]e461da2f2012-02-16 19:06:401805}
1806
[email protected]38cd8f7f2012-06-15 22:06:071807bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() {
1808 return CommandLine::ForCurrentProcess()->HasSwitch(
1809 switches::kPpapiFlashInProcess);
1810}
1811
[email protected]a7944aa2012-10-15 10:12:141812FilePath ChromeContentBrowserClient::GetHyphenDictionaryDirectory() {
1813 FilePath directory;
1814 PathService::Get(chrome::DIR_APP_DICTIONARIES, &directory);
1815 return directory.Append(FILE_PATH_LITERAL("Hyphen"));
1816}
1817
[email protected]e60c0232011-11-11 19:56:351818#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]a1733df2012-06-22 11:24:181819void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
1820 const CommandLine& command_line,
[email protected]40da3e0c2012-10-24 22:03:381821 int child_process_id,
[email protected]c7abd422012-09-25 00:20:081822 std::vector<FileDescriptorInfo>* mappings) {
[email protected]29699c22012-10-03 23:57:391823#if defined(OS_ANDROID)
1824 FilePath data_path;
1825 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
1826 DCHECK(!data_path.empty());
1827
1828 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
1829 FilePath chrome_pak = data_path.AppendASCII("chrome.pak");
1830 base::PlatformFile f =
1831 base::CreatePlatformFile(chrome_pak, flags, NULL, NULL);
1832 DCHECK(f != base::kInvalidPlatformFileValue);
1833 mappings->push_back(FileDescriptorInfo(kAndroidChromePakDescriptor,
1834 FileDescriptor(f, true)));
1835
1836 FilePath chrome_resources_pak =
1837 data_path.AppendASCII("chrome_100_percent.pak");
1838 f = base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL);
1839 DCHECK(f != base::kInvalidPlatformFileValue);
1840 mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor,
1841 FileDescriptor(f, true)));
1842
1843 const std::string locale = GetApplicationLocale();
1844 FilePath locale_pak = ResourceBundle::GetSharedInstance().
1845 GetLocaleFilePath(locale, false);
1846 f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL);
1847 DCHECK(f != base::kInvalidPlatformFileValue);
1848 mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor,
1849 FileDescriptor(f, true)));
[email protected]40da3e0c2012-10-24 22:03:381850
1851#if defined(USE_LINUX_BREAKPAD)
1852 f = crash_dump_manager_->CreateMinidumpFile(child_process_id);
1853 if (f == base::kInvalidPlatformFileValue) {
1854 LOG(ERROR) << "Failed to create file for minidump, crash reporting will be "
1855 "disabled for this process.";
1856 } else {
1857 mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor,
1858 FileDescriptor(f, true)));
1859 }
1860#endif // defined(USE_LINUX_BREAKPAD)
1861
1862#else
1863 int crash_signal_fd = GetCrashSignalFD(command_line);
1864 if (crash_signal_fd >= 0) {
1865 mappings->push_back(FileDescriptorInfo(kCrashDumpSignal,
1866 FileDescriptor(crash_signal_fd,
1867 false)));
1868 }
[email protected]29699c22012-10-03 23:57:391869#endif // defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:301870}
[email protected]e60c0232011-11-11 19:56:351871#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:301872
[email protected]4a65826d2011-08-25 16:04:011873#if defined(OS_WIN)
1874const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
1875 return chrome::kBrowserResourcesDll;
1876}
1877#endif
1878
[email protected]40da3e0c2012-10-24 22:03:381879#if defined(OS_ANDROID)
1880void ChromeContentBrowserClient::InitCrashDumpManager() {
1881 if (!crash_dump_manager_.get())
1882 crash_dump_manager_.reset(new CrashDumpManager());
1883}
1884#endif
1885
[email protected]37a72af2011-06-13 05:42:011886#if defined(USE_NSS)
1887crypto::CryptoModuleBlockingPasswordDelegate*
1888 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1889 const GURL& url) {
[email protected]6246ac52012-09-24 01:55:291890 return chrome::NewCryptoModuleBlockingDialogDelegate(
1891 chrome::kCryptoModulePasswordKeygen, url.host());
[email protected]37a72af2011-06-13 05:42:011892}
1893#endif
1894
[email protected]e9a32a52012-06-14 23:32:431895void ChromeContentBrowserClient::SetApplicationLocale(
1896 const std::string& locale) {
1897 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1898
1899 // This object is guaranteed to outlive all threads so we don't have to
1900 // worry about the lack of refcounting and can just post as Unretained.
1901 //
1902 // The common case is that this function is called early in Chrome startup
1903 // before any threads are created (it will also be called later if the user
1904 // changes the pref). In this case, there will be no threads created and
1905 // posting will fail. When there are no threads, we can just set the string
1906 // without worrying about threadsafety.
1907 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1908 base::Bind(
1909 &ChromeContentBrowserClient::SetApplicationLocaleOnIOThread,
1910 base::Unretained(this), locale)))
1911 io_thread_application_locale_ = locale;
1912}
1913
1914void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
1915 const std::string& locale) {
1916 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1917 io_thread_application_locale_ = locale;
1918}
1919
[email protected]d977f9c2011-03-14 16:10:261920} // namespace chrome