OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "chrome/browser/prerender/prerender_message_filter.h" | 56 #include "chrome/browser/prerender/prerender_message_filter.h" |
57 #include "chrome/browser/prerender/prerender_tracker.h" | 57 #include "chrome/browser/prerender/prerender_tracker.h" |
58 #include "chrome/browser/printing/printing_message_filter.h" | 58 #include "chrome/browser/printing/printing_message_filter.h" |
59 #include "chrome/browser/profiles/profile.h" | 59 #include "chrome/browser/profiles/profile.h" |
60 #include "chrome/browser/profiles/profile_io_data.h" | 60 #include "chrome/browser/profiles/profile_io_data.h" |
61 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
62 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 62 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
63 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" | 63 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
64 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" | 64 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" |
65 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" | 65 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" |
66 #include "chrome/browser/search_engines/template_url_service.h" | |
67 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
68 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 66 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
69 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" | 67 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
70 #include "chrome/browser/ssl/ssl_add_certificate.h" | 68 #include "chrome/browser/ssl/ssl_add_certificate.h" |
71 #include "chrome/browser/ssl/ssl_blocking_page.h" | 69 #include "chrome/browser/ssl/ssl_blocking_page.h" |
72 #include "chrome/browser/ssl/ssl_tab_helper.h" | 70 #include "chrome/browser/ssl/ssl_tab_helper.h" |
73 #include "chrome/browser/tab_contents/tab_util.h" | 71 #include "chrome/browser/tab_contents/tab_util.h" |
74 #include "chrome/browser/toolkit_extra_parts.h" | 72 #include "chrome/browser/toolkit_extra_parts.h" |
75 #include "chrome/browser/ui/chrome_select_file_policy.h" | 73 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 74 #include "chrome/browser/ui/search/search.h" |
76 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 75 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
77 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 76 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
78 #include "chrome/browser/user_style_sheet_watcher.h" | 77 #include "chrome/browser/user_style_sheet_watcher.h" |
79 #include "chrome/browser/user_style_sheet_watcher_factory.h" | 78 #include "chrome/browser/user_style_sheet_watcher_factory.h" |
80 #include "chrome/browser/view_type_utils.h" | 79 #include "chrome/browser/view_type_utils.h" |
81 #include "chrome/common/child_process_logging.h" | 80 #include "chrome/common/child_process_logging.h" |
82 #include "chrome/common/chrome_constants.h" | 81 #include "chrome/common/chrome_constants.h" |
83 #include "chrome/common/chrome_paths.h" | 82 #include "chrome/common/chrome_paths.h" |
84 #include "chrome/common/chrome_switches.h" | 83 #include "chrome/common/chrome_switches.h" |
85 #include "chrome/common/extensions/extension.h" | 84 #include "chrome/common/extensions/extension.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (process_type == switches::kPpapiPluginProcess) | 399 if (process_type == switches::kPpapiPluginProcess) |
401 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 400 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
402 | 401 |
403 if (process_type == switches::kGpuProcess) | 402 if (process_type == switches::kGpuProcess) |
404 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 403 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
405 | 404 |
406 return -1; | 405 return -1; |
407 } | 406 } |
408 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 407 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
409 | 408 |
410 // TODO(dhollowa): http://crbug.com/170390 This test exists in different places | 409 // Transforms the input |url| into its "effective URL". The returned URL |
411 // in Chrome. Follow-up to consolidate these various Instant URL checks. | |
412 // Returns true if |url| has the same scheme, host, and path as the instant URL | |
413 // set via --instant-url. | |
414 bool IsForcedInstantURL(const GURL& url) { | |
415 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
416 if (command_line->HasSwitch(switches::kInstantURL)) { | |
417 GURL instant_url(command_line->GetSwitchValueASCII(switches::kInstantURL)); | |
418 if (url.scheme() == instant_url.scheme() && | |
419 url.host() == instant_url.host() && | |
420 url.path() == instant_url.path()) { | |
421 return true; | |
422 } | |
423 } | |
424 return false; | |
425 } | |
426 | |
427 // Determines whether the |url| is an Instant url for the default search | |
428 // provider (set for the |profile|). | |
429 // Also returns true if an Instant "effective url" (see below) is passed in. | |
430 bool IsInstantURL(const GURL& url, Profile* profile) { | |
431 // Handle the command-line URL. | |
432 if (IsForcedInstantURL(url)) | |
433 return true; | |
434 | |
435 // A URL of this form has already be determined to be an Instant url, | |
436 // this is its "effective url". So trivially return true. | |
437 if (url.SchemeIs(chrome::kChromeSearchScheme)) | |
438 return true; | |
439 | |
440 TemplateURLService* template_url_service = | |
441 TemplateURLServiceFactory::GetForProfile(profile); | |
442 if (!template_url_service) | |
443 return false; | |
444 | |
445 TemplateURL* template_url = template_url_service->GetDefaultSearchProvider(); | |
446 if (!template_url) | |
447 return false; | |
448 | |
449 if (template_url->instant_url().empty()) | |
450 return false; | |
451 | |
452 return template_url->IsInstantURL(url); | |
453 } | |
454 | |
455 // Transforms the input |url| into its "effective url". The returned url | |
456 // facilitates grouping process-per-site. The |url| is transformed, for | 410 // facilitates grouping process-per-site. The |url| is transformed, for |
457 // example, from | 411 // example, from |
458 // | 412 // |
459 // https://www.google.com/search?espv=1&q=tractors | 413 // https://www.google.com/search?espv=1&q=tractors |
460 // | 414 // |
461 // to the effective url | 415 // to the effective URL |
462 // | 416 // |
463 // chrome-search://www.google.com/search?espv=1&q=tractors | 417 // chrome-search://www.google.com/search?espv=1&q=tractors |
464 // | 418 // |
465 // Notice the scheme change. | 419 // Notice the scheme change. |
466 // If the input is already an effective url then that same url is | 420 // |
467 // returned. | 421 // If the input is already an effective URL then that same URL is returned. |
468 GURL GetEffectiveInstantURL(const GURL& url, Profile* profile) { | 422 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { |
469 CHECK(IsInstantURL(url, profile)) << "Error granting Instant access."; | 423 CHECK(chrome::search::ShouldAssignURLToInstantRenderer(url, profile)) |
| 424 << "Error granting Instant access."; |
470 | 425 |
471 if (url.SchemeIs(chrome::kChromeSearchScheme)) | 426 if (url.SchemeIs(chrome::kChromeSearchScheme)) |
472 return url; | 427 return url; |
473 | 428 |
474 GURL effective_url(url); | 429 GURL effective_url(url); |
475 | 430 |
476 // Replace the scheme with "chrome-search:". | 431 // Replace the scheme with "chrome-search:". |
477 url_canon::Replacements<char> replacements; | 432 url_canon::Replacements<char> replacements; |
478 std::string search_scheme(chrome::kChromeSearchScheme); | 433 std::string search_scheme(chrome::kChromeSearchScheme); |
479 replacements.SetScheme(search_scheme.data(), | 434 replacements.SetScheme(search_scheme.data(), |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); | 676 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); |
722 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); | 677 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
723 } | 678 } |
724 | 679 |
725 GURL ChromeContentBrowserClient::GetEffectiveURL( | 680 GURL ChromeContentBrowserClient::GetEffectiveURL( |
726 content::BrowserContext* browser_context, const GURL& url) { | 681 content::BrowserContext* browser_context, const GURL& url) { |
727 Profile* profile = Profile::FromBrowserContext(browser_context); | 682 Profile* profile = Profile::FromBrowserContext(browser_context); |
728 if (!profile) | 683 if (!profile) |
729 return url; | 684 return url; |
730 | 685 |
731 // If the input |url| is an Instant url, make its effective url distinct from | 686 // If the input |url| should be assigned to the Instant renderer, make its |
732 // other urls on the search provider's domain. | 687 // effective URL distinct from other URLs on the search provider's domain. |
733 if (IsInstantURL(url, profile)) | 688 if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile)) |
734 return GetEffectiveInstantURL(url, profile); | 689 return GetEffectiveURLForInstant(url, profile); |
735 | 690 |
736 // If the input |url| is part of an installed app, the effective URL is an | 691 // If the input |url| is part of an installed app, the effective URL is an |
737 // extension URL with the ID of that extension as the host. This has the | 692 // extension URL with the ID of that extension as the host. This has the |
738 // effect of grouping apps together in a common SiteInstance. | 693 // effect of grouping apps together in a common SiteInstance. |
739 ExtensionService* extension_service = | 694 ExtensionService* extension_service = |
740 extensions::ExtensionSystem::Get(profile)->extension_service(); | 695 extensions::ExtensionSystem::Get(profile)->extension_service(); |
741 if (!extension_service) | 696 if (!extension_service) |
742 return url; | 697 return url; |
743 | 698 |
744 const Extension* extension = extension_service->extensions()-> | 699 const Extension* extension = extension_service->extensions()-> |
(...skipping 15 matching lines...) Expand all Loading... |
760 content::BrowserContext* browser_context, const GURL& effective_url) { | 715 content::BrowserContext* browser_context, const GURL& effective_url) { |
761 // Non-extension, non-Instant URLs should generally use | 716 // Non-extension, non-Instant URLs should generally use |
762 // process-per-site-instance. Because we expect to use the effective URL, | 717 // process-per-site-instance. Because we expect to use the effective URL, |
763 // URLs for hosted apps (apart from bookmark apps) should have an extension | 718 // URLs for hosted apps (apart from bookmark apps) should have an extension |
764 // scheme by now. | 719 // scheme by now. |
765 | 720 |
766 Profile* profile = Profile::FromBrowserContext(browser_context); | 721 Profile* profile = Profile::FromBrowserContext(browser_context); |
767 if (!profile) | 722 if (!profile) |
768 return false; | 723 return false; |
769 | 724 |
770 if (IsInstantURL(effective_url, profile)) | 725 if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile)) |
771 return true; | 726 return true; |
772 | 727 |
773 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) | 728 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) |
774 return false; | 729 return false; |
775 | 730 |
776 ExtensionService* extension_service = | 731 ExtensionService* extension_service = |
777 extensions::ExtensionSystem::Get(profile)->extension_service(); | 732 extensions::ExtensionSystem::Get(profile)->extension_service(); |
778 if (!extension_service) | 733 if (!extension_service) |
779 return false; | 734 return false; |
780 | 735 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 Profile::FromBrowserContext(process_host->GetBrowserContext()); | 813 Profile::FromBrowserContext(process_host->GetBrowserContext()); |
859 // This may be NULL during tests. In that case, just assume any site can | 814 // This may be NULL during tests. In that case, just assume any site can |
860 // share any host. | 815 // share any host. |
861 if (!profile) | 816 if (!profile) |
862 return true; | 817 return true; |
863 | 818 |
864 InstantService* instant_service = | 819 InstantService* instant_service = |
865 InstantServiceFactory::GetForProfile(profile); | 820 InstantServiceFactory::GetForProfile(profile); |
866 if (instant_service && | 821 if (instant_service && |
867 instant_service->IsInstantProcess(process_host->GetID())) | 822 instant_service->IsInstantProcess(process_host->GetID())) |
868 return IsInstantURL(site_url, profile); | 823 return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile); |
869 | 824 |
870 ExtensionService* service = | 825 ExtensionService* service = |
871 extensions::ExtensionSystem::Get(profile)->extension_service(); | 826 extensions::ExtensionSystem::Get(profile)->extension_service(); |
872 extensions::ProcessMap* process_map = service->process_map(); | 827 extensions::ProcessMap* process_map = service->process_map(); |
873 | 828 |
874 // Don't allow the Task Manager to share a process with anything else. | 829 // Don't allow the Task Manager to share a process with anything else. |
875 // Otherwise it can affect the renderers it is observing. | 830 // Otherwise it can affect the renderers it is observing. |
876 // Note: we could create another RenderProcessHostPrivilege bucket for | 831 // Note: we could create another RenderProcessHostPrivilege bucket for |
877 // this to allow multiple chrome://tasks instances to share, but that's | 832 // this to allow multiple chrome://tasks instances to share, but that's |
878 // a very unlikely case without serious consequences. | 833 // a very unlikely case without serious consequences. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 SiteInstance* site_instance) { | 903 SiteInstance* site_instance) { |
949 CHECK(site_instance->HasProcess()); | 904 CHECK(site_instance->HasProcess()); |
950 | 905 |
951 Profile* profile = Profile::FromBrowserContext( | 906 Profile* profile = Profile::FromBrowserContext( |
952 site_instance->GetBrowserContext()); | 907 site_instance->GetBrowserContext()); |
953 if (!profile) | 908 if (!profile) |
954 return; | 909 return; |
955 | 910 |
956 // Remember the ID of the Instant process to signal the renderer process | 911 // Remember the ID of the Instant process to signal the renderer process |
957 // on startup in |AppendExtraCommandLineSwitches| below. | 912 // on startup in |AppendExtraCommandLineSwitches| below. |
958 if (IsInstantURL(site_instance->GetSiteURL(), profile)) { | 913 if (chrome::search::ShouldAssignURLToInstantRenderer( |
| 914 site_instance->GetSiteURL(), profile)) { |
959 InstantService* instant_service = | 915 InstantService* instant_service = |
960 InstantServiceFactory::GetForProfile(profile); | 916 InstantServiceFactory::GetForProfile(profile); |
961 if (instant_service) | 917 if (instant_service) |
962 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); | 918 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
963 } | 919 } |
964 | 920 |
965 ExtensionService* service = | 921 ExtensionService* service = |
966 extensions::ExtensionSystem::Get(profile)->extension_service(); | 922 extensions::ExtensionSystem::Get(profile)->extension_service(); |
967 if (!service) | 923 if (!service) |
968 return; | 924 return; |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 io_thread_application_locale_ = locale; | 2045 io_thread_application_locale_ = locale; |
2090 } | 2046 } |
2091 | 2047 |
2092 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2048 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
2093 const std::string& locale) { | 2049 const std::string& locale) { |
2094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2050 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2095 io_thread_application_locale_ = locale; | 2051 io_thread_application_locale_ = locale; |
2096 } | 2052 } |
2097 | 2053 |
2098 } // namespace chrome | 2054 } // namespace chrome |
OLD | NEW |