blob: d46465abc1002a03fd5f652aaaf48bd22423ea42 [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]eabbfb12013-04-05 23:28:3513#include "base/lazy_instance.h"
[email protected]29699c22012-10-03 23:57:3914#include "base/path_service.h"
[email protected]3853a4c2013-02-11 17:15:5715#include "base/prefs/pref_service.h"
[email protected]b71313232013-05-06 06:16:2916#include "base/string_number_conversions.h"
[email protected]f3986f82012-01-03 20:00:0617#include "base/utf_string_conversions.h"
[email protected]b80f68432011-05-02 17:22:3018#include "chrome/app/breakpad_mac.h"
[email protected]056efdc2013-04-06 00:14:5319#include "chrome/browser/app_mode/app_mode_utils.h"
[email protected]b8148ac2011-07-13 22:03:2520#include "chrome/browser/browser_about_handler.h"
[email protected]b80f68432011-05-02 17:22:3021#include "chrome/browser/browser_process.h"
[email protected]b0cb5e82012-07-19 19:22:4722#include "chrome/browser/browsing_data/browsing_data_helper.h"
23#include "chrome/browser/browsing_data/browsing_data_remover.h"
[email protected]763ec4ca2011-04-29 15:48:1224#include "chrome/browser/character_encoding.h"
[email protected]43535512013-02-20 20:41:4125#include "chrome/browser/chrome_net_benchmarking_message_filter.h"
[email protected]317f96c92011-05-31 06:53:4126#include "chrome/browser/chrome_quota_permission_context.h"
[email protected]edece212011-11-16 11:56:5627#include "chrome/browser/content_settings/content_settings_utils.h"
[email protected]30fde822011-10-28 09:49:0528#include "chrome/browser/content_settings/cookie_settings.h"
[email protected]6786bf402011-12-03 15:19:4529#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]8093a542011-05-13 07:29:3230#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]9d06d88d2012-02-23 22:37:0831#include "chrome/browser/defaults.h"
[email protected]e1d16eb92011-08-18 23:19:3232#include "chrome/browser/download/download_util.h"
[email protected]17263b22013-05-16 03:29:2233#include "chrome/browser/extensions/activity_log/activity_log.h"
[email protected]2b33dcd02012-03-18 01:34:1634#include "chrome/browser/extensions/api/web_request/web_request_api.h"
[email protected]1deace22013-05-22 06:14:4635#include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
[email protected]76411f412012-02-22 18:56:0636#include "chrome/browser/extensions/extension_host.h"
[email protected]941623e2011-06-07 23:06:0437#include "chrome/browser/extensions/extension_info_map.h"
[email protected]9c1662b2012-03-06 15:44:3338#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]d977f9c2011-03-14 16:10:2639#include "chrome/browser/extensions/extension_service.h"
[email protected]31d8f5f22012-04-02 15:22:0840#include "chrome/browser/extensions/extension_system.h"
[email protected]b8148ac2011-07-13 22:03:2541#include "chrome/browser/extensions/extension_web_ui.h"
[email protected]f3986f82012-01-03 20:00:0642#include "chrome/browser/extensions/extension_webkit_preferences.h"
[email protected]eb4832a2012-12-08 01:57:5243#include "chrome/browser/extensions/suggest_permission_util.h"
[email protected]32538d92011-08-25 00:09:2344#include "chrome/browser/geolocation/chrome_access_token_store.h"
[email protected]763ec4ca2011-04-29 15:48:1245#include "chrome/browser/google/google_util.h"
[email protected]11158e2d2013-02-01 02:31:5646#include "chrome/browser/media/media_capture_devices_dispatcher.h"
[email protected]95132f52013-04-12 02:19:0447#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
[email protected]0c7193742012-11-07 19:05:0348#include "chrome/browser/nacl_host/nacl_process_host.h"
[email protected]ae6e9912011-07-27 01:18:2849#include "chrome/browser/net/chrome_net_log.h"
[email protected]941623e2011-06-07 23:06:0450#include "chrome/browser/notifications/desktop_notification_service.h"
51#include "chrome/browser/notifications/desktop_notification_service_factory.h"
[email protected]93f72062013-05-29 20:29:4052#include "chrome/browser/pepper_permission_util.h"
[email protected]0609b17f2011-05-31 20:13:4253#include "chrome/browser/platform_util.h"
[email protected]c2295f72013-01-03 22:18:5654#include "chrome/browser/plugins/plugin_info_message_filter.h"
[email protected]f3986f82012-01-03 20:00:0655#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]f9034cf2011-07-21 12:43:4156#include "chrome/browser/prerender/prerender_manager.h"
[email protected]3085c502011-10-05 17:50:5057#include "chrome/browser/prerender/prerender_manager_factory.h"
[email protected]2736c032012-05-11 18:06:0758#include "chrome/browser/prerender/prerender_message_filter.h"
[email protected]f9034cf2011-07-21 12:43:4159#include "chrome/browser/prerender/prerender_tracker.h"
[email protected]05fcf982011-04-19 00:44:1460#include "chrome/browser/printing/printing_message_filter.h"
[email protected]7e75e4a2013-05-17 17:20:0361#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
[email protected]05fcf982011-04-19 00:44:1462#include "chrome/browser/profiles/profile.h"
[email protected]8093a542011-05-13 07:29:3263#include "chrome/browser/profiles/profile_io_data.h"
[email protected]76411f412012-02-22 18:56:0664#include "chrome/browser/profiles/profile_manager.h"
[email protected]05fcf982011-04-19 00:44:1465#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
[email protected]b7631cc2012-09-15 05:08:3866#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
[email protected]a7b8e43d2013-03-18 18:52:4367#include "chrome/browser/search/instant_service.h"
68#include "chrome/browser/search/instant_service_factory.h"
69#include "chrome/browser/search/search.h"
[email protected]05fcf982011-04-19 00:44:1470#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
[email protected]c52b2892012-03-07 11:01:0271#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
[email protected]7a06d282013-05-03 04:39:3372#include "chrome/browser/speech/tts_message_filter.h"
[email protected]8ec71262011-07-28 08:12:4673#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
[email protected]3b455502012-12-11 18:22:5874#include "chrome/browser/ssl/ssl_add_certificate.h"
[email protected]848dd042011-06-04 18:24:0375#include "chrome/browser/ssl/ssl_blocking_page.h"
[email protected]11feec322012-09-18 03:58:5276#include "chrome/browser/ssl/ssl_tab_helper.h"
[email protected]8ec26472011-06-06 16:52:4577#include "chrome/browser/tab_contents/tab_util.h"
[email protected]c27541f2012-05-24 19:25:5478#include "chrome/browser/toolkit_extra_parts.h"
[email protected]a28e3302013-02-03 03:50:4379#include "chrome/browser/ui/chrome_select_file_policy.h"
[email protected]b5d73422012-06-02 23:46:4480#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
[email protected]863f70a2012-01-27 02:05:5081#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
[email protected]970c63e2013-03-07 00:25:3082#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
[email protected]f3986f82012-01-03 20:00:0683#include "chrome/browser/user_style_sheet_watcher.h"
[email protected]13169ab2012-04-06 07:48:1584#include "chrome/browser/user_style_sheet_watcher_factory.h"
[email protected]1352ca92013-04-30 02:30:2785#include "chrome/browser/validation_message_message_filter.h"
[email protected]db9f2142013-05-27 22:56:1686#include "chrome/browser/webview/webview_guest.h"
[email protected]b80f68432011-05-02 17:22:3087#include "chrome/common/child_process_logging.h"
[email protected]4a65826d2011-08-25 16:04:0188#include "chrome/common/chrome_constants.h"
[email protected]a7944aa2012-10-15 10:12:1489#include "chrome/common/chrome_paths.h"
[email protected]f3b357692013-03-22 05:16:1390#include "chrome/common/chrome_process_type.h"
[email protected]b80f68432011-05-02 17:22:3091#include "chrome/common/chrome_switches.h"
[email protected]9367eabc2013-03-01 01:29:2992#include "chrome/common/extensions/background_info.h"
[email protected]941623e2011-06-07 23:06:0493#include "chrome/common/extensions/extension.h"
[email protected]395045c2012-05-22 15:04:3894#include "chrome/common/extensions/extension_process_policy.h"
[email protected]615d88f2011-12-13 01:47:4495#include "chrome/common/extensions/extension_set.h"
[email protected]561e33d52013-04-03 06:58:4396#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
[email protected]b71313232013-05-06 06:16:2997#include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
[email protected]157cc902012-11-02 06:31:5898#include "chrome/common/extensions/permissions/socket_permission.h"
[email protected]f1933792011-06-14 00:49:3499#include "chrome/common/logging_chrome.h"
[email protected]763ec4ca2011-04-29 15:48:12100#include "chrome/common/pref_names.h"
[email protected]3e69bc82011-05-26 23:22:38101#include "chrome/common/render_messages.h"
[email protected]c5dbef02011-05-13 05:06:09102#include "chrome/common/url_constants.h"
[email protected]e8f3f9982013-05-10 20:59:53103#include "chromeos/chromeos_constants.h"
[email protected]75fee372013-03-06 00:42:44104#include "components/user_prefs/pref_registry_syncable.h"
[email protected]e0ada9c2012-03-20 03:54:43105#include "content/public/browser/browser_child_process_host.h"
[email protected]b48c9182011-10-26 18:03:30106#include "content/public/browser/browser_main_parts.h"
[email protected]b7631cc2012-09-15 05:08:38107#include "content/public/browser/browser_ppapi_host.h"
[email protected]825b1662012-03-12 19:07:31108#include "content/public/browser/browser_url_handler.h"
[email protected]0c7193742012-11-07 19:05:03109#include "content/public/browser/child_process_data.h"
[email protected]b9535422012-02-09 01:47:59110#include "content/public/browser/child_process_security_policy.h"
[email protected]cb6430932012-10-31 00:53:36111#include "content/public/browser/compositor_util.h"
[email protected]f3b1a082011-11-18 00:34:30112#include "content/public/browser/render_process_host.h"
[email protected]9c1662b2012-03-06 15:44:33113#include "content/public/browser/render_view_host.h"
[email protected]ce967862012-02-09 22:47:05114#include "content/public/browser/resource_context.h"
[email protected]b6583592012-01-25 19:52:33115#include "content/public/browser/site_instance.h"
[email protected]91ee3682012-01-19 15:02:19116#include "content/public/browser/web_contents.h"
[email protected]8643e6d2012-01-18 20:26:10117#include "content/public/browser/web_contents_view.h"
[email protected]e0ada9c2012-03-20 03:54:43118#include "content/public/common/child_process_host.h"
[email protected]a1733df2012-06-22 11:24:18119#include "content/public/common/content_descriptors.h"
[email protected]cb2edf22013-04-01 20:25:23120#include "extensions/browser/view_type_utils.h"
[email protected]885c0e92012-11-13 20:27:42121#include "extensions/common/constants.h"
[email protected]c9b6eb62011-10-18 20:49:39122#include "grit/generated_resources.h"
[email protected]2a281332012-07-11 22:20:23123#include "grit/ui_resources.h"
[email protected]1bc28312012-11-08 08:31:53124#include "net/base/escape.h"
[email protected]3b455502012-12-11 18:22:58125#include "net/base/mime_util.h"
[email protected]5b9bc352012-07-18 13:13:34126#include "net/cookies/canonical_cookie.h"
[email protected]aa84a7e2012-03-15 21:29:06127#include "net/cookies/cookie_options.h"
[email protected]536fd0b2013-03-14 17:41:57128#include "net/ssl/ssl_cert_request_info.h"
[email protected]b7631cc2012-09-15 05:08:38129#include "ppapi/host/ppapi_host.h"
[email protected]c9b6eb62011-10-18 20:49:39130#include "ui/base/l10n/l10n_util.h"
[email protected]ac55e292011-06-24 05:16:08131#include "ui/base/resource/resource_bundle.h"
[email protected]fb1aac12013-05-14 05:30:24132#include "ui/message_center/message_center_util.h"
[email protected]4fdf6742012-01-10 20:14:36133#include "webkit/glue/webpreferences.h"
[email protected]a085aed72012-04-24 05:32:04134#include "webkit/plugins/plugin_switches.h"
[email protected]d977f9c2011-03-14 16:10:26135
[email protected]b48c9182011-10-26 18:03:30136#if defined(OS_WIN)
[email protected]199fc7a2011-09-28 22:45:38137#include "chrome/browser/chrome_browser_main_win.h"
[email protected]34f48682013-03-20 00:30:18138#include "sandbox/win/src/sandbox_policy.h"
[email protected]199fc7a2011-09-28 22:45:38139#elif defined(OS_MACOSX)
140#include "chrome/browser/chrome_browser_main_mac.h"
[email protected]7ceb99012011-12-21 08:05:56141#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
[email protected]b48c9182011-10-26 18:03:30142#elif defined(OS_CHROMEOS)
143#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
[email protected]5c915252013-05-07 13:15:39144#include "chrome/browser/chromeos/login/startup_utils.h"
[email protected]fe69558d2012-03-12 11:34:49145#include "chrome/browser/chromeos/login/user_manager.h"
[email protected]5c915252013-05-07 13:15:39146#include "chrome/browser/chromeos/system/statistics_provider.h"
[email protected]931d1042013-04-05 17:50:44147#include "chromeos/chromeos_switches.h"
[email protected]81ce2c42012-03-24 01:43:26148#elif defined(OS_LINUX)
[email protected]b48c9182011-10-26 18:03:30149#include "chrome/browser/chrome_browser_main_linux.h"
[email protected]81054f812012-08-30 00:47:09150#elif defined(OS_ANDROID)
[email protected]40da3e0c2012-10-24 22:03:38151#include "chrome/browser/android/crash_dump_manager.h"
[email protected]81054f812012-08-30 00:47:09152#include "chrome/browser/chrome_browser_main_android.h"
[email protected]29699c22012-10-03 23:57:39153#include "chrome/common/descriptors_android.h"
[email protected]b48c9182011-10-26 18:03:30154#elif defined(OS_POSIX)
155#include "chrome/browser/chrome_browser_main_posix.h"
156#endif
157
[email protected]6653c192012-04-10 22:52:44158#if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:30159#include "base/linux_util.h"
[email protected]1602cde2012-06-26 15:09:12160#include "chrome/browser/crash_handler_host_linux.h"
[email protected]1fd5302c2011-05-28 04:06:43161#endif
[email protected]b80f68432011-05-02 17:22:30162
[email protected]1e87df32012-09-12 04:53:19163#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
164#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
165#endif
166
[email protected]29699c22012-10-03 23:57:39167#if defined(OS_ANDROID)
168#include "ui/base/ui_base_paths.h"
169#endif
170
[email protected]37a72af2011-06-13 05:42:01171#if defined(USE_NSS)
172#include "chrome/browser/ui/crypto_module_password_dialog.h"
173#endif
174
[email protected]d5bcd06f2013-04-21 08:07:24175#if !defined(OS_CHROMEOS)
176#include "chrome/browser/signin/signin_manager.h"
177#include "chrome/browser/signin/signin_manager_factory.h"
178#endif
179
[email protected]02250952013-04-24 23:52:53180#if !defined(OS_ANDROID)
181#include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h"
182#endif
183
[email protected]c7abd422012-09-25 00:20:08184using base::FileDescriptor;
[email protected]c8c77182011-12-21 15:04:47185using content::AccessTokenStore;
[email protected]0c7193742012-11-07 19:05:03186using content::BrowserChildProcessHostIterator;
[email protected]631bb742011-11-02 11:29:39187using content::BrowserThread;
[email protected]825b1662012-03-12 19:07:31188using content::BrowserURLHandler;
[email protected]b9535422012-02-09 01:47:59189using content::ChildProcessSecurityPolicy;
[email protected]c7abd422012-09-25 00:20:08190using content::FileDescriptorInfo;
[email protected]9f9749a2012-03-02 19:37:00191using content::QuotaPermissionContext;
[email protected]eaabba22012-03-07 15:02:11192using content::RenderViewHost;
[email protected]b6583592012-01-25 19:52:33193using content::SiteInstance;
[email protected]83ff91c2012-01-05 20:54:13194using content::WebContents;
[email protected]c2e66e12012-06-27 06:27:06195using extensions::APIPermission;
[email protected]1c321ee2012-05-21 03:02:34196using extensions::Extension;
[email protected]1d5e58b2013-01-31 08:41:40197using extensions::Manifest;
[email protected]631bb742011-11-02 11:29:39198
[email protected]c5dbef02011-05-13 05:06:09199namespace {
200
[email protected]eabbfb12013-04-05 23:28:35201// Cached version of the locale so we can return the locale on the I/O
202// thread.
203base::LazyInstance<std::string> g_io_thread_application_locale;
204
[email protected]93f72062013-05-29 20:29:40205#if defined(ENABLE_PLUGINS)
[email protected]e461da2f2012-02-16 19:06:40206const char* kPredefinedAllowedSocketOrigins[] = {
207 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
[email protected]b95bf502012-04-06 07:41:18208 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client)
[email protected]99132682012-04-24 19:00:45209 "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126
210 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
211 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop
212 "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
[email protected]a450b6be2012-05-22 19:30:35213 "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
[email protected]9040a0c22012-06-22 19:06:54214 "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089
215 "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099
216 "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099
217 "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099
218 "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099
219 "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099
[email protected]4dc30b82012-08-15 00:24:38220 "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099
[email protected]45db05f2012-12-10 21:52:58221 "jdfhpkjeckflbbleddjlpimecpbjdeep", // see crbug.com/142514
[email protected]b71313232013-05-06 06:16:29222 "iabmpiboiopbgfabjmgeedhcmjenhbla", // see crbug.com/165080
223 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789
224 "7525AF4F66763A70A883C4700529F647B470E4D2", // see crbug.com/238084
225 "0B549507088E1564D672F7942EB87CA4DAD73972", // see crbug.com/238084
226 "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084
[email protected]e461da2f2012-02-16 19:06:40227};
[email protected]93f72062013-05-29 20:29:40228#endif
[email protected]e461da2f2012-02-16 19:06:40229
[email protected]f8f93eb2012-09-25 03:06:24230// Returns a copy of the given url with its host set to given host and path set
231// to given path. Other parts of the url will be the same.
232GURL ReplaceURLHostAndPath(const GURL& url,
233 const std::string& host,
234 const std::string& path) {
235 url_canon::Replacements<char> replacements;
236 replacements.SetHost(host.c_str(),
237 url_parse::Component(0, host.length()));
238 replacements.SetPath(path.c_str(),
239 url_parse::Component(0, path.length()));
240 return url.ReplaceComponents(replacements);
241}
242
243// Maps "foo://bar/baz/" to "foo://chrome/bar/baz/".
244GURL AddUberHost(const GURL& url) {
245 const std::string uber_host = chrome::kChromeUIUberHost;
246 const std::string new_path = url.host() + url.path();
247
248 return ReplaceURLHostAndPath(url, uber_host, new_path);
249}
250
[email protected]045bf7c2012-09-28 20:27:36251// If url->host() is "chrome" and url->path() has characters other than the
252// first slash, changes the url from "foo://chrome/bar/" to "foo://bar/" and
253// returns true. Otherwise returns false.
[email protected]f8f93eb2012-09-25 03:06:24254bool RemoveUberHost(GURL* url) {
255 if (url->host() != chrome::kChromeUIUberHost)
256 return false;
257
[email protected]045bf7c2012-09-28 20:27:36258 if (url->path().empty() || url->path() == "/")
259 return false;
260
[email protected]f8f93eb2012-09-25 03:06:24261 const std::string old_path = url->path();
262
263 const std::string::size_type separator = old_path.find('/', 1);
264 std::string new_host;
265 std::string new_path;
266 if (separator == std::string::npos) {
[email protected]045bf7c2012-09-28 20:27:36267 new_host = old_path.substr(1);
[email protected]f8f93eb2012-09-25 03:06:24268 } else {
269 new_host = old_path.substr(1, separator - 1);
270 new_path = old_path.substr(separator);
271 }
272
273 *url = ReplaceURLHostAndPath(*url, new_host, new_path);
274
275 return true;
276}
277
[email protected]b8148ac2011-07-13 22:03:25278// Handles rewriting Web UI URLs.
[email protected]8d3132f62011-10-12 07:13:42279bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
[email protected]f8f93eb2012-09-25 03:06:24280 // Do not handle special URLs such as "about:foo"
281 if (!url->host().empty()) {
282 const GURL chrome_url = AddUberHost(*url);
283
284 // Handle valid "chrome://chrome/foo" URLs so the reverse handler will
285 // be called.
286 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
287 browser_context, chrome_url))
288 return true;
289 }
290
[email protected]863f70a2012-01-27 02:05:50291 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
292 browser_context, *url))
[email protected]b8148ac2011-07-13 22:03:25293 return false;
294
[email protected]fe69558d2012-03-12 11:34:49295#if defined(OS_CHROMEOS)
296 // Special case : in ChromeOS in Guest mode bookmarks and history are
297 // disabled for security reasons. New tab page explains the reasons, so
298 // we redirect user to new tab page.
299 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
300 if (url->SchemeIs(chrome::kChromeUIScheme) &&
301 (url->DomainIs(chrome::kChromeUIBookmarksHost) ||
302 url->DomainIs(chrome::kChromeUIHistoryHost))) {
303 // Rewrite with new tab URL
304 *url = GURL(chrome::kChromeUINewTabURL);
305 }
306 }
307#endif
308
[email protected]b8148ac2011-07-13 22:03:25309 // Special case the new tab page. In older versions of Chrome, the new tab
310 // page was hosted at chrome-internal:<blah>. This might be in people's saved
311 // sessions or bookmarks, so we say any URL with that scheme triggers the new
312 // tab page.
313 if (url->SchemeIs(chrome::kChromeInternalScheme)) {
314 // Rewrite it with the proper new tab URL.
315 *url = GURL(chrome::kChromeUINewTabURL);
316 }
317
318 return true;
319}
320
[email protected]f8f93eb2012-09-25 03:06:24321// Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to
322// "chrome://foo/".
323bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) {
324 if (!url->is_valid() || !url->SchemeIs(chrome::kChromeUIScheme))
325 return false;
326
327 return RemoveUberHost(url);
328}
329
[email protected]8d3132f62011-10-12 07:13:42330// Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
331// below. Extension, and isolated apps require different privileges to be
332// granted to their RenderProcessHosts. This classification allows us to make
333// sure URLs are served by hosts with the right set of privileges.
334enum RenderProcessHostPrivilege {
335 PRIV_NORMAL,
[email protected]eec0b33c2011-12-05 22:09:45336 PRIV_HOSTED,
[email protected]8d3132f62011-10-12 07:13:42337 PRIV_ISOLATED,
[email protected]eec0b33c2011-12-05 22:09:45338 PRIV_EXTENSION,
[email protected]8d3132f62011-10-12 07:13:42339};
340
341RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
342 const GURL& url,
343 ExtensionService* service) {
344 // Default to a normal renderer cause it is lower privileged. This should only
345 // occur if the URL on a site instance is either malformed, or uninitialized.
346 // If it is malformed, then there is no need for better privileges anyways.
347 // If it is uninitialized, but eventually settles on being an a scheme other
348 // than normal webrenderer, the navigation logic will correct us out of band
349 // anyways.
350 if (!url.is_valid())
351 return PRIV_NORMAL;
352
[email protected]885c0e92012-11-13 20:27:42353 if (url.SchemeIs(extensions::kExtensionScheme)) {
[email protected]615d88f2011-12-13 01:47:44354 const Extension* extension =
355 service->extensions()->GetByID(url.host());
[email protected]561e33d52013-04-03 06:58:43356 if (extension &&
357 extensions::AppIsolationInfo::HasIsolatedStorage(extension))
[email protected]8d3132f62011-10-12 07:13:42358 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45359 if (extension && extension->is_hosted_app())
360 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42361
362 return PRIV_EXTENSION;
363 }
364
365 return PRIV_NORMAL;
366}
367
368RenderProcessHostPrivilege GetProcessPrivilege(
[email protected]f3b1a082011-11-18 00:34:30369 content::RenderProcessHost* process_host,
[email protected]6f371442011-11-09 06:45:46370 extensions::ProcessMap* process_map,
371 ExtensionService* service) {
[email protected]6f371442011-11-09 06:45:46372 std::set<std::string> extension_ids =
[email protected]f3b1a082011-11-18 00:34:30373 process_map->GetExtensionsInProcess(process_host->GetID());
[email protected]6f371442011-11-09 06:45:46374 if (extension_ids.empty())
[email protected]676f6ab2011-10-19 20:23:21375 return PRIV_NORMAL;
376
[email protected]6f371442011-11-09 06:45:46377 for (std::set<std::string>::iterator iter = extension_ids.begin();
378 iter != extension_ids.end(); ++iter) {
379 const Extension* extension = service->GetExtensionById(*iter, false);
[email protected]561e33d52013-04-03 06:58:43380 if (extension &&
381 extensions::AppIsolationInfo::HasIsolatedStorage(extension))
[email protected]8d3132f62011-10-12 07:13:42382 return PRIV_ISOLATED;
[email protected]eec0b33c2011-12-05 22:09:45383 if (extension && extension->is_hosted_app())
384 return PRIV_HOSTED;
[email protected]8d3132f62011-10-12 07:13:42385 }
386
[email protected]676f6ab2011-10-19 20:23:21387 return PRIV_EXTENSION;
[email protected]8d3132f62011-10-12 07:13:42388}
389
[email protected]6786bf402011-12-03 15:19:45390bool CertMatchesFilter(const net::X509Certificate& cert,
391 const base::DictionaryValue& filter) {
392 // TODO(markusheintz): This is the minimal required filter implementation.
393 // Implement a better matcher.
394
395 // An empty filter matches any client certificate since no requirements are
396 // specified at all.
397 if (filter.empty())
398 return true;
399
400 std::string common_name;
401 if (filter.GetString("ISSUER.CN", &common_name) &&
402 (cert.issuer().common_name == common_name)) {
403 return true;
404 }
405 return false;
406}
407
[email protected]f3986f82012-01-03 20:00:06408// Fills |map| with the per-script font prefs under path |map_name|.
409void FillFontFamilyMap(const PrefService* prefs,
410 const char* map_name,
[email protected]3184f90b2013-05-01 18:17:53411 webkit_glue::ScriptFontFamilyMap* map) {
[email protected]f3986f82012-01-03 20:00:06412 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
413 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
414 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
415 std::string font_family = prefs->GetString(pref_name.c_str());
[email protected]d0471062012-10-26 09:00:23416 if (!font_family.empty())
417 (*map)[script] = UTF8ToUTF16(font_family);
[email protected]f3986f82012-01-03 20:00:06418 }
419}
420
[email protected]a1733df2012-06-22 11:24:18421#if defined(OS_POSIX) && !defined(OS_MACOSX)
422int GetCrashSignalFD(const CommandLine& command_line) {
423 if (command_line.HasSwitch(switches::kExtensionProcess)) {
424 ExtensionCrashHandlerHostLinux* crash_handler =
425 ExtensionCrashHandlerHostLinux::GetInstance();
426 return crash_handler->GetDeathSignalSocket();
427 }
428
429 std::string process_type =
430 command_line.GetSwitchValueASCII(switches::kProcessType);
431
432 if (process_type == switches::kRendererProcess)
433 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
434
435 if (process_type == switches::kPluginProcess)
436 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
437
438 if (process_type == switches::kPpapiPluginProcess)
439 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
440
441 if (process_type == switches::kGpuProcess)
442 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
443
444 return -1;
445}
446#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
447
[email protected]d5bcd06f2013-04-21 08:07:24448#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:30449GURL GetEffectiveURLForSignin(const GURL& url) {
450 CHECK(SigninManager::IsWebBasedSigninFlowURL(url));
451
452 GURL effective_url(SigninManager::kChromeSigninEffectiveSite);
[email protected]fab8bbed42013-03-07 01:13:03453 // Copy the path because the argument to SetPathStr must outlive
454 // the Replacements object.
455 const std::string path_copy(url.path());
[email protected]970c63e2013-03-07 00:25:30456 GURL::Replacements replacements;
[email protected]fab8bbed42013-03-07 01:13:03457 replacements.SetPathStr(path_copy);
[email protected]970c63e2013-03-07 00:25:30458 effective_url = effective_url.ReplaceComponents(replacements);
459 return effective_url;
460}
[email protected]d5bcd06f2013-04-21 08:07:24461#endif
[email protected]970c63e2013-03-07 00:25:30462
[email protected]eabbfb12013-04-05 23:28:35463void SetApplicationLocaleOnIOThread(const std::string& locale) {
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
465 g_io_thread_application_locale.Get() = locale;
466}
467
[email protected]9dbfff12011-07-01 19:37:07468} // namespace
[email protected]c5dbef02011-05-13 05:06:09469
[email protected]d977f9c2011-03-14 16:10:26470namespace chrome {
471
[email protected]e461da2f2012-02-16 19:06:40472ChromeContentBrowserClient::ChromeContentBrowserClient() {
[email protected]93f72062013-05-29 20:29:40473#if defined(ENABLE_PLUGINS)
[email protected]e461da2f2012-02-16 19:06:40474 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
475 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
[email protected]93f72062013-05-29 20:29:40476#endif
[email protected]1deace22013-05-22 06:14:46477
478 permissions_policy_delegate_.reset(
479 new extensions::BrowserPermissionsPolicyDelegate());
[email protected]e461da2f2012-02-16 19:06:40480}
481
482ChromeContentBrowserClient::~ChromeContentBrowserClient() {
483}
484
[email protected]bca18382012-06-25 19:15:23485// static
[email protected]c753f142013-02-10 13:14:04486void ChromeContentBrowserClient::RegisterUserPrefs(
[email protected]443e9312013-05-06 06:17:34487 user_prefs::PrefRegistrySyncable* registry) {
488 registry->RegisterBooleanPref(
489 prefs::kDisable3DAPIs,
490 false,
491 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
492 registry->RegisterBooleanPref(
493 prefs::kEnableHyperlinkAuditing,
494 true,
495 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
496 registry->RegisterBooleanPref(
497 prefs::kEnableMemoryInfo,
498 false,
499 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
[email protected]bca18382012-06-25 19:15:23500}
501
[email protected]eabbfb12013-04-05 23:28:35502// static
503void ChromeContentBrowserClient::SetApplicationLocale(
504 const std::string& locale) {
505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
506
507 // This object is guaranteed to outlive all threads so we don't have to
508 // worry about the lack of refcounting and can just post as Unretained.
509 //
510 // The common case is that this function is called early in Chrome startup
511 // before any threads are created (it will also be called later if the user
512 // changes the pref). In this case, there will be no threads created and
513 // posting will fail. When there are no threads, we can just set the string
514 // without worrying about threadsafety.
515 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
516 base::Bind(&SetApplicationLocaleOnIOThread, locale))) {
517 g_io_thread_application_locale.Get() = locale;
518 }
519}
520
[email protected]50462bf02011-11-21 19:13:31521content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
522 const content::MainFunctionParams& parameters) {
523 ChromeBrowserMainParts* main_parts;
[email protected]b48c9182011-10-26 18:03:30524 // Construct the Main browser parts based on the OS type.
525#if defined(OS_WIN)
[email protected]50462bf02011-11-21 19:13:31526 main_parts = new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04527#elif defined(OS_MACOSX)
[email protected]50462bf02011-11-21 19:13:31528 main_parts = new ChromeBrowserMainPartsMac(parameters);
[email protected]b48c9182011-10-26 18:03:30529#elif defined(OS_CHROMEOS)
[email protected]2c624d02012-11-15 19:37:22530 main_parts = new chromeos::ChromeBrowserMainPartsChromeos(parameters);
[email protected]81ce2c42012-03-24 01:43:26531#elif defined(OS_LINUX)
[email protected]50462bf02011-11-21 19:13:31532 main_parts = new ChromeBrowserMainPartsLinux(parameters);
[email protected]6e677a342012-02-11 01:21:14533#elif defined(OS_ANDROID)
[email protected]81054f812012-08-30 00:47:09534 main_parts = new ChromeBrowserMainPartsAndroid(parameters);
[email protected]b48c9182011-10-26 18:03:30535#elif defined(OS_POSIX)
[email protected]50462bf02011-11-21 19:13:31536 main_parts = new ChromeBrowserMainPartsPosix(parameters);
[email protected]f967b722011-09-07 00:58:04537#else
[email protected]b48c9182011-10-26 18:03:30538 NOTREACHED();
[email protected]50462bf02011-11-21 19:13:31539 main_parts = new ChromeBrowserMainParts(parameters);
[email protected]b48c9182011-10-26 18:03:30540#endif
541
[email protected]7e75e4a2013-05-17 17:20:03542 chrome::AddProfilesExtraParts(main_parts);
543
[email protected]c7480942011-11-08 19:18:27544 // Construct additional browser parts. Stages are called in the order in
545 // which they are added.
[email protected]a13283cc2012-04-05 00:21:22546#if defined(TOOLKIT_GTK)
[email protected]684dace42012-07-01 14:30:41547 chrome::AddGtkToolkitExtraParts(main_parts);
[email protected]f967b722011-09-07 00:58:04548#endif
[email protected]c7480942011-11-08 19:18:27549
550#if defined(TOOLKIT_VIEWS)
[email protected]684dace42012-07-01 14:30:41551 chrome::AddViewsToolkitExtraParts(main_parts);
[email protected]c7480942011-11-08 19:18:27552#endif
553
[email protected]dc04be7c2012-03-15 23:57:49554#if defined(USE_ASH)
[email protected]684dace42012-07-01 14:30:41555 chrome::AddAshToolkitExtraParts(main_parts);
[email protected]dc04be7c2012-03-15 23:57:49556#endif
557
[email protected]e050ef142012-03-21 01:04:24558#if defined(USE_AURA)
[email protected]684dace42012-07-01 14:30:41559 chrome::AddAuraToolkitExtraParts(main_parts);
[email protected]e050ef142012-03-21 01:04:24560#endif
561
[email protected]95132f52013-04-12 02:19:04562 chrome::AddMetricsExtraParts(main_parts);
563
[email protected]50462bf02011-11-21 19:13:31564 return main_parts;
[email protected]f967b722011-09-07 00:58:04565}
566
[email protected]e94bbcb2012-09-07 05:33:57567std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite(
[email protected]d1198fd2012-08-13 22:50:19568 content::BrowserContext* browser_context,
[email protected]e94bbcb2012-09-07 05:33:57569 const GURL& site) {
[email protected]1bc28312012-11-08 08:31:53570 std::string partition_id;
571
572 // The partition ID for webview guest processes is the string value of its
573 // SiteInstance URL - "chrome-guest://app_id/persist?partition".
574 if (site.SchemeIs(chrome::kGuestScheme))
575 partition_id = site.spec();
576
[email protected]056efdc2013-04-06 00:14:53577 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
[email protected]1bc28312012-11-08 08:31:53578 return partition_id;
579}
580
581bool ChromeContentBrowserClient::IsValidStoragePartitionId(
582 content::BrowserContext* browser_context,
583 const std::string& partition_id) {
584 // The default ID is empty and is always valid.
585 if (partition_id.empty())
586 return true;
587
588 return GURL(partition_id).is_valid();
589}
590
591void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
592 content::BrowserContext* browser_context,
593 const GURL& site,
[email protected]14acc642012-11-17 12:20:10594 bool can_be_default,
[email protected]1bc28312012-11-08 08:31:53595 std::string* partition_domain,
596 std::string* partition_name,
597 bool* in_memory) {
[email protected]14acc642012-11-17 12:20:10598 // Default to the browser-wide storage partition and override based on |site|
599 // below.
600 partition_domain->clear();
601 partition_name->clear();
602 *in_memory = false;
603
[email protected]1bc28312012-11-08 08:31:53604 // For the webview tag, we create special guest processes, which host the
605 // tag content separately from the main application that embeds the tag.
606 // A webview tag can specify both the partition name and whether the storage
607 // for that partition should be persisted. Each tag gets a SiteInstance with
608 // a specially formatted URL, based on the application it is hosted by and
609 // the partition requested by it. The format for that URL is:
610 // chrome-guest://partition_domain/persist?partition_name
611 if (site.SchemeIs(chrome::kGuestScheme)) {
612 // Since guest URLs are only used for packaged apps, there must be an app
613 // id in the URL.
614 CHECK(site.has_host());
615 *partition_domain = site.host();
616 // Since persistence is optional, the path must either be empty or the
617 // literal string.
618 *in_memory = (site.path() != "/persist");
619 // The partition name is user supplied value, which we have encoded when the
620 // URL was created, so it needs to be decoded.
621 *partition_name = net::UnescapeURLComponent(site.query(),
622 net::UnescapeRule::NORMAL);
[email protected]14acc642012-11-17 12:20:10623 } else if (site.SchemeIs(extensions::kExtensionScheme)) {
624 // If |can_be_default| is false, the caller is stating that the |site|
625 // should be parsed as if it had isolated storage. In particular it is
626 // important to NOT check ExtensionService for the is_storage_isolated()
627 // attribute because this code path is run during Extension uninstall
628 // to do cleanup after the Extension has already been unloaded from the
629 // ExtensionService.
630 bool is_isolated = !can_be_default;
631 if (can_be_default) {
632 const Extension* extension = NULL;
633 Profile* profile = Profile::FromBrowserContext(browser_context);
634 ExtensionService* extension_service =
635 extensions::ExtensionSystem::Get(profile)->extension_service();
636 if (extension_service) {
637 extension = extension_service->extensions()->
638 GetExtensionOrAppByURL(ExtensionURLInfo(site));
[email protected]561e33d52013-04-03 06:58:43639 if (extension &&
640 extensions::AppIsolationInfo::HasIsolatedStorage(extension)) {
[email protected]14acc642012-11-17 12:20:10641 is_isolated = true;
642 }
643 }
644 }
[email protected]1bc28312012-11-08 08:31:53645
[email protected]14acc642012-11-17 12:20:10646 if (is_isolated) {
647 CHECK(site.has_host());
648 // For extensions with isolated storage, the the host of the |site| is
649 // the |partition_domain|. The |in_memory| and |partition_name| are only
650 // used in guest schemes so they are cleared here.
651 *partition_domain = site.host();
[email protected]1bc28312012-11-08 08:31:53652 *in_memory = false;
[email protected]14acc642012-11-17 12:20:10653 partition_name->clear();
[email protected]1bc28312012-11-08 08:31:53654 }
[email protected]d1198fd2012-08-13 22:50:19655 }
656
[email protected]14acc642012-11-17 12:20:10657 // Assert that if |can_be_default| is false, the code above must have found a
658 // non-default partition. If this fails, the caller has a serious logic
659 // error about which StoragePartition they expect to be in and it is not
660 // safe to continue.
661 CHECK(can_be_default || !partition_domain->empty());
[email protected]d7c7c98a2012-07-12 21:27:44662}
663
[email protected]38b098f2012-03-14 21:11:57664content::WebContentsViewDelegate*
665 ChromeContentBrowserClient::GetWebContentsViewDelegate(
666 content::WebContents* web_contents) {
[email protected]d33220292012-07-04 01:41:27667 return chrome::CreateWebContentsViewDelegate(web_contents);
[email protected]74313b42011-08-24 16:51:32668}
669
[email protected]24665682013-02-25 20:59:38670// Check if the extension activity log is enabled for the profile.
671static bool IsExtensionActivityLogEnabledForProfile(Profile* profile) {
672 extensions::ActivityLog* activity_log =
673 extensions::ActivityLog::GetInstance(profile);
674 return activity_log->IsLogEnabled();
675}
676
[email protected]44703cc72013-01-24 04:56:06677void ChromeContentBrowserClient::GuestWebContentsCreated(
678 WebContents* guest_web_contents, WebContents* embedder_web_contents) {
679 Profile* profile = Profile::FromBrowserContext(
680 embedder_web_contents->GetBrowserContext());
681 ExtensionService* service =
682 extensions::ExtensionSystem::Get(profile)->extension_service();
683 if (!service)
684 return;
685 const GURL& url = embedder_web_contents->GetSiteInstance()->GetSiteURL();
686 const Extension* extension = service->extensions()->
687 GetExtensionOrAppByURL(ExtensionURLInfo(url));
688 if (!extension)
689 return;
690 std::vector<ExtensionMsg_Loaded_Params> extensions;
691 extensions.push_back(ExtensionMsg_Loaded_Params(extension));
692 guest_web_contents->Send(new ExtensionMsg_Loaded(extensions));
[email protected]c4c2312c2013-05-13 05:04:11693 // TODO(fsamuel): This should be replaced with WebViewGuest or AdViewGuest
694 // once they are ready.
695 extensions::TabHelper::CreateForWebContents(guest_web_contents);
[email protected]db9f2142013-05-27 22:56:16696 new WebViewGuest(guest_web_contents, embedder_web_contents, extension->id());
[email protected]44703cc72013-01-24 04:56:06697}
698
[email protected]f3b1a082011-11-18 00:34:30699void ChromeContentBrowserClient::RenderProcessHostCreated(
700 content::RenderProcessHost* host) {
701 int id = host->GetID();
702 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
[email protected]43535512013-02-20 20:41:41703 net::URLRequestContextGetter* context =
704 profile->GetRequestContextForRenderProcess(id);
705
[email protected]f3b1a082011-11-18 00:34:30706 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]43535512013-02-20 20:41:41707 id, profile, context));
[email protected]ebd71962012-12-20 02:56:55708#if defined(ENABLE_PLUGINS)
[email protected]f3b1a082011-11-18 00:34:30709 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
[email protected]ebd71962012-12-20 02:56:55710#endif
[email protected]658677f2012-06-09 06:04:02711#if defined(ENABLE_PRINTING)
[email protected]0045b0f42012-07-26 11:52:08712 host->GetChannel()->AddFilter(new PrintingMessageFilter(id, profile));
[email protected]058e5732012-03-01 22:48:03713#endif
[email protected]f3b1a082011-11-18 00:34:30714 host->GetChannel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02715 new SearchProviderInstallStateMessageFilter(id, profile));
[email protected]f3b1a082011-11-18 00:34:30716 host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]7ceb99012011-12-21 08:05:56717#if defined(OS_MACOSX)
[email protected]628cad4d2013-04-13 00:36:21718 host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac(id));
[email protected]7ceb99012011-12-21 08:05:56719#endif
[email protected]43535512013-02-20 20:41:41720 host->GetChannel()->AddFilter(new ChromeNetBenchmarkingMessageFilter(
721 id, profile, context));
[email protected]2736c032012-05-11 18:06:07722 host->GetChannel()->AddFilter(
723 new prerender::PrerenderMessageFilter(id, profile));
[email protected]1352ca92013-04-30 02:30:27724 host->GetChannel()->AddFilter(new ValidationMessageMessageFilter(id));
[email protected]7a06d282013-05-03 04:39:33725 host->GetChannel()->AddFilter(new TtsMessageFilter(id, profile));
[email protected]3e69bc82011-05-26 23:22:38726
[email protected]2ccf45c2011-08-19 23:35:50727 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
728 profile->IsOffTheRecord()));
[email protected]39a5b532011-10-22 01:47:07729
[email protected]24665682013-02-25 20:59:38730 host->Send(new ChromeViewMsg_SetExtensionActivityLogEnabled(
731 IsExtensionActivityLogEnabledForProfile(profile)));
732
[email protected]39a5b532011-10-22 01:47:07733 SendExtensionWebRequestStatusToHost(host);
[email protected]edece212011-11-16 11:56:56734
735 RendererContentSettingRules rules;
736 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules);
737 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
[email protected]05fcf982011-04-19 00:44:14738}
739
[email protected]95c95552013-05-03 04:21:22740GURL ChromeContentBrowserClient::GetPossiblyPrivilegedURL(
741 content::BrowserContext* browser_context,
742 const GURL& url,
743 bool is_renderer_initiated,
744 content::SiteInstance* current_instance) {
745 Profile* profile = Profile::FromBrowserContext(browser_context);
746 if (!profile)
747 return url;
748
749 // Only return the privileged instant URL if we are entering from a browser-
750 // initiated navigation or if we are already in the instant process.
751 bool is_instant_process = false;
752 int process_id = current_instance->GetProcess()->GetID();
753 InstantService* instant_service =
754 InstantServiceFactory::GetForProfile(profile);
755 if (instant_service)
756 is_instant_process = instant_service->IsInstantProcess(process_id);
757
758 DCHECK_EQ(is_instant_process,
759 chrome::IsPrivilegedURLForInstant(current_instance->GetSiteURL()));
760 if (!is_renderer_initiated || is_instant_process) {
761 // If the input |url| should be assigned to the Instant renderer, make its
762 // privileged URL distinct from other URLs on the search provider's domain.
763 if (chrome::ShouldAssignURLToInstantRenderer(url, profile))
764 return chrome::GetPrivilegedURLForInstant(url, profile);
765 }
766
767 return url;
768}
769
[email protected]3d7474ff2011-07-27 17:47:37770GURL ChromeContentBrowserClient::GetEffectiveURL(
771 content::BrowserContext* browser_context, const GURL& url) {
772 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]c5dec6292013-01-25 04:54:52773 if (!profile)
774 return url;
775
[email protected]d5bcd06f2013-04-21 08:07:24776#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:30777 // If the input |url| should be assigned to the Signin renderer, make its
778 // effective URL distinct from other URLs on the signin service's domain.
779 // Note that the signin renderer will be allowed to sign the user in to
780 // Chrome.
781 if (SigninManager::IsWebBasedSigninFlowURL(url))
782 return GetEffectiveURLForSignin(url);
[email protected]d5bcd06f2013-04-21 08:07:24783#endif
[email protected]970c63e2013-03-07 00:25:30784
[email protected]c5dec6292013-01-25 04:54:52785 // If the input |url| is part of an installed app, the effective URL is an
786 // extension URL with the ID of that extension as the host. This has the
787 // effect of grouping apps together in a common SiteInstance.
788 ExtensionService* extension_service =
[email protected]06bdd2b2012-11-30 18:47:13789 extensions::ExtensionSystem::Get(profile)->extension_service();
790 if (!extension_service)
[email protected]36fb2c7c2011-04-04 15:49:08791 return url;
792
[email protected]06bdd2b2012-11-30 18:47:13793 const Extension* extension = extension_service->extensions()->
[email protected]615d88f2011-12-13 01:47:44794 GetHostedAppByURL(ExtensionURLInfo(url));
[email protected]36fb2c7c2011-04-04 15:49:08795 if (!extension)
796 return url;
797
[email protected]15877ca2011-11-18 22:40:52798 // Bookmark apps do not use the hosted app process model, and should be
799 // treated as normal URLs.
800 if (extension->from_bookmark())
801 return url;
802
[email protected]36fb2c7c2011-04-04 15:49:08803 // If the URL is part of an extension's web extent, convert it to an
804 // extension URL.
805 return extension->GetResourceURL(url.path());
806}
807
[email protected]056ad2a2011-07-12 02:13:55808bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37809 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]c5dec6292013-01-25 04:54:52810 // Non-extension, non-Instant URLs should generally use
811 // process-per-site-instance. Because we expect to use the effective URL,
812 // URLs for hosted apps (apart from bookmark apps) should have an extension
813 // scheme by now.
814
815 Profile* profile = Profile::FromBrowserContext(browser_context);
816 if (!profile)
817 return false;
818
[email protected]165fe422013-03-27 06:34:03819 if (chrome::ShouldAssignURLToInstantRenderer(effective_url, profile))
[email protected]c5dec6292013-01-25 04:54:52820 return true;
821
[email protected]d5bcd06f2013-04-21 08:07:24822#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:30823 if (SigninManager::IsWebBasedSigninFlowURL(effective_url))
824 return true;
[email protected]d5bcd06f2013-04-21 08:07:24825#endif
[email protected]970c63e2013-03-07 00:25:30826
[email protected]885c0e92012-11-13 20:27:42827 if (!effective_url.SchemeIs(extensions::kExtensionScheme))
[email protected]056ad2a2011-07-12 02:13:55828 return false;
829
[email protected]c5dec6292013-01-25 04:54:52830 ExtensionService* extension_service =
[email protected]06bdd2b2012-11-30 18:47:13831 extensions::ExtensionSystem::Get(profile)->extension_service();
832 if (!extension_service)
[email protected]056ad2a2011-07-12 02:13:55833 return false;
834
[email protected]06bdd2b2012-11-30 18:47:13835 const Extension* extension = extension_service->extensions()->
[email protected]615d88f2011-12-13 01:47:44836 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
[email protected]056ad2a2011-07-12 02:13:55837 if (!extension)
838 return false;
839
840 // If the URL is part of a hosted app that does not have the background
[email protected]7b54ca02012-03-02 18:06:53841 // permission, or that does not allow JavaScript access to the background
842 // page, we want to give each instance its own process to improve
[email protected]056ad2a2011-07-12 02:13:55843 // responsiveness.
[email protected]1d5e58b2013-01-31 08:41:40844 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) {
[email protected]c2e66e12012-06-27 06:27:06845 if (!extension->HasAPIPermission(APIPermission::kBackground) ||
[email protected]9367eabc2013-03-01 01:29:29846 !extensions::BackgroundInfo::AllowJSAccess(extension)) {
[email protected]7b54ca02012-03-02 18:06:53847 return false;
848 }
849 }
[email protected]056ad2a2011-07-12 02:13:55850
[email protected]7b54ca02012-03-02 18:06:53851 // Hosted apps that have script access to their background page must use
852 // process per site, since all instances can make synchronous calls to the
853 // background window. Other extensions should use process per site as well.
[email protected]056ad2a2011-07-12 02:13:55854 return true;
855}
856
[email protected]672c8c12013-03-07 12:30:06857// These are treated as WebUI schemes but do not get WebUI bindings.
[email protected]8f89dd412013-04-17 02:35:41858void ChromeContentBrowserClient::GetAdditionalWebUISchemes(
859 std::vector<std::string>* additional_schemes) {
860 additional_schemes->push_back(chrome::kChromeSearchScheme);
[email protected]672c8c12013-03-07 12:30:06861}
862
[email protected]6bd30072013-02-08 18:17:11863net::URLRequestContextGetter*
864ChromeContentBrowserClient::CreateRequestContext(
865 content::BrowserContext* browser_context,
[email protected]672c8c12013-03-07 12:30:06866 content::ProtocolHandlerMap* protocol_handlers) {
[email protected]6bd30072013-02-08 18:17:11867 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]672c8c12013-03-07 12:30:06868 return profile->CreateRequestContext(protocol_handlers);
[email protected]6bd30072013-02-08 18:17:11869}
870
871net::URLRequestContextGetter*
872ChromeContentBrowserClient::CreateRequestContextForStoragePartition(
873 content::BrowserContext* browser_context,
[email protected]152ea302013-02-11 04:08:40874 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:11875 bool in_memory,
[email protected]672c8c12013-03-07 12:30:06876 content::ProtocolHandlerMap* protocol_handlers) {
[email protected]6bd30072013-02-08 18:17:11877 Profile* profile = Profile::FromBrowserContext(browser_context);
878 return profile->CreateRequestContextForStoragePartition(
[email protected]672c8c12013-03-07 12:30:06879 partition_path, in_memory, protocol_handlers);
[email protected]6bd30072013-02-08 18:17:11880}
881
[email protected]46fb9442011-12-09 17:57:47882bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
883 return ProfileIOData::IsHandledURL(url);
884}
885
[email protected]c4365fa42013-05-14 01:08:24886bool ChromeContentBrowserClient::CanCommitURL(
887 content::RenderProcessHost* process_host,
888 const GURL& url) {
889 // We need to let most extension URLs commit in any process, since this can
890 // be allowed due to web_accessible_resources. Most hosted app URLs may also
891 // load in any process (e.g., in an iframe). However, the Chrome Web Store
892 // cannot be loaded in iframes and should never be requested outside its
893 // process.
894 Profile* profile =
895 Profile::FromBrowserContext(process_host->GetBrowserContext());
896 ExtensionService* service =
897 extensions::ExtensionSystem::Get(profile)->extension_service();
898 if (!service)
899 return true;
900 const Extension* new_extension =
901 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
902 if (new_extension &&
903 new_extension->is_hosted_app() &&
904 new_extension->id() == extension_misc::kWebStoreAppId &&
905 !service->process_map()->Contains(new_extension->id(),
906 process_host->GetID())) {
907 return false;
908 }
909
910 return true;
911}
912
[email protected]2a5221b2011-09-27 23:07:31913bool ChromeContentBrowserClient::IsSuitableHost(
[email protected]f3b1a082011-11-18 00:34:30914 content::RenderProcessHost* process_host,
[email protected]2a5221b2011-09-27 23:07:31915 const GURL& site_url) {
916 Profile* profile =
[email protected]f3b1a082011-11-18 00:34:30917 Profile::FromBrowserContext(process_host->GetBrowserContext());
[email protected]c5dec6292013-01-25 04:54:52918 // This may be NULL during tests. In that case, just assume any site can
919 // share any host.
920 if (!profile)
921 return true;
922
[email protected]d43f99fe2013-04-03 00:20:14923 // Instant URLs should only be in the instant process and instant process
924 // should only have Instant URLs.
[email protected]c5dec6292013-01-25 04:54:52925 InstantService* instant_service =
926 InstantServiceFactory::GetForProfile(profile);
[email protected]d43f99fe2013-04-03 00:20:14927 if (instant_service) {
928 bool is_instant_process = instant_service->IsInstantProcess(
929 process_host->GetID());
930 bool should_be_in_instant_process =
931 chrome::ShouldAssignURLToInstantRenderer(site_url, profile);
932 if (is_instant_process || should_be_in_instant_process)
933 return is_instant_process && should_be_in_instant_process;
934 }
[email protected]c5dec6292013-01-25 04:54:52935
[email protected]d5bcd06f2013-04-21 08:07:24936#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:30937 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
938 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID()))
939 return SigninManager::IsWebBasedSigninFlowURL(site_url);
[email protected]d5bcd06f2013-04-21 08:07:24940#endif
[email protected]970c63e2013-03-07 00:25:30941
[email protected]06bdd2b2012-11-30 18:47:13942 ExtensionService* service =
943 extensions::ExtensionSystem::Get(profile)->extension_service();
[email protected]6f371442011-11-09 06:45:46944 extensions::ProcessMap* process_map = service->process_map();
[email protected]2a5221b2011-09-27 23:07:31945
[email protected]ffa97602011-11-17 17:55:52946 // Don't allow the Task Manager to share a process with anything else.
947 // Otherwise it can affect the renderers it is observing.
948 // Note: we could create another RenderProcessHostPrivilege bucket for
949 // this to allow multiple chrome://tasks instances to share, but that's
950 // a very unlikely case without serious consequences.
951 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin())
952 return false;
953
[email protected]8d3132f62011-10-12 07:13:42954 // These may be NULL during tests. In that case, just assume any site can
955 // share any host.
[email protected]6f371442011-11-09 06:45:46956 if (!service || !process_map)
[email protected]2a5221b2011-09-27 23:07:31957 return true;
958
[email protected]eec0b33c2011-12-05 22:09:45959 // Otherwise, just make sure the process privilege matches the privilege
960 // required by the site.
[email protected]e94bbcb2012-09-07 05:33:57961 RenderProcessHostPrivilege privilege_required =
962 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]eec0b33c2011-12-05 22:09:45963 return GetProcessPrivilege(process_host, process_map, service) ==
964 privilege_required;
[email protected]2a5221b2011-09-27 23:07:31965}
966
[email protected]76411f412012-02-22 18:56:06967// This function is trying to limit the amount of processes used by extensions
968// with background pages. It uses a globally set percentage of processes to
969// run such extensions and if the limit is exceeded, it returns true, to
970// indicate to the content module to group extensions together.
971bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
972 content::BrowserContext* browser_context, const GURL& url) {
973 // It has to be a valid URL for us to check for an extension.
974 if (!url.is_valid())
975 return false;
976
977 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]2ee3da9d62012-12-05 20:17:19978 ExtensionService* service = !profile ? NULL :
[email protected]06bdd2b2012-11-30 18:47:13979 extensions::ExtensionSystem::Get(profile)->extension_service();
[email protected]76411f412012-02-22 18:56:06980 if (!service)
981 return false;
982
983 // We have to have a valid extension with background page to proceed.
984 const Extension* extension =
985 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
986 if (!extension)
987 return false;
[email protected]9367eabc2013-03-01 01:29:29988 if (!extensions::BackgroundInfo::HasBackgroundPage(extension))
[email protected]76411f412012-02-22 18:56:06989 return false;
990
991 std::set<int> process_ids;
992 size_t max_process_count =
993 content::RenderProcessHost::GetMaxRendererProcessCount();
994
995 // Go through all profiles to ensure we have total count of extension
996 // processes containing background pages, otherwise one profile can
997 // starve the other.
998 std::vector<Profile*> profiles = g_browser_process->profile_manager()->
999 GetLoadedProfiles();
1000 for (size_t i = 0; i < profiles.size(); ++i) {
[email protected]be93bba02012-10-24 16:44:031001 ExtensionProcessManager* epm =
1002 extensions::ExtensionSystem::Get(profiles[i])->process_manager();
[email protected]d1fe1352012-04-26 00:47:321003 for (ExtensionProcessManager::const_iterator iter =
1004 epm->background_hosts().begin();
1005 iter != epm->background_hosts().end(); ++iter) {
[email protected]3a1dc572012-07-31 22:25:131006 const extensions::ExtensionHost* host = *iter;
[email protected]d1fe1352012-04-26 00:47:321007 process_ids.insert(host->render_process_host()->GetID());
[email protected]76411f412012-02-22 18:56:061008 }
1009 }
1010
1011 if (process_ids.size() >
1012 (max_process_count * chrome::kMaxShareOfExtensionProcesses)) {
1013 return true;
1014 }
1015
1016 return false;
1017}
1018
[email protected]6f371442011-11-09 06:45:461019void ChromeContentBrowserClient::SiteInstanceGotProcess(
1020 SiteInstance* site_instance) {
1021 CHECK(site_instance->HasProcess());
1022
1023 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:021024 site_instance->GetBrowserContext());
[email protected]c5dec6292013-01-25 04:54:521025 if (!profile)
1026 return;
1027
1028 // Remember the ID of the Instant process to signal the renderer process
1029 // on startup in |AppendExtraCommandLineSwitches| below.
[email protected]165fe422013-03-27 06:34:031030 if (chrome::ShouldAssignURLToInstantRenderer(
[email protected]7c60f5042013-02-14 03:39:321031 site_instance->GetSiteURL(), profile)) {
[email protected]c5dec6292013-01-25 04:54:521032 InstantService* instant_service =
1033 InstantServiceFactory::GetForProfile(profile);
1034 if (instant_service)
1035 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID());
1036 }
1037
[email protected]d5bcd06f2013-04-21 08:07:241038#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:301039 // We only expect there to be one signin process as we use process-per-site
1040 // for signin URLs. The signin process will be cleared from SigninManager
1041 // when the renderer is destroyed.
1042 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
1043 SigninManager* signin_manager =
1044 SigninManagerFactory::GetForProfile(profile);
1045 if (signin_manager)
1046 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
[email protected]1deace22013-05-22 06:14:461047 BrowserThread::PostTask(
1048 BrowserThread::IO, FROM_HERE,
1049 base::Bind(&ExtensionInfoMap::SetSigninProcess,
1050 extensions::ExtensionSystem::Get(profile)->info_map(),
1051 site_instance->GetProcess()->GetID()));
[email protected]970c63e2013-03-07 00:25:301052 }
[email protected]d5bcd06f2013-04-21 08:07:241053#endif
[email protected]970c63e2013-03-07 00:25:301054
[email protected]06bdd2b2012-11-30 18:47:131055 ExtensionService* service =
1056 extensions::ExtensionSystem::Get(profile)->extension_service();
[email protected]6f371442011-11-09 06:45:461057 if (!service)
1058 return;
1059
1060 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:441061 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
[email protected]77ab17312012-09-28 15:34:591062 site_instance->GetSiteURL()));
[email protected]6f371442011-11-09 06:45:461063 if (!extension)
1064 return;
1065
[email protected]6bc04fd82011-12-04 02:29:351066 service->process_map()->Insert(extension->id(),
1067 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:331068 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:461069 BrowserThread::PostTask(
1070 BrowserThread::IO, FROM_HERE,
1071 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
[email protected]bd306722012-07-11 20:43:591072 extensions::ExtensionSystem::Get(profile)->info_map(),
[email protected]6f371442011-11-09 06:45:461073 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:351074 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:331075 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:461076}
1077
1078void ChromeContentBrowserClient::SiteInstanceDeleting(
1079 SiteInstance* site_instance) {
1080 if (!site_instance->HasProcess())
1081 return;
1082
1083 Profile* profile = Profile::FromBrowserContext(
[email protected]72daaa92012-01-18 13:39:021084 site_instance->GetBrowserContext());
[email protected]06bdd2b2012-11-30 18:47:131085 ExtensionService* service =
1086 extensions::ExtensionSystem::Get(profile)->extension_service();
[email protected]6f371442011-11-09 06:45:461087 if (!service)
1088 return;
1089
1090 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:441091 service->extensions()->GetExtensionOrAppByURL(
[email protected]77ab17312012-09-28 15:34:591092 ExtensionURLInfo(site_instance->GetSiteURL()));
[email protected]6f371442011-11-09 06:45:461093 if (!extension)
1094 return;
1095
[email protected]6bc04fd82011-12-04 02:29:351096 service->process_map()->Remove(extension->id(),
1097 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:331098 site_instance->GetId());
[email protected]6f371442011-11-09 06:45:461099 BrowserThread::PostTask(
1100 BrowserThread::IO, FROM_HERE,
1101 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
[email protected]bd306722012-07-11 20:43:591102 extensions::ExtensionSystem::Get(profile)->info_map(),
[email protected]6f371442011-11-09 06:45:461103 extension->id(),
[email protected]6bc04fd82011-12-04 02:29:351104 site_instance->GetProcess()->GetID(),
[email protected]b6583592012-01-25 19:52:331105 site_instance->GetId()));
[email protected]6f371442011-11-09 06:45:461106}
1107
[email protected]f05763972012-06-06 18:17:261108bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
[email protected]e9841fbd2013-02-22 23:12:141109 SiteInstance* site_instance,
[email protected]e3daf3c2011-10-05 21:17:081110 const GURL& current_url,
1111 const GURL& new_url) {
[email protected]f05763972012-06-06 18:17:261112 if (current_url.is_empty()) {
1113 // Always choose a new process when navigating to extension URLs. The
1114 // process grouping logic will combine all of a given extension's pages
1115 // into the same process.
[email protected]885c0e92012-11-13 20:27:421116 if (new_url.SchemeIs(extensions::kExtensionScheme))
[email protected]f05763972012-06-06 18:17:261117 return true;
[email protected]e3daf3c2011-10-05 21:17:081118
[email protected]f05763972012-06-06 18:17:261119 return false;
1120 }
1121
1122 // Also, we must switch if one is an extension and the other is not the exact
1123 // same extension.
[email protected]885c0e92012-11-13 20:27:421124 if (current_url.SchemeIs(extensions::kExtensionScheme) ||
1125 new_url.SchemeIs(extensions::kExtensionScheme)) {
[email protected]f05763972012-06-06 18:17:261126 if (current_url.GetOrigin() != new_url.GetOrigin())
1127 return true;
1128 }
1129
[email protected]e9841fbd2013-02-22 23:12:141130 // The checks below only matter if we can retrieve which extensions are
1131 // installed.
1132 Profile* profile =
1133 Profile::FromBrowserContext(site_instance->GetBrowserContext());
1134 ExtensionService* service =
1135 extensions::ExtensionSystem::Get(profile)->extension_service();
1136 if (!service)
1137 return false;
1138
1139 // We must swap if the URL is for an extension and we are not using an
1140 // extension process.
1141 const Extension* new_extension =
1142 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(new_url));
1143 // Ignore all hosted apps except the Chrome Web Store, since they do not
1144 // require their own BrowsingInstance (e.g., postMessage is ok).
1145 if (new_extension &&
1146 new_extension->is_hosted_app() &&
1147 new_extension->id() != extension_misc::kWebStoreAppId)
1148 new_extension = NULL;
1149 if (new_extension &&
1150 site_instance->HasProcess() &&
1151 !service->process_map()->Contains(new_extension->id(),
1152 site_instance->GetProcess()->GetID()))
1153 return true;
1154
[email protected]f05763972012-06-06 18:17:261155 return false;
[email protected]e3daf3c2011-10-05 21:17:081156}
1157
[email protected]395045c2012-05-22 15:04:381158bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1159 content::ResourceContext* resource_context, const GURL& current_url,
1160 const GURL& new_url) {
1161 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
1162 return extensions::CrossesExtensionProcessBoundary(
1163 io_data->GetExtensionInfoMap()->extensions(),
[email protected]ea7b7d82012-05-25 17:29:171164 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
[email protected]395045c2012-05-22 15:04:381165}
1166
[email protected]763ec4ca2011-04-29 15:48:121167std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
1168 const std::string& alias_name) {
1169 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
1170}
1171
[email protected]b80f68432011-05-02 17:22:301172void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
1173 CommandLine* command_line, int child_process_id) {
1174#if defined(USE_LINUX_BREAKPAD)
1175 if (IsCrashReporterEnabled()) {
1176 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
1177 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
1178 }
1179#elif defined(OS_MACOSX)
1180 if (IsCrashReporterEnabled()) {
1181 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
1182 child_process_logging::GetClientId());
1183 }
1184#endif // OS_MACOSX
1185
[email protected]f1933792011-06-14 00:49:341186 if (logging::DialogsAreSuppressed())
1187 command_line->AppendSwitch(switches::kNoErrorDialogs);
1188
[email protected]b80f68432011-05-02 17:22:301189 std::string process_type =
1190 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:171191 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]9206f2a02013-03-20 01:10:321192
1193 if (browser_command_line.HasSwitch(switches::kChromeFrame))
1194 command_line->AppendSwitch(switches::kChromeFrame);
1195
[email protected]718eab62011-10-05 21:16:521196 if (process_type == switches::kRendererProcess) {
[email protected]650b2d52013-02-10 03:41:451197 base::FilePath user_data_dir =
[email protected]b80f68432011-05-02 17:22:301198 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
1199 if (!user_data_dir.empty())
1200 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
1201#if defined(OS_CHROMEOS)
1202 const std::string& login_profile =
[email protected]931d1042013-04-05 17:50:441203 browser_command_line.GetSwitchValueASCII(
1204 chromeos::switches::kLoginProfile);
[email protected]b80f68432011-05-02 17:22:301205 if (!login_profile.empty())
[email protected]931d1042013-04-05 17:50:441206 command_line->AppendSwitchASCII(
1207 chromeos::switches::kLoginProfile, login_profile);
[email protected]b80f68432011-05-02 17:22:301208#endif
1209
[email protected]f3b1a082011-11-18 00:34:301210 content::RenderProcessHost* process =
1211 content::RenderProcessHost::FromID(child_process_id);
[email protected]a8d851f82011-12-21 00:32:371212 if (process) {
1213 Profile* profile = Profile::FromBrowserContext(
1214 process->GetBrowserContext());
[email protected]06bdd2b2012-11-30 18:47:131215 ExtensionService* extension_service =
1216 extensions::ExtensionSystem::Get(profile)->extension_service();
1217 if (extension_service) {
1218 extensions::ProcessMap* process_map = extension_service->process_map();
[email protected]c8598d42012-09-25 21:17:001219 if (process_map && process_map->Contains(process->GetID()))
1220 command_line->AppendSwitch(switches::kExtensionProcess);
1221 }
[email protected]b80f68432011-05-02 17:22:301222
[email protected]a8d851f82011-12-21 00:32:371223 PrefService* prefs = profile->GetPrefs();
1224 // Currently this pref is only registered if applied via a policy.
1225 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
1226 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
1227 // Turn this policy into a command line switch.
1228 command_line->AppendSwitch(switches::kDisable3DAPIs);
1229 }
[email protected]718eab62011-10-05 21:16:521230
[email protected]a8d851f82011-12-21 00:32:371231 // Disable client-side phishing detection in the renderer if it is
1232 // disabled in the Profile preferences or the browser process.
1233 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
1234 !g_browser_process->safe_browsing_detection_service()) {
1235 command_line->AppendSwitch(
1236 switches::kDisableClientSidePhishingDetection);
1237 }
[email protected]0045b0f42012-07-26 11:52:081238
1239 if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled))
[email protected]47c7ec82012-01-18 03:29:211240 command_line->AppendSwitch(switches::kRendererPrintPreview);
[email protected]c5dec6292013-01-25 04:54:521241
1242 InstantService* instant_service =
1243 InstantServiceFactory::GetForProfile(profile);
1244 if (instant_service &&
1245 instant_service->IsInstantProcess(process->GetID()))
1246 command_line->AppendSwitch(switches::kInstantProcess);
[email protected]970c63e2013-03-07 00:25:301247
[email protected]d5bcd06f2013-04-21 08:07:241248#if !defined(OS_CHROMEOS)
[email protected]970c63e2013-03-07 00:25:301249 SigninManager* signin_manager =
1250 SigninManagerFactory::GetForProfile(profile);
1251 if (signin_manager && signin_manager->IsSigninProcess(process->GetID()))
1252 command_line->AppendSwitch(switches::kSigninProcess);
[email protected]d5bcd06f2013-04-21 08:07:241253#endif
[email protected]47c7ec82012-01-18 03:29:211254 }
[email protected]4287a3d2011-06-13 23:56:511255
[email protected]87552982012-11-02 17:21:401256 if (content::IsThreadedCompositingEnabled())
1257 command_line->AppendSwitch(switches::kEnableThreadedCompositing);
1258
[email protected]16dc42452013-04-09 04:37:191259 if (message_center::IsRichNotificationEnabled())
1260 command_line->AppendSwitch(switches::kDisableHTMLNotifications);
[email protected]16dc42452013-04-09 04:37:191261
[email protected]47c7ec82012-01-18 03:29:211262 // Please keep this in alphabetical order.
[email protected]4287a3d2011-06-13 23:56:511263 static const char* const kSwitchNames[] = {
[email protected]000f3ad2013-05-16 02:19:171264 autofill::switches::kDisableInteractiveAutocomplete,
[email protected]e217c5632013-04-12 19:11:481265 autofill::switches::kEnableExperimentalFormFilling,
[email protected]000f3ad2013-05-16 02:19:171266 autofill::switches::kEnableInteractiveAutocomplete,
[email protected]4287a3d2011-06-13 23:56:511267 switches::kAllowHTTPBackgroundPage,
[email protected]70f48c02011-12-02 21:27:481268 switches::kAllowLegacyExtensionManifests,
[email protected]4287a3d2011-06-13 23:56:511269 switches::kAllowScriptingGallery,
1270 switches::kAppsCheckoutURL,
1271 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:311272 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:511273 switches::kDebugPrint,
[email protected]382fb0d2012-02-25 00:19:501274 switches::kDisableBundledPpapiFlash,
[email protected]e9dfe222012-05-11 22:05:531275 switches::kDisableExtensionsResourceWhitelist,
[email protected]b0553c7e2012-09-19 21:36:111276 switches::kDisableScriptedPrintThrottling,
[email protected]e9cddd52013-03-23 17:37:531277 switches::kEnableAdview,
1278 switches::kEnableAdviewSrcAttribute,
[email protected]47c7ec82012-01-18 03:29:211279 switches::kEnableBenchmarking,
[email protected]4287a3d2011-06-13 23:56:511280 switches::kEnableExperimentalExtensionApis,
[email protected]4287a3d2011-06-13 23:56:511281 switches::kEnableIPCFuzzing,
1282 switches::kEnableNaCl,
[email protected]ce304ce2013-02-22 21:54:451283 switches::kEnableNetBenchmarking,
[email protected]bcbe7652012-02-22 00:08:481284 switches::kEnablePasswordGeneration,
[email protected]284b03c2012-08-13 17:55:051285 switches::kEnablePnacl,
[email protected]4287a3d2011-06-13 23:56:511286 switches::kEnableWatchdog,
[email protected]ac2e2acd2013-03-21 12:57:291287 switches::kExtensionsOnChromeURLs,
[email protected]4287a3d2011-06-13 23:56:511288 switches::kMemoryProfiling,
1289 switches::kMessageLoopHistogrammer,
[email protected]f45c5f32012-04-18 19:26:371290 switches::kNoJsRandomness,
[email protected]f45c5f32012-04-18 19:26:371291 switches::kPlaybackMode,
[email protected]4287a3d2011-06-13 23:56:511292 switches::kPpapiFlashArgs,
1293 switches::kPpapiFlashInProcess,
1294 switches::kPpapiFlashPath,
1295 switches::kPpapiFlashVersion,
1296 switches::kProfilingAtStart,
1297 switches::kProfilingFile,
1298 switches::kProfilingFlush,
[email protected]f45c5f32012-04-18 19:26:371299 switches::kRecordMode,
[email protected]4287a3d2011-06-13 23:56:511300 switches::kSilentDumpOnDCHECK,
[email protected]199def22013-02-21 17:52:291301 switches::kSpdyProxyAuthOrigin,
[email protected]a446534d2012-02-09 00:07:381302 switches::kWhitelistedExtensionID,
[email protected]4287a3d2011-06-13 23:56:511303 };
1304
1305 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1306 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:171307 } else if (process_type == switches::kUtilityProcess) {
[email protected]a446534d2012-02-09 00:07:381308 static const char* const kSwitchNames[] = {
[email protected]eb653f82012-05-24 02:31:351309 switches::kAllowHTTPBackgroundPage,
[email protected]a446534d2012-02-09 00:07:381310 switches::kEnableExperimentalExtensionApis,
1311 switches::kWhitelistedExtensionID,
1312 };
1313
1314 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1315 arraysize(kSwitchNames));
[email protected]4287a3d2011-06-13 23:56:511316 } else if (process_type == switches::kPluginProcess) {
1317 static const char* const kSwitchNames[] = {
[email protected]931d1042013-04-05 17:50:441318#if defined(OS_CHROMEOS)
1319 chromeos::switches::kLoginProfile,
1320#endif
[email protected]4287a3d2011-06-13 23:56:511321 switches::kMemoryProfiling,
1322 switches::kSilentDumpOnDCHECK,
1323 switches::kUserDataDir,
1324 };
1325
1326 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1327 arraysize(kSwitchNames));
1328 } else if (process_type == switches::kZygoteProcess) {
1329 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:511330 switches::kUserDataDir, // Make logs go to the right file.
1331 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
[email protected]382fb0d2012-02-25 00:19:501332 switches::kDisableBundledPpapiFlash,
[email protected]4287a3d2011-06-13 23:56:511333 switches::kPpapiFlashInProcess,
1334 switches::kPpapiFlashPath,
1335 switches::kPpapiFlashVersion,
1336 };
1337
1338 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1339 arraysize(kSwitchNames));
[email protected]d56ecf922012-02-15 16:03:111340 } else if (process_type == switches::kGpuProcess) {
[email protected]f01b88a2013-02-27 22:04:001341 base::FilePath user_data_dir =
1342 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
1343 if (!user_data_dir.empty())
1344 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
[email protected]d56ecf922012-02-15 16:03:111345 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
1346 // because GPU is expected to be unreliable.
1347 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) &&
1348 !command_line->HasSwitch(switches::kDisableBreakpad))
1349 command_line->AppendSwitch(switches::kDisableBreakpad);
[email protected]b80f68432011-05-02 17:22:301350 }
[email protected]6f08af82011-09-15 01:19:031351
1352 // The command line switch kEnableBenchmarking needs to be specified along
1353 // with the kEnableStatsTable switch to ensure that the stats table global
1354 // is initialized correctly.
1355 if (command_line->HasSwitch(switches::kEnableBenchmarking))
1356 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:301357}
1358
1359std::string ChromeContentBrowserClient::GetApplicationLocale() {
[email protected]e9a32a52012-06-14 23:32:431360 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
[email protected]eabbfb12013-04-05 23:28:351361 return g_io_thread_application_locale.Get();
[email protected]b80f68432011-05-02 17:22:301362 return g_browser_process->GetApplicationLocale();
1363}
1364
[email protected]597a867b2011-11-18 18:31:201365std::string ChromeContentBrowserClient::GetAcceptLangs(
1366 content::BrowserContext* context) {
1367 Profile* profile = Profile::FromBrowserContext(context);
[email protected]3d7474ff2011-07-27 17:47:371368 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:081369}
1370
[email protected]9ec0f452012-05-31 15:58:531371gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() {
[email protected]7c3228a2011-11-11 21:35:221372 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
[email protected]9ec0f452012-05-31 15:58:531373 return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
[email protected]ac55e292011-06-24 05:16:081374}
1375
[email protected]a2176792011-05-08 19:30:491376bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:091377 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:191378 const GURL& first_party,
[email protected]df02aca2012-02-09 21:03:201379 content::ResourceContext* context) {
[email protected]8093a542011-05-13 07:29:321380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201381 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051382 return io_data->GetCookieSettings()->
1383 IsSettingCookieAllowed(manifest_url, first_party);
[email protected]a2176792011-05-08 19:30:491384}
1385
[email protected]ed24fad2011-05-10 22:44:011386bool ChromeContentBrowserClient::AllowGetCookie(
1387 const GURL& url,
1388 const GURL& first_party,
1389 const net::CookieList& cookie_list,
[email protected]df02aca2012-02-09 21:03:201390 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011391 int render_process_id,
1392 int render_view_id) {
1393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201394 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051395 bool allow = io_data->GetCookieSettings()->
1396 IsReadingCookieAllowed(url, first_party);
[email protected]ed24fad2011-05-10 22:44:011397
[email protected]8093a542011-05-13 07:29:321398 BrowserThread::PostTask(
1399 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031400 base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
[email protected]fd473d12012-04-05 11:38:431401 render_view_id, url, first_party, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:011402 return allow;
1403}
1404
1405bool ChromeContentBrowserClient::AllowSetCookie(
1406 const GURL& url,
1407 const GURL& first_party,
1408 const std::string& cookie_line,
[email protected]df02aca2012-02-09 21:03:201409 content::ResourceContext* context,
[email protected]ed24fad2011-05-10 22:44:011410 int render_process_id,
1411 int render_view_id,
1412 net::CookieOptions* options) {
1413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201414 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]30fde822011-10-28 09:49:051415 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1416 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
1417
[email protected]8093a542011-05-13 07:29:321418 BrowserThread::PostTask(
1419 BrowserThread::UI, FROM_HERE,
[email protected]317c58f02011-11-09 02:15:031420 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
[email protected]fd473d12012-04-05 11:38:431421 render_view_id, url, first_party, cookie_line, *options,
1422 !allow));
[email protected]ed24fad2011-05-10 22:44:011423 return allow;
1424}
1425
[email protected]d5a19162011-06-30 18:51:541426bool ChromeContentBrowserClient::AllowSaveLocalState(
[email protected]df02aca2012-02-09 21:03:201427 content::ResourceContext* context) {
[email protected]d5a19162011-06-30 18:51:541428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201429 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]bf510ed2012-06-05 08:31:431430 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1431 ContentSetting setting = cookie_settings->GetDefaultCookieSetting(NULL);
[email protected]1848cdc2012-02-17 10:48:261432
[email protected]bf510ed2012-06-05 08:31:431433 // TODO(bauerb): Should we also disallow local state if the default is BLOCK?
1434 // Could we even support per-origin settings?
1435 return setting != CONTENT_SETTING_SESSION_ONLY;
[email protected]d5a19162011-06-30 18:51:541436}
1437
[email protected]5c5a88e2011-11-12 00:45:351438bool ChromeContentBrowserClient::AllowWorkerDatabase(
[email protected]5c5a88e2011-11-12 00:45:351439 const GURL& url,
1440 const string16& name,
1441 const string16& display_name,
1442 unsigned long estimated_size,
[email protected]df02aca2012-02-09 21:03:201443 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481444 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201446 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351447 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1448 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1449
[email protected]62151052012-02-01 18:40:481450 // Record access to database for potential display in UI.
1451 std::vector<std::pair<int, int> >::const_iterator i;
1452 for (i = render_views.begin(); i != render_views.end(); ++i) {
1453 BrowserThread::PostTask(
1454 BrowserThread::UI, FROM_HERE,
1455 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
1456 i->first, i->second, url, name, display_name, !allow));
[email protected]5c5a88e2011-11-12 00:45:351457 }
1458
1459 return allow;
1460}
1461
1462bool ChromeContentBrowserClient::AllowWorkerFileSystem(
[email protected]5c5a88e2011-11-12 00:45:351463 const GURL& url,
[email protected]df02aca2012-02-09 21:03:201464 content::ResourceContext* context,
[email protected]62151052012-02-01 18:40:481465 const std::vector<std::pair<int, int> >& render_views) {
[email protected]5c5a88e2011-11-12 00:45:351466 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201467 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]5c5a88e2011-11-12 00:45:351468 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1469 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1470
[email protected]62151052012-02-01 18:40:481471 // Record access to file system for potential display in UI.
1472 std::vector<std::pair<int, int> >::const_iterator i;
1473 for (i = render_views.begin(); i != render_views.end(); ++i) {
1474 BrowserThread::PostTask(
1475 BrowserThread::UI, FROM_HERE,
1476 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
1477 i->first, i->second, url, !allow));
[email protected]5c5a88e2011-11-12 00:45:351478 }
1479
1480 return allow;
1481}
1482
[email protected]7c5ff9a2012-03-02 07:42:491483bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
1484 const GURL& url,
1485 const string16& name,
1486 content::ResourceContext* context,
1487 const std::vector<std::pair<int, int> >& render_views) {
1488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1489 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1490 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1491 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1492
1493 // Record access to IndexedDB for potential display in UI.
1494 std::vector<std::pair<int, int> >::const_iterator i;
1495 for (i = render_views.begin(); i != render_views.end(); ++i) {
1496 BrowserThread::PostTask(
1497 BrowserThread::UI, FROM_HERE,
1498 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
1499 i->first, i->second, url, name, !allow));
1500 }
1501
1502 return allow;
1503}
1504
[email protected]6133f922011-07-01 21:34:341505net::URLRequestContext*
1506ChromeContentBrowserClient::OverrideRequestContextForURL(
[email protected]df02aca2012-02-09 21:03:201507 const GURL& url, content::ResourceContext* context) {
[email protected]6133f922011-07-01 21:34:341508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]885c0e92012-11-13 20:27:421509 if (url.SchemeIs(extensions::kExtensionScheme)) {
[email protected]df02aca2012-02-09 21:03:201510 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]6133f922011-07-01 21:34:341511 return io_data->extensions_request_context();
1512 }
1513
1514 return NULL;
1515}
1516
[email protected]317f96c92011-05-31 06:53:411517QuotaPermissionContext*
1518ChromeContentBrowserClient::CreateQuotaPermissionContext() {
1519 return new ChromeQuotaPermissionContext();
1520}
1521
[email protected]848dd042011-06-04 18:24:031522void ChromeContentBrowserClient::AllowCertificateError(
[email protected]4cf611e32012-02-13 16:06:171523 int render_process_id,
1524 int render_view_id,
1525 int cert_error,
1526 const net::SSLInfo& ssl_info,
1527 const GURL& request_url,
[email protected]a2f76882013-02-25 21:36:021528 ResourceType::Type resource_type,
[email protected]848dd042011-06-04 18:24:031529 bool overridable,
[email protected]d9be47702012-05-16 03:41:221530 bool strict_enforcement,
[email protected]4cf611e32012-02-13 16:06:171531 const base::Callback<void(bool)>& callback,
[email protected]8c965c22013-05-23 19:28:001532 content::CertificateRequestResultType* result) {
[email protected]a2f76882013-02-25 21:36:021533 if (resource_type != ResourceType::MAIN_FRAME) {
1534 // A sub-resource has a certificate error. The user doesn't really
1535 // have a context for making the right decision, so block the
1536 // request hard, without an info bar to allow showing the insecure
1537 // content.
[email protected]8c965c22013-05-23 19:28:001538 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY;
[email protected]a2f76882013-02-25 21:36:021539 return;
1540 }
1541
[email protected]f9034cf2011-07-21 12:43:411542 // If the tab is being prerendered, cancel the prerender and the request.
[email protected]83ff91c2012-01-05 20:54:131543 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]4cf611e32012-02-13 16:06:171544 render_process_id, render_view_id);
[email protected]f9034cf2011-07-21 12:43:411545 if (!tab) {
1546 NOTREACHED();
1547 return;
1548 }
1549 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:501550 prerender::PrerenderManagerFactory::GetForProfile(
[email protected]627e0512011-12-21 22:55:301551 Profile::FromBrowserContext(tab->GetBrowserContext()));
[email protected]3a6ec762012-10-17 16:01:011552 if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab,
1553 NULL)) {
[email protected]f9034cf2011-07-21 12:43:411554 if (prerender_manager->prerender_tracker()->TryCancel(
[email protected]4cf611e32012-02-13 16:06:171555 render_process_id, render_view_id,
[email protected]f9034cf2011-07-21 12:43:411556 prerender::FINAL_STATUS_SSL_ERROR)) {
[email protected]8c965c22013-05-23 19:28:001557 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
[email protected]f9034cf2011-07-21 12:43:411558 return;
1559 }
1560 }
1561
[email protected]1e87df32012-09-12 04:53:191562#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
[email protected]eb0b9dd2012-09-19 21:36:231563 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
1564 captive_portal::CaptivePortalTabHelper::FromWebContents(tab);
1565 if (captive_portal_tab_helper)
1566 captive_portal_tab_helper->OnSSLCertError(ssl_info);
[email protected]1e87df32012-09-12 04:53:191567#endif
1568
[email protected]f9034cf2011-07-21 12:43:411569 // Otherwise, display an SSL blocking page.
[email protected]d9be47702012-05-16 03:41:221570 new SSLBlockingPage(tab, cert_error, ssl_info, request_url, overridable,
1571 strict_enforcement, callback);
[email protected]848dd042011-06-04 18:24:031572}
1573
[email protected]c99c442e2011-08-24 11:37:301574void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:451575 int render_process_id,
1576 int render_view_id,
[email protected]7a593db2012-02-13 21:19:401577 const net::HttpNetworkSession* network_session,
1578 net::SSLCertRequestInfo* cert_request_info,
1579 const base::Callback<void(net::X509Certificate*)>& callback) {
[email protected]83ff91c2012-01-05 20:54:131580 WebContents* tab = tab_util::GetWebContentsByID(
[email protected]8ec26472011-06-06 16:52:451581 render_process_id, render_view_id);
1582 if (!tab) {
1583 NOTREACHED();
1584 return;
1585 }
1586
[email protected]6786bf402011-12-03 15:19:451587 GURL requesting_url("https://" + cert_request_info->host_and_port);
1588 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
1589 << cert_request_info->host_and_port;
1590
[email protected]627e0512011-12-21 22:55:301591 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
[email protected]6786bf402011-12-03 15:19:451592 scoped_ptr<Value> filter(
1593 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1594 requesting_url,
1595 requesting_url,
1596 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1597 std::string(), NULL));
1598
1599 if (filter.get()) {
1600 // Try to automatically select a client certificate.
1601 if (filter->IsType(Value::TYPE_DICTIONARY)) {
1602 DictionaryValue* filter_dict =
1603 static_cast<DictionaryValue*>(filter.get());
1604
1605 const std::vector<scoped_refptr<net::X509Certificate> >&
1606 all_client_certs = cert_request_info->client_certs;
1607 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1608 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
1609 // Use the first certificate that is matched by the filter.
[email protected]7a593db2012-02-13 21:19:401610 callback.Run(all_client_certs[i]);
[email protected]6786bf402011-12-03 15:19:451611 return;
1612 }
1613 }
1614 } else {
1615 NOTREACHED();
1616 }
1617 }
1618
[email protected]11feec322012-09-18 03:58:521619 SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab);
1620 if (!ssl_tab_helper) {
1621 // If there is no SSLTabHelper for the given WebContents then we can't
[email protected]6786bf402011-12-03 15:19:451622 // show the user a dialog to select a client certificate. So we simply
[email protected]2a349e92011-12-07 12:00:141623 // proceed with no client certificate.
[email protected]7a593db2012-02-13 21:19:401624 callback.Run(NULL);
[email protected]6786bf402011-12-03 15:19:451625 return;
1626 }
[email protected]11feec322012-09-18 03:58:521627 ssl_tab_helper->ShowClientCertificateRequestDialog(
[email protected]7a593db2012-02-13 21:19:401628 network_session, cert_request_info, callback);
[email protected]8ec26472011-06-06 16:52:451629}
1630
[email protected]3b455502012-12-11 18:22:581631void ChromeContentBrowserClient::AddCertificate(
[email protected]8ec26472011-06-06 16:52:451632 net::URLRequest* request,
[email protected]3b455502012-12-11 18:22:581633 net::CertificateMimeType cert_type,
1634 const void* cert_data,
1635 size_t cert_size,
[email protected]8ec26472011-06-06 16:52:451636 int render_process_id,
1637 int render_view_id) {
[email protected]3b455502012-12-11 18:22:581638 chrome::SSLAddCertificate(request, cert_type, cert_data, cert_size,
1639 render_process_id, render_view_id);
[email protected]8ec26472011-06-06 16:52:451640}
1641
[email protected]dc73a7b2012-03-25 15:27:181642content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
[email protected]11158e2d2013-02-01 02:31:561643 return MediaCaptureDevicesDispatcher::GetInstance();
[email protected]dc73a7b2012-03-25 15:27:181644}
1645
[email protected]941623e2011-06-07 23:06:041646void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1647 const GURL& source_origin,
1648 int callback_context,
1649 int render_process_id,
1650 int render_view_id) {
[email protected]5fd2e842012-03-01 00:29:111651#if defined(ENABLE_NOTIFICATIONS)
[email protected]d0d9c3ee2012-06-19 03:07:021652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1653 WebContents* contents =
1654 tab_util::GetWebContentsByID(render_process_id, render_view_id);
1655 if (!contents) {
[email protected]941623e2011-06-07 23:06:041656 NOTREACHED();
1657 return;
1658 }
1659
[email protected]d0d9c3ee2012-06-19 03:07:021660 // Skip showing the infobar if the request comes from an extension, and that
1661 // extension has the 'notify' permission. (If the extension does not have the
1662 // permission, the user will still be prompted.)
1663 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
[email protected]c7cd5942013-04-30 03:31:011664 ExtensionInfoMap* extension_info_map =
1665 extensions::ExtensionSystem::Get(profile)->info_map();
1666 DesktopNotificationService* notification_service =
1667 DesktopNotificationServiceFactory::GetForProfile(profile);
1668 const Extension* extension = NULL;
1669 if (extension_info_map) {
1670 ExtensionSet extensions;
1671 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1672 source_origin, render_process_id,
1673 extensions::APIPermission::kNotification, &extensions);
1674 for (ExtensionSet::const_iterator iter = extensions.begin();
1675 iter != extensions.end(); ++iter) {
1676 if (notification_service->IsExtensionEnabled((*iter)->id())) {
1677 extension = *iter;
1678 break;
1679 }
1680 }
1681 }
[email protected]eb4832a2012-12-08 01:57:521682 RenderViewHost* rvh =
1683 RenderViewHost::FromID(render_process_id, render_view_id);
1684 if (IsExtensionWithPermissionOrSuggestInConsole(
1685 APIPermission::kNotification, extension, rvh)) {
[email protected]d0d9c3ee2012-06-19 03:07:021686 if (rvh)
1687 rvh->DesktopNotificationPermissionRequestDone(callback_context);
1688 return;
1689 }
1690
[email protected]c7cd5942013-04-30 03:31:011691 notification_service->RequestPermission(source_origin, render_process_id,
[email protected]d0d9c3ee2012-06-19 03:07:021692 render_view_id, callback_context, contents);
[email protected]5fd2e842012-03-01 00:29:111693#else
1694 NOTIMPLEMENTED();
1695#endif
[email protected]941623e2011-06-07 23:06:041696}
1697
1698WebKit::WebNotificationPresenter::Permission
1699 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
[email protected]34eec7ffe32011-11-02 23:49:021700 const GURL& source_origin,
[email protected]df02aca2012-02-09 21:03:201701 content::ResourceContext* context,
[email protected]34eec7ffe32011-11-02 23:49:021702 int render_process_id) {
[email protected]5fd2e842012-03-01 00:29:111703#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041704 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]df02aca2012-02-09 21:03:201705 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]941623e2011-06-07 23:06:041706
[email protected]c7cd5942013-04-30 03:31:011707 DesktopNotificationService* notification_service =
1708 io_data->GetNotificationService();
1709 if (notification_service) {
1710 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1711 ExtensionSet extensions;
1712 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1713 source_origin, render_process_id,
1714 extensions::APIPermission::kNotification, &extensions);
1715 for (ExtensionSet::const_iterator iter = extensions.begin();
1716 iter != extensions.end(); ++iter) {
1717 if (notification_service->IsExtensionEnabled((*iter)->id()))
1718 return WebKit::WebNotificationPresenter::PermissionAllowed;
1719 }
1720
1721 return notification_service->HasPermission(source_origin);
1722 }
1723
1724 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
[email protected]5fd2e842012-03-01 00:29:111725#else
1726 return WebKit::WebNotificationPresenter::PermissionAllowed;
1727#endif
[email protected]941623e2011-06-07 23:06:041728}
1729
1730void ChromeContentBrowserClient::ShowDesktopNotification(
[email protected]0ee57e22011-11-12 01:59:171731 const content::ShowDesktopNotificationHostMsgParams& params,
[email protected]941623e2011-06-07 23:06:041732 int render_process_id,
1733 int render_view_id,
1734 bool worker) {
[email protected]5fd2e842012-03-01 00:29:111735#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041736 RenderViewHost* rvh = RenderViewHost::FromID(
1737 render_process_id, render_view_id);
1738 if (!rvh) {
1739 NOTREACHED();
1740 return;
1741 }
1742
[email protected]9f76c1e2012-03-05 15:15:581743 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301744 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041745 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371746 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041747 service->ShowDesktopNotification(
1748 params, render_process_id, render_view_id,
1749 worker ? DesktopNotificationService::WorkerNotification :
1750 DesktopNotificationService::PageNotification);
[email protected]5fd2e842012-03-01 00:29:111751#else
1752 NOTIMPLEMENTED();
1753#endif
[email protected]941623e2011-06-07 23:06:041754}
1755
1756void ChromeContentBrowserClient::CancelDesktopNotification(
1757 int render_process_id,
1758 int render_view_id,
1759 int notification_id) {
[email protected]5fd2e842012-03-01 00:29:111760#if defined(ENABLE_NOTIFICATIONS)
[email protected]941623e2011-06-07 23:06:041761 RenderViewHost* rvh = RenderViewHost::FromID(
1762 render_process_id, render_view_id);
1763 if (!rvh) {
1764 NOTREACHED();
1765 return;
1766 }
1767
[email protected]9f76c1e2012-03-05 15:15:581768 content::RenderProcessHost* process = rvh->GetProcess();
[email protected]f3b1a082011-11-18 00:34:301769 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
[email protected]941623e2011-06-07 23:06:041770 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:371771 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:041772 service->CancelDesktopNotification(
1773 render_process_id, render_view_id, notification_id);
[email protected]5fd2e842012-03-01 00:29:111774#else
1775 NOTIMPLEMENTED();
1776#endif
[email protected]941623e2011-06-07 23:06:041777}
1778
[email protected]9f3fba52011-06-08 20:37:191779bool ChromeContentBrowserClient::CanCreateWindow(
[email protected]2b751a12012-03-06 03:00:351780 const GURL& opener_url,
[email protected]34eec7ffe32011-11-02 23:49:021781 const GURL& source_origin,
[email protected]9f3fba52011-06-08 20:37:191782 WindowContainerType container_type,
[email protected]df02aca2012-02-09 21:03:201783 content::ResourceContext* context,
[email protected]03b6d552012-03-29 04:03:011784 int render_process_id,
1785 bool* no_javascript_access) {
[email protected]9f3fba52011-06-08 20:37:191786 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]03b6d552012-03-29 04:03:011787
1788 *no_javascript_access = false;
1789
[email protected]9f3fba52011-06-08 20:37:191790 // If the opener is trying to create a background window but doesn't have
1791 // the appropriate permission, fail the attempt.
1792 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
[email protected]df02aca2012-02-09 21:03:201793 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]7b54ca02012-03-02 18:06:531794 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1795
[email protected]03b6d552012-03-29 04:03:011796 if (!map->SecurityOriginHasAPIPermission(
1797 source_origin,
1798 render_process_id,
[email protected]c2e66e12012-06-27 06:27:061799 APIPermission::kBackground)) {
[email protected]03b6d552012-03-29 04:03:011800 return false;
1801 }
1802
[email protected]7b54ca02012-03-02 18:06:531803 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1804 // return a recently installed Extension even if this CanCreateWindow call
1805 // was made by an old copy of the page in a normal web process. That's ok,
[email protected]03b6d552012-03-29 04:03:011806 // because the permission check above would have caused an early return
1807 // already. We must use the full URL to find hosted apps, though, and not
1808 // just the origin.
[email protected]7b54ca02012-03-02 18:06:531809 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
[email protected]2b751a12012-03-06 03:00:351810 ExtensionURLInfo(opener_url));
[email protected]9367eabc2013-03-01 01:29:291811 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension))
[email protected]03b6d552012-03-29 04:03:011812 *no_javascript_access = true;
[email protected]9f3fba52011-06-08 20:37:191813 }
[email protected]056efdc2013-04-06 00:14:531814
1815 // No new browser window (popup or tab) in app mode.
1816 if (container_type == WINDOW_CONTAINER_TYPE_NORMAL &&
1817 chrome::IsRunningInForcedAppMode()) {
1818 return false;
1819 }
1820
[email protected]9f3fba52011-06-08 20:37:191821 return true;
1822}
1823
1824std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
[email protected]df02aca2012-02-09 21:03:201825 const GURL& url, content::ResourceContext* context) {
[email protected]9f3fba52011-06-08 20:37:191826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1827 // Check if it's an extension-created worker, in which case we want to use
1828 // the name of the extension.
[email protected]df02aca2012-02-09 21:03:201829 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
[email protected]9f3fba52011-06-08 20:37:191830 const Extension* extension =
1831 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
1832 return extension ? extension->name() : std::string();
1833}
1834
[email protected]99907362012-01-11 05:41:401835void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1836 return g_browser_process->ResourceDispatcherHostCreated();
[email protected]3cb054e62011-06-13 05:21:171837}
1838
[email protected]7a06d282013-05-03 04:39:331839// TODO(tommi): Rename from Get to Create.
[email protected]c52b2892012-03-07 11:01:021840content::SpeechRecognitionManagerDelegate*
1841 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
[email protected]3bd0aab2013-05-30 20:07:491842#if !defined(OS_ANDROID)
[email protected]c52b2892012-03-07 11:01:021843 return new speech::ChromeSpeechRecognitionManagerDelegate();
[email protected]a03f2d32012-03-14 00:26:321844#else
[email protected]3bd0aab2013-05-30 20:07:491845 // TODO(janx): Implement speech::AndroidSpeechRecognitionManagerDelegate
1846 // (see crbug.com/222352).
[email protected]a03f2d32012-03-14 00:26:321847 return NULL;
1848#endif
[email protected]66cfec62012-02-24 17:57:511849}
1850
[email protected]ae6e9912011-07-27 01:18:281851net::NetLog* ChromeContentBrowserClient::GetNetLog() {
1852 return g_browser_process->net_log();
1853}
1854
[email protected]32538d92011-08-25 00:09:231855AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
1856 return new ChromeAccessTokenStore();
1857}
1858
[email protected]dbae6b02011-06-29 23:51:411859bool ChromeContentBrowserClient::IsFastShutdownPossible() {
[email protected]263ff4f2013-01-04 20:23:011860 return true;
[email protected]dbae6b02011-06-29 23:51:411861}
1862
[email protected]64d69de42012-02-06 00:19:541863void ChromeContentBrowserClient::OverrideWebkitPrefs(
[email protected]2e21fe292012-03-02 22:52:321864 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) {
[email protected]f3986f82012-01-03 20:00:061865 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:581866 rvh->GetProcess()->GetBrowserContext());
[email protected]f3986f82012-01-03 20:00:061867 PrefService* prefs = profile->GetPrefs();
[email protected]f3986f82012-01-03 20:00:061868
[email protected]f3986f82012-01-03 20:00:061869 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541870 &web_prefs->standard_font_family_map);
[email protected]f3986f82012-01-03 20:00:061871 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541872 &web_prefs->fixed_font_family_map);
[email protected]f3986f82012-01-03 20:00:061873 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541874 &web_prefs->serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061875 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541876 &web_prefs->sans_serif_font_family_map);
[email protected]f3986f82012-01-03 20:00:061877 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541878 &web_prefs->cursive_font_family_map);
[email protected]f3986f82012-01-03 20:00:061879 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
[email protected]64d69de42012-02-06 00:19:541880 &web_prefs->fantasy_font_family_map);
[email protected]85edc232012-10-05 08:56:031881 FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap,
1882 &web_prefs->pictograph_font_family_map);
[email protected]f3986f82012-01-03 20:00:061883
[email protected]64d69de42012-02-06 00:19:541884 web_prefs->default_font_size =
[email protected]ddf72142012-05-22 04:52:401885 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
[email protected]64d69de42012-02-06 00:19:541886 web_prefs->default_fixed_font_size =
[email protected]ddf72142012-05-22 04:52:401887 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
[email protected]64d69de42012-02-06 00:19:541888 web_prefs->minimum_font_size =
[email protected]ddf72142012-05-22 04:52:401889 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
[email protected]64d69de42012-02-06 00:19:541890 web_prefs->minimum_logical_font_size =
[email protected]ddf72142012-05-22 04:52:401891 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
[email protected]f3986f82012-01-03 20:00:061892
[email protected]ddf72142012-05-22 04:52:401893 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061894
[email protected]64d69de42012-02-06 00:19:541895 web_prefs->javascript_can_open_windows_automatically =
[email protected]ddf72142012-05-22 04:52:401896 prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically);
[email protected]64d69de42012-02-06 00:19:541897 web_prefs->dom_paste_enabled =
[email protected]f3986f82012-01-03 20:00:061898 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
[email protected]64d69de42012-02-06 00:19:541899 web_prefs->shrinks_standalone_images_to_fit =
[email protected]f3986f82012-01-03 20:00:061900 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
1901 const DictionaryValue* inspector_settings =
1902 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
1903 if (inspector_settings) {
[email protected]c40ef1c2013-02-25 18:42:181904 for (DictionaryValue::Iterator iter(*inspector_settings); !iter.IsAtEnd();
1905 iter.Advance()) {
[email protected]f3986f82012-01-03 20:00:061906 std::string value;
[email protected]c40ef1c2013-02-25 18:42:181907 if (iter.value().GetAsString(&value)) {
[email protected]64d69de42012-02-06 00:19:541908 web_prefs->inspector_settings.push_back(
[email protected]c40ef1c2013-02-25 18:42:181909 std::make_pair(iter.key(), value));
1910 }
[email protected]f3986f82012-01-03 20:00:061911 }
1912 }
[email protected]64d69de42012-02-06 00:19:541913 web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
[email protected]f3986f82012-01-03 20:00:061914
[email protected]ddf72142012-05-22 04:52:401915 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled))
[email protected]64d69de42012-02-06 00:19:541916 web_prefs->javascript_enabled = false;
1917 if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled))
1918 web_prefs->web_security_enabled = false;
[email protected]ddf72142012-05-22 04:52:401919 if (!prefs->GetBoolean(prefs::kWebKitPluginsEnabled))
[email protected]64d69de42012-02-06 00:19:541920 web_prefs->plugins_enabled = false;
1921 if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled))
1922 web_prefs->java_enabled = false;
1923 web_prefs->loads_images_automatically =
[email protected]ddf72142012-05-22 04:52:401924 prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically);
[email protected]f3986f82012-01-03 20:00:061925
[email protected]64d69de42012-02-06 00:19:541926 if (prefs->GetBoolean(prefs::kDisable3DAPIs))
1927 web_prefs->experimental_webgl_enabled = false;
[email protected]f3986f82012-01-03 20:00:061928
[email protected]64d69de42012-02-06 00:19:541929 web_prefs->memory_info_enabled =
1930 prefs->GetBoolean(prefs::kEnableMemoryInfo);
1931 web_prefs->allow_displaying_insecure_content =
1932 prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
1933 web_prefs->allow_running_insecure_content =
1934 prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
[email protected]d3b935f2012-10-19 23:14:321935#if defined(OS_ANDROID)
1936 web_prefs->font_scale_factor =
1937 static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor));
1938 web_prefs->force_enable_zoom =
1939 prefs->GetBoolean(prefs::kWebKitForceEnableZoom);
[email protected]0b60abd2013-03-13 16:34:451940#if defined(GOOGLE_TV)
1941 web_prefs->user_gesture_required_for_media_playback = false;
1942#endif
[email protected]d3b935f2012-10-19 23:14:321943#endif
[email protected]5c915252013-05-07 13:15:391944
[email protected]9d06d88d2012-02-23 22:37:081945 web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
[email protected]5c915252013-05-07 13:15:391946#if defined(OS_CHROMEOS)
1947 // Enable password echo during OOBE when keyboard driven flag is set.
1948 if (chromeos::UserManager::IsInitialized() &&
1949 !chromeos::UserManager::Get()->IsUserLoggedIn() &&
1950 !chromeos::StartupUtils::IsOobeCompleted()) {
1951 bool keyboard_driven_oobe = false;
1952 chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag(
[email protected]e8f3f9982013-05-10 20:59:531953 chromeos::kOemKeyboardDrivenOobeKey, &keyboard_driven_oobe);
[email protected]5c915252013-05-07 13:15:391954 if (keyboard_driven_oobe)
1955 web_prefs->password_echo_enabled = true;
1956 }
1957#endif
[email protected]f3986f82012-01-03 20:00:061958
[email protected]46f8e742013-05-03 18:37:141959#if defined(OS_ANDROID)
1960 web_prefs->user_style_sheet_enabled = false;
1961#else
[email protected]64d69de42012-02-06 00:19:541962 // The user stylesheet watcher may not exist in a testing profile.
[email protected]13169ab2012-04-06 07:48:151963 UserStyleSheetWatcher* user_style_sheet_watcher =
1964 UserStyleSheetWatcherFactory::GetForProfile(profile);
1965 if (user_style_sheet_watcher) {
[email protected]64d69de42012-02-06 00:19:541966 web_prefs->user_style_sheet_enabled = true;
1967 web_prefs->user_style_sheet_location =
[email protected]13169ab2012-04-06 07:48:151968 user_style_sheet_watcher->user_style_sheet();
[email protected]64d69de42012-02-06 00:19:541969 } else {
1970 web_prefs->user_style_sheet_enabled = false;
[email protected]f3986f82012-01-03 20:00:061971 }
[email protected]46f8e742013-05-03 18:37:141972#endif
[email protected]f3986f82012-01-03 20:00:061973
[email protected]cfadadd2013-04-03 04:43:021974 web_prefs->asynchronous_spell_checking_enabled = true;
1975 web_prefs->unified_textchecker_enabled = true;
[email protected]dd5d0fb2012-01-18 03:37:571976
[email protected]64d69de42012-02-06 00:19:541977 web_prefs->uses_universal_detector =
[email protected]f3986f82012-01-03 20:00:061978 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);
[email protected]64d69de42012-02-06 00:19:541979 web_prefs->text_areas_are_resizable =
[email protected]f3986f82012-01-03 20:00:061980 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
[email protected]64d69de42012-02-06 00:19:541981 web_prefs->hyperlink_auditing_enabled =
[email protected]f3986f82012-01-03 20:00:061982 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
1983
1984 // Make sure we will set the default_encoding with canonical encoding name.
[email protected]64d69de42012-02-06 00:19:541985 web_prefs->default_encoding =
[email protected]f3986f82012-01-03 20:00:061986 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
[email protected]64d69de42012-02-06 00:19:541987 web_prefs->default_encoding);
1988 if (web_prefs->default_encoding.empty()) {
[email protected]ddf72142012-05-22 04:52:401989 prefs->ClearPref(prefs::kDefaultCharset);
1990 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
[email protected]f3986f82012-01-03 20:00:061991 }
[email protected]64d69de42012-02-06 00:19:541992 DCHECK(!web_prefs->default_encoding.empty());
[email protected]f3986f82012-01-03 20:00:061993
[email protected]88ecf66d2012-12-11 22:53:471994 if (content::IsForceCompositingModeEnabled())
1995 web_prefs->force_compositing_mode = true;
1996
[email protected]299d7f12012-05-23 05:31:151997 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
[email protected]cb2edf22013-04-01 20:25:231998 extensions::ViewType view_type = extensions::GetViewType(web_contents);
[email protected]06bdd2b2012-11-30 18:47:131999 ExtensionService* service =
2000 extensions::ExtensionSystem::Get(profile)->extension_service();
[email protected]f3986f82012-01-03 20:00:062001 if (service) {
[email protected]1bc28312012-11-08 08:31:532002 const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
2003 const Extension* extension = service->extensions()->GetByID(url.host());
2004 // Ensure that we are only granting extension preferences to URLs with
2005 // the correct scheme. Without this check, chrome-guest:// schemes used by
2006 // webview tags as well as hosts that happen to match the id of an
2007 // installed extension would get the wrong preferences.
[email protected]885c0e92012-11-13 20:27:422008 if (url.SchemeIs(extensions::kExtensionScheme)) {
[email protected]1bc28312012-11-08 08:31:532009 extension_webkit_preferences::SetPreferences(
2010 extension, view_type, web_prefs);
2011 }
[email protected]f3986f82012-01-03 20:00:062012 }
2013
[email protected]cb2edf22013-04-01 20:25:232014 if (view_type == extensions::VIEW_TYPE_NOTIFICATION) {
[email protected]64d69de42012-02-06 00:19:542015 web_prefs->allow_scripts_to_close_windows = true;
[email protected]cb2edf22013-04-01 20:25:232016 } else if (view_type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) {
[email protected]f3986f82012-01-03 20:00:062017 // Disable all kinds of acceleration for background pages.
2018 // See http://crbug.com/96005 and http://crbug.com/96006
[email protected]64d69de42012-02-06 00:19:542019 web_prefs->force_compositing_mode = false;
2020 web_prefs->accelerated_compositing_enabled = false;
[email protected]f3986f82012-01-03 20:00:062021 }
[email protected]2e21fe292012-03-02 22:52:322022
2023#if defined(FILE_MANAGER_EXTENSION)
2024 // Override the default of suppressing HW compositing for WebUI pages for the
2025 // file manager, which is implemented using WebUI but wants HW acceleration
2026 // for video decode & render.
2027 if (url.spec() == chrome::kChromeUIFileManagerURL) {
2028 web_prefs->accelerated_compositing_enabled = true;
2029 web_prefs->accelerated_2d_canvas_enabled = true;
2030 }
2031#endif
[email protected]181a95ee2011-07-12 19:26:362032}
2033
2034void ChromeContentBrowserClient::UpdateInspectorSetting(
2035 RenderViewHost* rvh, const std::string& key, const std::string& value) {
[email protected]f3986f82012-01-03 20:00:062036 content::BrowserContext* browser_context =
[email protected]9f76c1e2012-03-05 15:15:582037 rvh->GetProcess()->GetBrowserContext();
[email protected]f3986f82012-01-03 20:00:062038 DictionaryPrefUpdate update(
2039 Profile::FromBrowserContext(browser_context)->GetPrefs(),
2040 prefs::kWebKitInspectorSettings);
2041 DictionaryValue* inspector_settings = update.Get();
2042 inspector_settings->SetWithoutPathExpansion(key,
2043 Value::CreateStringValue(value));
[email protected]181a95ee2011-07-12 19:26:362044}
2045
[email protected]b8148ac2011-07-13 22:03:252046void ChromeContentBrowserClient::BrowserURLHandlerCreated(
2047 BrowserURLHandler* handler) {
2048 // Add the default URL handlers.
2049 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
2050 BrowserURLHandler::null_handler());
2051 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
2052 &ExtensionWebUI::HandleChromeURLOverrideReverse);
2053
[email protected]b3adbd02011-11-30 22:23:272054 // about: handler. Must come before chrome: handler, since it will
2055 // rewrite about: urls to chrome: URLs and then expect chrome: to
2056 // actually handle them.
[email protected]b8148ac2011-07-13 22:03:252057 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
2058 BrowserURLHandler::null_handler());
2059 // chrome: & friends.
[email protected]f8f93eb2012-09-25 03:06:242060 handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
[email protected]b8148ac2011-07-13 22:03:252061}
2062
2063void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:372064 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:582065 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:472066 BrowsingDataRemover* remover =
2067 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]3d4d4cf2012-06-04 10:40:552068 remover->Remove(BrowsingDataRemover::REMOVE_CACHE,
2069 BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:252070 // BrowsingDataRemover takes care of deleting itself when done.
2071}
2072
2073void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:372074 Profile* profile = Profile::FromBrowserContext(
[email protected]9f76c1e2012-03-05 15:15:582075 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
[email protected]38b892b42012-09-04 13:25:472076 BrowsingDataRemover* remover =
2077 BrowsingDataRemover::CreateForUnboundedRange(profile);
[email protected]dceaa912011-09-06 17:17:232078 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]3d4d4cf2012-06-04 10:40:552079 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB);
[email protected]b8148ac2011-07-13 22:03:252080 // BrowsingDataRemover takes care of deleting itself when done.
2081}
2082
[email protected]650b2d52013-02-10 03:41:452083base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
[email protected]e1d16eb92011-08-18 23:19:322084 return download_util::GetDefaultDownloadDirectory();
2085}
2086
[email protected]c9b6eb62011-10-18 20:49:392087std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
2088 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
2089}
2090
[email protected]b7631cc2012-09-15 05:08:382091void ChromeContentBrowserClient::DidCreatePpapiPlugin(
2092 content::BrowserPpapiHost* browser_host) {
[email protected]6d17f6392012-12-05 05:24:542093#if defined(ENABLE_PLUGINS)
[email protected]b7631cc2012-09-15 05:08:382094 browser_host->GetPpapiHost()->AddHostFactoryFilter(
2095 scoped_ptr<ppapi::host::HostFactory>(
2096 new ChromeBrowserPepperHostFactory(browser_host)));
[email protected]6d17f6392012-12-05 05:24:542097#endif
[email protected]b7631cc2012-09-15 05:08:382098}
2099
[email protected]0c7193742012-11-07 19:05:032100content::BrowserPpapiHost*
2101 ChromeContentBrowserClient::GetExternalBrowserPpapiHost(
2102 int plugin_process_id) {
[email protected]f3b357692013-03-22 05:16:132103 BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_LOADER);
[email protected]0c7193742012-11-07 19:05:032104 while (!iter.Done()) {
2105 NaClProcessHost* host = static_cast<NaClProcessHost*>(iter.GetDelegate());
2106 if (host->process() &&
2107 host->process()->GetData().id == plugin_process_id) {
2108 // Found the plugin.
2109 return host->browser_ppapi_host();
2110 }
2111 ++iter;
2112 }
2113 return NULL;
2114}
2115
[email protected]7b38b192013-03-23 18:39:312116bool ChromeContentBrowserClient::SupportsBrowserPlugin(
2117 content::BrowserContext* browser_context, const GURL& site_url) {
2118 if (CommandLine::ForCurrentProcess()->HasSwitch(
2119 switches::kEnableBrowserPluginForAllViewTypes))
2120 return true;
2121
2122 Profile* profile = Profile::FromBrowserContext(browser_context);
2123 ExtensionService* service =
2124 extensions::ExtensionSystem::Get(profile)->extension_service();
2125 if (!service)
2126 return false;
2127
2128 const Extension* extension = service->extensions()->
2129 GetExtensionOrAppByURL(ExtensionURLInfo(site_url));
2130 if (!extension)
2131 return false;
2132
[email protected]c2d2f102013-04-29 16:42:582133 return extension->HasAPIPermission(APIPermission::kWebView) ||
2134 extension->HasAPIPermission(APIPermission::kAdView);
[email protected]7b38b192013-03-23 18:39:312135}
2136
[email protected]38cd8f7f2012-06-15 22:06:072137bool ChromeContentBrowserClient::AllowPepperSocketAPI(
[email protected]157cc902012-11-02 06:31:582138 content::BrowserContext* browser_context,
2139 const GURL& url,
2140 const content::SocketPermissionRequest& params) {
[email protected]93f72062013-05-29 20:29:402141#if defined(ENABLE_PLUGINS)
2142 return IsExtensionOrSharedModuleWhitelisted(
2143 Profile::FromBrowserContext(browser_context),
2144 url,
2145 allowed_socket_origins_,
2146 switches::kAllowNaClSocketAPI);
2147#else
[email protected]a658d452012-03-02 12:45:292148 return false;
[email protected]93f72062013-05-29 20:29:402149#endif
[email protected]e461da2f2012-02-16 19:06:402150}
2151
[email protected]650b2d52013-02-10 03:41:452152base::FilePath ChromeContentBrowserClient::GetHyphenDictionaryDirectory() {
2153 base::FilePath directory;
[email protected]a7944aa2012-10-15 10:12:142154 PathService::Get(chrome::DIR_APP_DICTIONARIES, &directory);
2155 return directory.Append(FILE_PATH_LITERAL("Hyphen"));
2156}
2157
[email protected]a28e3302013-02-03 03:50:432158ui::SelectFilePolicy* ChromeContentBrowserClient::CreateSelectFilePolicy(
2159 WebContents* web_contents) {
2160 return new ChromeSelectFilePolicy(web_contents);
2161}
2162
[email protected]7d9424702013-04-14 13:14:162163void ChromeContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
2164 std::vector<std::string>* additional_allowed_schemes) {
2165 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
2166 additional_allowed_schemes);
2167 additional_allowed_schemes->push_back(kChromeUIScheme);
2168 additional_allowed_schemes->push_back(extensions::kExtensionScheme);
2169}
2170
[email protected]02250952013-04-24 23:52:532171void ChromeContentBrowserClient::GetAdditionalFileSystemMountPointProviders(
2172 const base::FilePath& storage_partition_path,
2173 ScopedVector<fileapi::FileSystemMountPointProvider>* additional_providers) {
2174#if !defined(OS_ANDROID)
2175 additional_providers->push_back(new MediaFileSystemMountPointProvider(
2176 storage_partition_path));
2177#endif
2178}
2179
[email protected]e60c0232011-11-11 19:56:352180#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]a1733df2012-06-22 11:24:182181void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
2182 const CommandLine& command_line,
[email protected]40da3e0c2012-10-24 22:03:382183 int child_process_id,
[email protected]c7abd422012-09-25 00:20:082184 std::vector<FileDescriptorInfo>* mappings) {
[email protected]29699c22012-10-03 23:57:392185#if defined(OS_ANDROID)
[email protected]650b2d52013-02-10 03:41:452186 base::FilePath data_path;
[email protected]29699c22012-10-03 23:57:392187 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
2188 DCHECK(!data_path.empty());
2189
2190 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
[email protected]650b2d52013-02-10 03:41:452191 base::FilePath chrome_pak = data_path.AppendASCII("chrome.pak");
[email protected]29699c22012-10-03 23:57:392192 base::PlatformFile f =
2193 base::CreatePlatformFile(chrome_pak, flags, NULL, NULL);
2194 DCHECK(f != base::kInvalidPlatformFileValue);
2195 mappings->push_back(FileDescriptorInfo(kAndroidChromePakDescriptor,
2196 FileDescriptor(f, true)));
2197
[email protected]650b2d52013-02-10 03:41:452198 base::FilePath chrome_resources_pak =
[email protected]29699c22012-10-03 23:57:392199 data_path.AppendASCII("chrome_100_percent.pak");
2200 f = base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL);
2201 DCHECK(f != base::kInvalidPlatformFileValue);
[email protected]73592382013-01-18 19:22:372202 mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor,
[email protected]29699c22012-10-03 23:57:392203 FileDescriptor(f, true)));
2204
2205 const std::string locale = GetApplicationLocale();
[email protected]650b2d52013-02-10 03:41:452206 base::FilePath locale_pak = ResourceBundle::GetSharedInstance().
[email protected]29699c22012-10-03 23:57:392207 GetLocaleFilePath(locale, false);
2208 f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL);
2209 DCHECK(f != base::kInvalidPlatformFileValue);
2210 mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor,
2211 FileDescriptor(f, true)));
[email protected]40da3e0c2012-10-24 22:03:382212
[email protected]650b2d52013-02-10 03:41:452213 base::FilePath resources_pack_path;
[email protected]73592382013-01-18 19:22:372214 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
2215 f = base::CreatePlatformFile(resources_pack_path, flags, NULL, NULL);
2216 DCHECK(f != base::kInvalidPlatformFileValue);
2217 mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor,
2218 FileDescriptor(f, true)));
2219
[email protected]40da3e0c2012-10-24 22:03:382220#if defined(USE_LINUX_BREAKPAD)
[email protected]82174aa2013-01-22 21:53:432221 if (IsCrashReporterEnabled()) {
2222 f = CrashDumpManager::GetInstance()->CreateMinidumpFile(child_process_id);
2223 if (f == base::kInvalidPlatformFileValue) {
2224 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
2225 "be disabled for this process.";
2226 } else {
2227 mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor,
2228 FileDescriptor(f, true)));
2229 }
[email protected]40da3e0c2012-10-24 22:03:382230 }
2231#endif // defined(USE_LINUX_BREAKPAD)
2232
2233#else
2234 int crash_signal_fd = GetCrashSignalFD(command_line);
2235 if (crash_signal_fd >= 0) {
2236 mappings->push_back(FileDescriptorInfo(kCrashDumpSignal,
2237 FileDescriptor(crash_signal_fd,
2238 false)));
2239 }
[email protected]29699c22012-10-03 23:57:392240#endif // defined(OS_ANDROID)
[email protected]b80f68432011-05-02 17:22:302241}
[email protected]e60c0232011-11-11 19:56:352242#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]b80f68432011-05-02 17:22:302243
[email protected]4a65826d2011-08-25 16:04:012244#if defined(OS_WIN)
2245const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
2246 return chrome::kBrowserResourcesDll;
2247}
[email protected]34f48682013-03-20 00:30:182248
2249void ChromeContentBrowserClient::PreSpawnRenderer(
2250 sandbox::TargetPolicy* policy,
2251 bool* success) {
2252 // This code is duplicated in nacl_exe_win_64.cc.
2253 // Allow the server side of a pipe restricted to the "chrome.nacl."
2254 // namespace so that it cannot impersonate other system or other chrome
2255 // service pipes.
2256 sandbox::ResultCode result = policy->AddRule(
2257 sandbox::TargetPolicy::SUBSYS_NAMED_PIPES,
2258 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY,
2259 L"\\\\.\\pipe\\chrome.nacl.*");
2260 if (result != sandbox::SBOX_ALL_OK) {
2261 *success = false;
2262 return;
2263 }
2264
2265 // Renderers need to send named pipe handles and shared memory
2266 // segment handles to NaCl loader processes.
2267 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
2268 sandbox::TargetPolicy::HANDLES_DUP_ANY,
2269 L"File");
2270 if (result != sandbox::SBOX_ALL_OK) {
2271 *success = false;
2272 return;
2273 }
2274}
[email protected]4a65826d2011-08-25 16:04:012275#endif
2276
[email protected]37a72af2011-06-13 05:42:012277#if defined(USE_NSS)
2278crypto::CryptoModuleBlockingPasswordDelegate*
2279 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
2280 const GURL& url) {
[email protected]6246ac52012-09-24 01:55:292281 return chrome::NewCryptoModuleBlockingDialogDelegate(
2282 chrome::kCryptoModulePasswordKeygen, url.host());
[email protected]37a72af2011-06-13 05:42:012283}
2284#endif
2285
[email protected]d977f9c2011-03-14 16:10:262286} // namespace chrome