15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_content_browser_client.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <set>
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utility>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/bind.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/command_line.h"
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/lazy_instance.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/path_service.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h"
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/prefs/scoped_user_pref_update.h"
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string_number_conversions.h"
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/threading/sequenced_worker_pool.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_about_handler.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_process.h"
227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/browser_shutdown.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browsing_data/browsing_data_helper.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browsing_data/browsing_data_remover.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/character_encoding.h"
266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "chrome/browser/chrome_content_browser_client_parts.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chrome_net_benchmarking_message_filter.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_quota_permission_context.h"
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/content_settings/content_settings_utils.h"
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/content_settings/cookie_settings.h"
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/content_settings/host_content_settings_map.h"
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/content_settings/tab_specific_content_settings.h"
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/defaults.h"
343551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/download/download_prefs.h"
355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/browser/font_family_cache.h"
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/geolocation/chrome_access_token_store.h"
37f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/geolocation/geolocation_permission_context.h"
38f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/media/cast_transport_host_filter.h"
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/media/media_capture_devices_dispatcher.h"
41f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/media/midi_permission_context.h"
42f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/media/midi_permission_context_factory.h"
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/net/chrome_net_log.h"
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/desktop_notification_service.h"
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/desktop_notification_service_factory.h"
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/platform_util.h"
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/plugins/plugin_info_message_filter.h"
50558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch#include "chrome/browser/prerender/prerender_final_status.h"
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/prerender/prerender_manager.h"
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/prerender/prerender_manager_factory.h"
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/prerender/prerender_message_filter.h"
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/prerender/prerender_tracker.h"
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/printing/printing_message_filter.h"
5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_io_data.h"
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/search/instant_service.h"
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/search/instant_service_factory.h"
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/search/search.h"
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/signin/principals_message_filter.h"
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/speech/tts_controller.h"
68c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/speech/tts_message_filter.h"
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ssl/ssl_add_certificate.h"
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ssl/ssl_blocking_page.h"
7146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "chrome/browser/ssl/ssl_client_certificate_selector.h"
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/tab_contents/tab_util.h"
7358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/ui/blocked_content/blocked_window_params.h"
74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/chrome_select_file_policy.h"
76eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/ui/sync/sync_promo_ui.h"
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_constants.h"
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_paths.h"
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h"
828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/common/env_vars.h"
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/logging_chrome.h"
847d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "chrome/common/pepper_permission_util.h"
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h"
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/render_messages.h"
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h"
8803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "chrome/grit/generated_resources.h"
894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/installer/util/google_update_settings.h"
90a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "chromeos/chromeos_constants.h"
91010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "components/cdm/browser/cdm_message_filter_android.h"
920529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "components/cloud_devices/common/cloud_devices_switches.h"
931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/content_settings/core/browser/content_settings_provider.h"
941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/content_settings/core/common/content_settings.h"
951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/content_settings/core/common/permission_request_id.h"
965f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "components/dom_distiller/core/url_constants.h"
976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "components/google/core/browser/google_util.h"
985f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "components/metrics/client_info.h"
99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/pref_registry/pref_registry_syncable.h"
1000529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "components/signin/core/common/profile_management_switches.h"
1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/translate/core/common/translate_switches.h"
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_child_process_host.h"
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_main_parts.h"
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_ppapi_host.h"
105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/browser/browser_thread.h"
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_url_handler.h"
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/child_process_data.h"
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/child_process_security_policy.h"
1095f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/browser/desktop_notification_delegate.h"
1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/public/browser/render_frame_host.h"
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/render_process_host.h"
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/render_view_host.h"
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/resource_context.h"
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/site_instance.h"
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents.h"
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/child_process_host.h"
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/content_descriptors.h"
118116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/common/show_desktop_notification_params.h"
11968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "content/public/common/url_utils.h"
120116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/common/web_preferences.h"
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/base/mime_util.h"
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/cookies/canonical_cookie.h"
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/cookies/cookie_options.h"
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/ssl/ssl_cert_request_info.h"
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/host/ppapi_host.h"
1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ppapi/shared_impl/ppapi_switches.h"
1271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/fileapi/external_mount_points.h"
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/resource/resource_bundle.h"
13003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "ui/resources/grit/ui_resources.h"
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/win/windows_version.h"
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_browser_main_win.h"
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "sandbox/win/src/sandbox_policy.h"
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_MACOSX)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_browser_main_mac.h"
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
1391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/crash/app/breakpad_mac.h"
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_CHROMEOS)
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h"
143116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/chromeos/file_manager/app_id.h"
1440529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.h"
1457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chromeos/fileapi/file_system_backend.h"
1465c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h"
147b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "chrome/browser/chromeos/login/startup_utils.h"
148558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch#include "chrome/browser/chromeos/system/input_device_settings.h"
149c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/chromeos_switches.h"
1506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/user_manager/user_manager.h"
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_LINUX)
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_browser_main_linux.h"
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_ANDROID)
154effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/browser/android/new_tab_page_url_handler.h"
15558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_browser_main_android.h"
157f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/media/protected_media_identifier_permission_context.h"
158f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/descriptors_android.h"
1601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/crash/browser/crash_dump_manager_android.h"
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_POSIX)
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chrome_browser_main_posix.h"
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#if defined(OS_POSIX) && !defined(OS_MACOSX)
1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/debug/leak_annotations.h"
1671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/crash/app/breakpad_linux.h"
1681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/crash/browser/crash_handler_host_linux.h"
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/ui_base_paths.h"
1738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ui/gfx/android/device_display_info.h"
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_ANDROID)
1771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/android/dev_tools_manager_delegate_android.h"
1781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#else
1791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
1801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif
1811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if !defined(OS_CHROMEOS)
183effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/browser/signin/chrome_signin_client.h"
184effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/browser/signin/chrome_signin_client_factory.h"
185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/signin/signin_manager_factory.h"
186e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "components/signin/core/browser/signin_manager.h"
187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#if defined(TOOLKIT_VIEWS)
1907dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h"
1917dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
1927dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(USE_ATHENA)
1941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "athena/content/public/web_contents_view_delegate_creator.h"
1951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.h"
1961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#elif defined(USE_ASH)
1977dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h"
1987dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
1997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
2007dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#if defined(USE_AURA)
2017dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h"
2027dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
2037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
2047dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#if defined(USE_X11)
2057dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_browser_main_extra_parts_x11.h"
2067dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
2077dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
20846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
20946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
21046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#endif
21146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
212116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(DISABLE_NACL)
213116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/nacl/browser/nacl_browser.h"
214116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/nacl/browser/nacl_host_message_filter.h"
215116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/nacl/browser/nacl_process_host.h"
216116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/nacl/common/nacl_process_type.h"
217116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/nacl/common/nacl_switches.h"
218116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
219116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
22046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
2216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
2225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/browser/extensions/extension_service.h"
2235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/browser/extensions/extension_util.h"
2241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
2251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/extension_system.h"
2266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "extensions/browser/guest_view/guest_view_base.h"
2276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "extensions/browser/guest_view/guest_view_manager.h"
2281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/guest_view/web_view/web_view_guest.h"
2291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
2301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
23103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "extensions/browser/suggest_permission_util.h"
2321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/constants.h"
2331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/extension.h"
2341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/extension_set.h"
2355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "extensions/common/manifest_handlers/background_info.h"
2361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/manifest_handlers/shared_module_info.h"
2371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/permissions/permissions_data.h"
2381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/permissions/socket_permission.h"
2391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/common/switches.h"
24046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#endif
24146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
242a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(ENABLE_SPELLCHECK)
243a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
244a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif
245a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
24646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#if defined(ENABLE_WEBRTC)
24746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "chrome/browser/media/webrtc_logging_handler_host.h"
24846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#endif
24946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using base::FileDescriptor;
2516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)using blink::WebWindowFeatures;
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::AccessTokenStore;
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::BrowserThread;
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::BrowserURLHandler;
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::ChildProcessSecurityPolicy;
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::QuotaPermissionContext;
2570529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochusing content::RenderFrameHost;
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::RenderViewHost;
259116680a4aac90f2aa7413d9095a592090648e557Ben Murdochusing content::ResourceType;
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::SiteInstance;
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::WebContents;
262116680a4aac90f2aa7413d9095a592090648e557Ben Murdochusing content::WebPreferences;
263558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochusing message_center::NotifierId;
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_POSIX)
266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using content::FileDescriptorInfo;
267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
2696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
2701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing extensions::APIPermission;
2716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)using extensions::ChromeContentBrowserClientExtensionsPart;
2721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing extensions::Extension;
2731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing extensions::InfoMap;
2741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing extensions::Manifest;
2756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif
2766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
279c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Cached version of the locale so we can return the locale on the I/O
280c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// thread.
281c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)base::LazyInstance<std::string> g_io_thread_application_locale;
282c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
283868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#if defined(ENABLE_PLUGINS)
2846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// TODO(teravest): Add renderer-side API-specific checking for these APIs so
2856d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// that blanket permission isn't granted to all dev channel APIs for these.
2866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// http://crbug.com/386743
2876d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)const char* const kPredefinedAllowedDevChannelOrigins[] = {
2886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",  // see crbug.com/383937
2896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  "4EB74897CB187C7633357C2FE832E0AD6A44883A"   // see crbug.com/383937
2906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)};
2916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
292cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)const char* const kPredefinedAllowedFileHandleOrigins[] = {
2930f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",  // see crbug.com/234789
2940f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  "4EB74897CB187C7633357C2FE832E0AD6A44883A"   // see crbug.com/234789
2950f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)};
2960f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
297cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)const char* const kPredefinedAllowedSocketOrigins[] = {
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "okddffdblfhhnmhodogpojmfkjmhinfp",  // Test SSH Client
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "pnhechapfaindjhompbnflcldabbghjo",  // HTerm App (SSH Client)
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "bglhmjfplikpjnfoegeomebmfnkjomhe",  // see crbug.com/122126
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "gbchcmhmhahfdphkhkmpfmihenigjmpp",  // Chrome Remote Desktop
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "kgngmbheleoaphbjbaiobfdepmghbfah",  // Pre-release Chrome Remote Desktop
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "odkaodonbgfohohmklejpjiejmcipmib",  // Dogfood Chrome Remote Desktop
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "ojoimpklfciegopdfgeenehpalipignm",  // Chromoting canary
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "cbkkbcmdlboombapidmoeolnmdacpkch",  // see crbug.com/129089
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "hhnbmknkdabfoieppbbljkhkfjcmcbjh",  // see crbug.com/134099
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "mablfbjkhmhkmefkjjacnbaikjkipphg",  // see crbug.com/134099
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "pdeelgamlgannhelgoegilelnnojegoh",  // see crbug.com/134099
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "cabapfdbkniadpollkckdnedaanlciaj",  // see crbug.com/134099
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "mapljbgnjledlpdmlchihnmeclmefbba",  // see crbug.com/134099
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  "ghbfeebgmiidnnmeobbbaiamklmpbpii",  // see crbug.com/134099
3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  "jdfhpkjeckflbbleddjlpimecpbjdeep",  // see crbug.com/142514
313c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  "iabmpiboiopbgfabjmgeedhcmjenhbla",  // see crbug.com/165080
314c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "B7CF8A292249681AF81771650BA4CEEAF19A4560",  // see crbug.com/165080
315c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",  // see crbug.com/234789
316c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "4EB74897CB187C7633357C2FE832E0AD6A44883A",  // see crbug.com/234789
317c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "7525AF4F66763A70A883C4700529F647B470E4D2",  // see crbug.com/238084
318c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "0B549507088E1564D672F7942EB87CA4DAD73972",  // see crbug.com/238084
319c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch  "864288364E239573E777D3E0E36864E590E95C74"   // see crbug.com/238084
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
321868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a copy of the given url with its host set to given host and path set
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to given path. Other parts of the url will be the same.
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GURL ReplaceURLHostAndPath(const GURL& url,
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const std::string& host,
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const std::string& path) {
3285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  url::Replacements<char> replacements;
3295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  replacements.SetHost(host.c_str(), url::Component(0, host.length()));
3305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  replacements.SetPath(path.c_str(), url::Component(0, path.length()));
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return url.ReplaceComponents(replacements);
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Maps "foo://bar/baz/" to "foo://chrome/bar/baz/".
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GURL AddUberHost(const GURL& url) {
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const std::string uber_host = chrome::kChromeUIUberHost;
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const std::string new_path = url.host() + url.path();
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return ReplaceURLHostAndPath(url, uber_host, new_path);
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If url->host() is "chrome" and url->path() has characters other than the
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// first slash, changes the url from "foo://chrome/bar/" to "foo://bar/" and
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// returns true. Otherwise returns false.
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RemoveUberHost(GURL* url) {
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (url->host() != chrome::kChromeUIUberHost)
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return false;
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (url->path().empty() || url->path() == "/")
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return false;
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const std::string old_path = url->path();
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const std::string::size_type separator = old_path.find('/', 1);
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string new_host;
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string new_path;
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (separator == std::string::npos) {
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_host = old_path.substr(1);
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else {
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_host = old_path.substr(1, separator - 1);
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_path = old_path.substr(separator);
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3647d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Do not allow URLs with paths empty before the first slash since we can't
3657d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // have an empty host. (e.g "foo://chrome//")
3667d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (new_host.empty())
3677d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return false;
3687d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *url = ReplaceURLHostAndPath(*url, new_host, new_path);
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  DCHECK(url->is_valid());
3727d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return true;
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Handles rewriting Web UI URLs.
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Do not handle special URLs such as "about:foo"
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!url->host().empty()) {
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const GURL chrome_url = AddUberHost(*url);
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Handle valid "chrome://chrome/foo" URLs so the reverse handler will
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // be called.
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            browser_context, chrome_url))
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return true;
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          browser_context, *url))
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return false;
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_CHROMEOS)
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Special case : in ChromeOS in Guest mode bookmarks and history are
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // disabled for security reasons. New tab page explains the reasons, so
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // we redirect user to new tab page.
3976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) {
3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    if (url->SchemeIs(content::kChromeUIScheme) &&
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        (url->DomainIs(chrome::kChromeUIBookmarksHost) ||
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         url->DomainIs(chrome::kChromeUIHistoryHost))) {
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      // Rewrite with new tab URL
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      *url = GURL(chrome::kChromeUINewTabURL);
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return true;
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// "chrome://foo/".
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) {
4135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme))
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return false;
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return RemoveUberHost(url);
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool CertMatchesFilter(const net::X509Certificate& cert,
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const base::DictionaryValue& filter) {
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(markusheintz): This is the minimal required filter implementation.
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Implement a better matcher.
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // An empty filter matches any client certificate since no requirements are
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // specified at all.
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (filter.empty())
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return true;
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string common_name;
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (filter.GetString("ISSUER.CN", &common_name) &&
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      (cert.issuer().common_name == common_name)) {
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return true;
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return false;
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
4388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
4398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    const std::string& process_type) {
4408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  base::FilePath dumps_path;
4418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
4428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  {
4438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    ANNOTATE_SCOPED_MEMORY_LEAK;
444cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    bool upload = (getenv(env_vars::kHeadless) == NULL);
4458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    breakpad::CrashHandlerHostLinux* crash_handler =
446cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        new breakpad::CrashHandlerHostLinux(process_type, dumps_path, upload);
4478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    crash_handler->StartUploaderThread();
4488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return crash_handler;
4498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
4508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
4518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int GetCrashSignalFD(const CommandLine& command_line) {
453cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Extensions have the same process type as renderers.
4545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
4558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
4568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if (!crash_handler)
4578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      crash_handler = CreateCrashHandlerHost("extension");
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return crash_handler->GetDeathSignalSocket();
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string process_type =
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      command_line.GetSwitchValueASCII(switches::kProcessType);
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (process_type == switches::kRendererProcess) {
4658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
4668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if (!crash_handler)
4678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      crash_handler = CreateCrashHandlerHost(process_type);
4688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return crash_handler->GetDeathSignalSocket();
4698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (process_type == switches::kPluginProcess) {
4728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
4738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if (!crash_handler)
4748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      crash_handler = CreateCrashHandlerHost(process_type);
4758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return crash_handler->GetDeathSignalSocket();
4768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (process_type == switches::kPpapiPluginProcess) {
4798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
4808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if (!crash_handler)
4818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      crash_handler = CreateCrashHandlerHost(process_type);
4828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return crash_handler->GetDeathSignalSocket();
4838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (process_type == switches::kGpuProcess) {
4868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
4878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if (!crash_handler)
4888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      crash_handler = CreateCrashHandlerHost(process_type);
4898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return crash_handler->GetDeathSignalSocket();
4908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return -1;
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4945f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif  // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
496c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if !defined(OS_CHROMEOS)
4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)GURL GetEffectiveURLForSignin(const GURL& url) {
4982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CHECK(SigninManager::IsWebBasedSigninFlowURL(url));
4992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL effective_url(SigninManager::kChromeSigninEffectiveSite);
5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Copy the path because the argument to SetPathStr must outlive
5022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the Replacements object.
5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const std::string path_copy(url.path());
5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL::Replacements replacements;
5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  replacements.SetPathStr(path_copy);
5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  effective_url = effective_url.ReplaceComponents(replacements);
5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return effective_url;
5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
509c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
510c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
511c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void SetApplicationLocaleOnIOThread(const std::string& locale) {
512c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
513c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  g_io_thread_application_locale.Get() = locale;
514c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
515c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
51658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)void HandleBlockedPopupOnUIThread(const BlockedWindowParams& params) {
51758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  WebContents* tab = tab_util::GetWebContentsByID(params.render_process_id(),
51858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                                  params.opener_id());
519558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  if (!tab)
520558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch    return;
521558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch
5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  prerender::PrerenderContents* prerender_contents =
5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prerender::PrerenderContents::FromWebContents(tab);
5245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (prerender_contents) {
5255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW);
5265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
5275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
5285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
529558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  PopupBlockerTabHelper* popup_helper =
530558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch      PopupBlockerTabHelper::FromWebContents(tab);
531558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  if (!popup_helper)
532558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch    return;
53358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  popup_helper->AddBlockedPopup(params);
53458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
53558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
53658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_ANDROID)
5378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
53858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) {
53958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  WebContents* web_contents =
54058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)      tab_util::GetWebContentsByID(params.render_process_id(),
54158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                   params.opener_id());
54258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  if (!web_contents)
54358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    return;
54458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
54558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params);
546558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch}
5478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
5480f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)float GetDeviceScaleAdjustment() {
5498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  static const float kMinFSM = 1.05f;
5508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  static const int kWidthForMinFSM = 320;
5518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  static const float kMaxFSM = 1.3f;
5528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  static const int kWidthForMaxFSM = 800;
5538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
5548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  gfx::DeviceDisplayInfo info;
5558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  int minWidth = info.GetSmallestDIPWidth();
5568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
5578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (minWidth <= kWidthForMinFSM)
5588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return kMinFSM;
5598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (minWidth >= kWidthForMaxFSM)
5608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return kMaxFSM;
5618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
5628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // The font scale multiplier varies linearly between kMinFSM and kMaxFSM.
5638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  float ratio = static_cast<float>(minWidth - kWidthForMinFSM) /
5648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      (kWidthForMaxFSM - kWidthForMinFSM);
5658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
5668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
5678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
56858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif  // defined(OS_ANDROID)
569558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch
5706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
5716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// By default, JavaScript and images are enabled in guest content.
5726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)void GetGuestViewDefaultContentSettingRules(
5736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    bool incognito,
5746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    RendererContentSettingRules* rules) {
5756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  rules->image_rules.push_back(
5766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
5776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  ContentSettingsPattern::Wildcard(),
5786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  CONTENT_SETTING_ALLOW,
5796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  std::string(),
5806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  incognito));
5816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
5826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  rules->script_rules.push_back(
5836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
5846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  ContentSettingsPattern::Wildcard(),
5856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  CONTENT_SETTING_ALLOW,
5866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  std::string(),
5876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                  incognito));
5886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}
5896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif  // defined(ENALBE_EXTENSIONS)
5906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace chrome {
5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)ChromeContentBrowserClient::ChromeContentBrowserClient()
596116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    : prerender_tracker_(NULL),
597116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      weak_factory_(this) {
598868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#if defined(ENABLE_PLUGINS)
5996d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
6006d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
6010f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
6020f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)    allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
605868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif
60690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
607116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(OS_ANDROID)
608116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance();
609116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine);
610116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
6115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
6126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
6135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart);
6146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ChromeContentBrowserClient::~ChromeContentBrowserClient() {
6185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i)
6195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    delete extra_parts_[i];
6205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  extra_parts_.clear();
6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
6247dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochvoid ChromeContentBrowserClient::RegisterProfilePrefs(
625c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    user_prefs::PrefRegistrySyncable* registry) {
626c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  registry->RegisterBooleanPref(
627c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      prefs::kDisable3DAPIs,
628c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      false,
629c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
630c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  registry->RegisterBooleanPref(
631c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      prefs::kEnableHyperlinkAuditing,
632c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      true,
633c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
6346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  registry->RegisterListPref(
6356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      prefs::kEnableDeprecatedWebPlatformFeatures,
6366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
637c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
638c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
639c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// static
640c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void ChromeContentBrowserClient::SetApplicationLocale(
641c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const std::string& locale) {
642c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
643c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
644c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // This object is guaranteed to outlive all threads so we don't have to
645c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // worry about the lack of refcounting and can just post as Unretained.
646c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  //
647c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // The common case is that this function is called early in Chrome startup
648c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // before any threads are created (it will also be called later if the user
649c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // changes the pref). In this case, there will be no threads created and
650c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // posting will fail. When there are no threads, we can just set the string
651c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // without worrying about threadsafety.
652c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
653c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)          base::Bind(&SetApplicationLocaleOnIOThread, locale))) {
654c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    g_io_thread_application_locale.Get() = locale;
655c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const content::MainFunctionParams& parameters) {
6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ChromeBrowserMainParts* main_parts;
6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Construct the Main browser parts based on the OS type.
6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainPartsWin(parameters);
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_MACOSX)
6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainPartsMac(parameters);
6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_CHROMEOS)
6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  main_parts = new chromeos::ChromeBrowserMainPartsChromeos(parameters);
6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_LINUX)
6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainPartsLinux(parameters);
6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_ANDROID)
6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainPartsAndroid(parameters);
6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_POSIX)
6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainPartsPosix(parameters);
6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NOTREACHED();
6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  main_parts = new ChromeBrowserMainParts(parameters);
6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
67990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  chrome::AddProfilesExtraParts(main_parts);
68090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Construct additional browser parts. Stages are called in the order in
6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // which they are added.
6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(TOOLKIT_VIEWS)
6847dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  main_parts->AddParts(new ChromeBrowserMainExtraPartsViews());
6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// TODO(oshima): Athena on chrome currently requires USE_ASH to build.
6881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// We should reduce the dependency as much as possible.
6891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(USE_ATHENA)
6901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  main_parts->AddParts(CreateChromeBrowserMainExtraPartsAthena());
6911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#elif defined(USE_ASH)
6927dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  main_parts->AddParts(new ChromeBrowserMainExtraPartsAsh());
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(USE_AURA)
6967dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  main_parts->AddParts(new ChromeBrowserMainExtraPartsAura());
6977dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#endif
6987dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
6997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#if defined(USE_X11)
7007dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  main_parts->AddParts(new ChromeBrowserMainExtraPartsX11());
7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
703c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  chrome::AddMetricsExtraParts(main_parts);
704c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return main_parts;
7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite(
7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::BrowserContext* browser_context,
7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const GURL& site) {
7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string partition_id;
7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The partition ID for webview guest processes is the string value of its
7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // SiteInstance URL - "chrome-guest://app_id/persist?partition".
715a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (site.SchemeIs(content::kGuestScheme)) {
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    partition_id = site.spec();
717a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  } else if (site.GetOrigin().spec() == kChromeUIChromeSigninURL) {
718a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Chrome signin page has an embedded iframe of extension and web content,
719a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // thus it must be isolated from other webUI pages.
720a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    partition_id = site.GetOrigin().spec();
721a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
723c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return partition_id;
7255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeContentBrowserClient::IsValidStoragePartitionId(
7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::BrowserContext* browser_context,
7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const std::string& partition_id) {
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The default ID is empty and is always valid.
7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (partition_id.empty())
7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return true;
7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return GURL(partition_id).is_valid();
7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::BrowserContext* browser_context,
7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const GURL& site,
7402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool can_be_default,
7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string* partition_domain,
7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string* partition_name,
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool* in_memory) {
7442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Default to the browser-wide storage partition and override based on |site|
7452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // below.
7462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  partition_domain->clear();
7472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  partition_name->clear();
7482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  *in_memory = false;
7492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
750f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  bool success = false;
751f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
7526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  success = extensions::WebViewGuest::GetGuestPartitionConfigForSite(
753f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      site, partition_domain, partition_name, in_memory);
754f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
755f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  if (!success && site.SchemeIs(extensions::kExtensionScheme)) {
7562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // If |can_be_default| is false, the caller is stating that the |site|
7572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // should be parsed as if it had isolated storage. In particular it is
7582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // important to NOT check ExtensionService for the is_storage_isolated()
7592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // attribute because this code path is run during Extension uninstall
7602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // to do cleanup after the Extension has already been unloaded from the
7612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // ExtensionService.
7622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool is_isolated = !can_be_default;
7632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (can_be_default) {
764effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      if (extensions::util::SiteHasIsolatedStorage(site, browser_context))
765effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch        is_isolated = true;
7662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (is_isolated) {
7692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      CHECK(site.has_host());
7702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // For extensions with isolated storage, the the host of the |site| is
7712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // the |partition_domain|. The |in_memory| and |partition_name| are only
7722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // used in guest schemes so they are cleared here.
7732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      *partition_domain = site.host();
7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      *in_memory = false;
7752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      partition_name->clear();
7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
777f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    success = true;
778f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  }
779f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif
780f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
781f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  if (!success && (site.GetOrigin().spec() == kChromeUIChromeSigninURL)) {
7825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // Chrome signin page has an embedded iframe of extension and web content,
7835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // thus it must be isolated from other webUI pages.
7845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    *partition_domain = chrome::kChromeUIChromeSigninHost;
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Assert that if |can_be_default| is false, the code above must have found a
7882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // non-default partition.  If this fails, the caller has a serious logic
7892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // error about which StoragePartition they expect to be in and it is not
7902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // safe to continue.
7912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CHECK(can_be_default || !partition_domain->empty());
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)content::WebContentsViewDelegate*
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ChromeContentBrowserClient::GetWebContentsViewDelegate(
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        content::WebContents* web_contents) {
7971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(USE_ATHENA)
7981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return athena::CreateWebContentsViewDelegate(web_contents);
7991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#else
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return chrome::CreateWebContentsViewDelegate(web_contents);
8011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void ChromeContentBrowserClient::RenderProcessWillLaunch(
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::RenderProcessHost* host) {
8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int id = host->GetID();
8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
8082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  net::URLRequestContextGetter* context =
8092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      profile->GetRequestContextForRenderProcess(id);
8102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
81146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  host->AddFilter(new ChromeRenderMessageFilter(id, profile));
8122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(ENABLE_PLUGINS)
8134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(new PluginInfoMessageFilter(id, profile));
8142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
8155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  host->AddFilter(new cast::CastTransportHostFilter);
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(ENABLE_PRINTING)
81703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  host->AddFilter(new printing::PrintingMessageFilter(id, profile));
8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
8194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(new SearchProviderInstallStateMessageFilter(id, profile));
820a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(ENABLE_SPELLCHECK)
8214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(new SpellCheckMessageFilter(id));
822a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif
8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
8244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(new SpellCheckMessageFilterMac(id));
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
8265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  host->AddFilter(new ChromeNetBenchmarkingMessageFilter(profile, context));
8274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(new prerender::PrerenderMessageFilter(id, profile));
8286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  host->AddFilter(new TtsMessageFilter(id, host->GetBrowserContext()));
829868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#if defined(ENABLE_WEBRTC)
8304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  WebRtcLoggingHandlerHost* webrtc_logging_handler_host =
8318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      new WebRtcLoggingHandlerHost(profile);
8325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  host->SetWebRtcLogMessageCallback(base::Bind(
8335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      &WebRtcLoggingHandlerHost::LogMessage, webrtc_logging_handler_host));
8344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->AddFilter(webrtc_logging_handler_host);
8354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  host->SetUserData(host, new base::UserDataAdapter<WebRtcLoggingHandlerHost>(
8364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      webrtc_logging_handler_host));
837868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif
8387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#if !defined(DISABLE_NACL)
839f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  host->AddFilter(new nacl::NaClHostMessageFilter(
840eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      id, profile->IsOffTheRecord(),
8418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      profile->GetPath(),
842eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      context));
8437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif
844d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#if defined(OS_ANDROID)
845010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  host->AddFilter(new cdm::CdmMessageFilterAndroid());
846d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif
8475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  if (switches::IsEnableAccountConsistency())
848a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    host->AddFilter(new PrincipalsMessageFilter(id));
8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      profile->IsOffTheRecord()));
8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  for (size_t i = 0; i < extra_parts_.size(); ++i)
8545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    extra_parts_[i]->RenderProcessWillLaunch(host);
8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RendererContentSettingRules rules;
857cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (host->IsIsolatedGuest()) {
858f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
8596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    GetGuestViewDefaultContentSettingRules(profile->IsOffTheRecord(), &rules);
860f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#else
861f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    NOTREACHED();
862f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif
863a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  } else {
864a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    GetRendererContentSettingRules(
865a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)        profile->GetHostContentSettingsMap(), &rules);
866a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  }
8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GURL ChromeContentBrowserClient::GetEffectiveURL(
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::BrowserContext* browser_context, const GURL& url) {
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Profile* profile = Profile::FromBrowserContext(browser_context);
8732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!profile)
8742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return url;
8752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
876a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // If the input |url| should be assigned to the Instant renderer, make its
877a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // effective URL distinct from other URLs on the search provider's domain.
878a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (chrome::ShouldAssignURLToInstantRenderer(url, profile))
879a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return chrome::GetEffectiveURLForInstant(url, profile);
880a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
881c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if !defined(OS_CHROMEOS)
8822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If the input |url| should be assigned to the Signin renderer, make its
8832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // effective URL distinct from other URLs on the signin service's domain.
8842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Note that the signin renderer will be allowed to sign the user in to
8852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Chrome.
8862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (SigninManager::IsWebBasedSigninFlowURL(url))
8872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return GetEffectiveURLForSignin(url);
888c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
8892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
8915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL(
8925f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      profile, url);
8936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#else
8946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  return url;
8956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif
8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::BrowserContext* browser_context, const GURL& effective_url) {
9002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Non-extension, non-Instant URLs should generally use
9012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // process-per-site-instance.  Because we expect to use the effective URL,
9022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // URLs for hosted apps (apart from bookmark apps) should have an extension
9032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // scheme by now.
9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Profile* profile = Profile::FromBrowserContext(browser_context);
9062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!profile)
9072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
9082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
909a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  if (chrome::ShouldUseProcessPerSiteForInstantURL(effective_url, profile))
9102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
9112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
912c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if !defined(OS_CHROMEOS)
9132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (SigninManager::IsWebBasedSigninFlowURL(effective_url))
9142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
915c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
9162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
9176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS)
9185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite(
9195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      profile, effective_url);
9206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#else
9216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  return false;
9226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif
9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// These are treated as WebUI schemes but do not get WebUI bindings. Also,
9265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// view-source is allowed for these schemes.
927c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void ChromeContentBrowserClient::GetAdditionalWebUISchemes(
928c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    std::vector<std::string>* additional_schemes) {
929c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  additional_schemes->push_back(chrome::kChromeSearchScheme);
9305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  additional_schemes->push_back(dom_distiller::kDomDistillerScheme);
9312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
9322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
933a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void ChromeContentBrowserClient::GetAdditionalWebUIHostsToIgnoreParititionCheck(
934a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    std::vector<std::string>* hosts) {
935a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIExtensionIconHost);
936a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIFaviconHost);
937a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIThemeHost);
938a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIThumbnailHost);
939a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIThumbnailHost2);
940a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  hosts->push_back(chrome::kChromeUIThumbnailListHost);
941a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
942a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
9432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)net::URLRequestContextGetter*
944