Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 12374007: signin: force web signin flow initiated visits to accounts.google.com to their own process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "chrome/browser/prerender/prerender_message_filter.h" 57 #include "chrome/browser/prerender/prerender_message_filter.h"
58 #include "chrome/browser/prerender/prerender_tracker.h" 58 #include "chrome/browser/prerender/prerender_tracker.h"
59 #include "chrome/browser/printing/printing_message_filter.h" 59 #include "chrome/browser/printing/printing_message_filter.h"
60 #include "chrome/browser/profiles/profile.h" 60 #include "chrome/browser/profiles/profile.h"
61 #include "chrome/browser/profiles/profile_io_data.h" 61 #include "chrome/browser/profiles/profile_io_data.h"
62 #include "chrome/browser/profiles/profile_manager.h" 62 #include "chrome/browser/profiles/profile_manager.h"
63 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 63 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
64 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" 64 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
65 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h" 65 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h"
66 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h" 66 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h"
67 #include "chrome/browser/signin/signin_manager.h"
68 #include "chrome/browser/signin/signin_manager_factory.h"
67 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" 69 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
68 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" 70 #include "chrome/browser/spellchecker/spellcheck_message_filter.h"
69 #include "chrome/browser/ssl/ssl_add_certificate.h" 71 #include "chrome/browser/ssl/ssl_add_certificate.h"
70 #include "chrome/browser/ssl/ssl_blocking_page.h" 72 #include "chrome/browser/ssl/ssl_blocking_page.h"
71 #include "chrome/browser/ssl/ssl_tab_helper.h" 73 #include "chrome/browser/ssl/ssl_tab_helper.h"
72 #include "chrome/browser/tab_contents/tab_util.h" 74 #include "chrome/browser/tab_contents/tab_util.h"
73 #include "chrome/browser/toolkit_extra_parts.h" 75 #include "chrome/browser/toolkit_extra_parts.h"
74 #include "chrome/browser/ui/chrome_select_file_policy.h" 76 #include "chrome/browser/ui/chrome_select_file_policy.h"
75 #include "chrome/browser/ui/search/search.h" 77 #include "chrome/browser/ui/search/search.h"
76 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" 78 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
77 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 79 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
80 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
78 #include "chrome/browser/user_style_sheet_watcher.h" 81 #include "chrome/browser/user_style_sheet_watcher.h"
79 #include "chrome/browser/user_style_sheet_watcher_factory.h" 82 #include "chrome/browser/user_style_sheet_watcher_factory.h"
80 #include "chrome/browser/view_type_utils.h" 83 #include "chrome/browser/view_type_utils.h"
81 #include "chrome/common/child_process_logging.h" 84 #include "chrome/common/child_process_logging.h"
82 #include "chrome/common/chrome_constants.h" 85 #include "chrome/common/chrome_constants.h"
83 #include "chrome/common/chrome_paths.h" 86 #include "chrome/common/chrome_paths.h"
84 #include "chrome/common/chrome_switches.h" 87 #include "chrome/common/chrome_switches.h"
85 #include "chrome/common/extensions/extension.h" 88 #include "chrome/common/extensions/extension.h"
86 #include "chrome/common/extensions/extension_process_policy.h" 89 #include "chrome/common/extensions/extension_process_policy.h"
87 #include "chrome/common/extensions/extension_set.h" 90 #include "chrome/common/extensions/extension_set.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 434
432 // Replace the scheme with "chrome-search:". 435 // Replace the scheme with "chrome-search:".
433 url_canon::Replacements<char> replacements; 436 url_canon::Replacements<char> replacements;
434 std::string search_scheme(chrome::kChromeSearchScheme); 437 std::string search_scheme(chrome::kChromeSearchScheme);
435 replacements.SetScheme(search_scheme.data(), 438 replacements.SetScheme(search_scheme.data(),
436 url_parse::Component(0, search_scheme.length())); 439 url_parse::Component(0, search_scheme.length()));
437 effective_url = effective_url.ReplaceComponents(replacements); 440 effective_url = effective_url.ReplaceComponents(replacements);
438 return effective_url; 441 return effective_url;
439 } 442 }
440 443
444 GURL GetEffectiveURLForSignin(const GURL& url) {
445 CHECK(SyncPromoUI::IsWebBasedSigninFlowURL(url));
446 if (url.SchemeIs(chrome::kChromeSigninScheme))
447 return url;
448
449 GURL effective_url(url);
450 // Replace the scheme with "chrome-signin:".
451 url_canon::Replacements<char> replacements;
452 std::string signin_scheme(chrome::kChromeSigninScheme);
453 replacements.SetScheme(signin_scheme.data(),
454 url_parse::Component(0, signin_scheme.length()));
455 effective_url = effective_url.ReplaceComponents(replacements);
456 return effective_url;
457 }
458
441 } // namespace 459 } // namespace
442 460
443 namespace chrome { 461 namespace chrome {
444 462
445 ChromeContentBrowserClient::ChromeContentBrowserClient() { 463 ChromeContentBrowserClient::ChromeContentBrowserClient() {
446 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) 464 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
447 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 465 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
448 } 466 }
449 467
450 ChromeContentBrowserClient::~ChromeContentBrowserClient() { 468 ChromeContentBrowserClient::~ChromeContentBrowserClient() {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 content::BrowserContext* browser_context, const GURL& url) { 706 content::BrowserContext* browser_context, const GURL& url) {
689 Profile* profile = Profile::FromBrowserContext(browser_context); 707 Profile* profile = Profile::FromBrowserContext(browser_context);
690 if (!profile) 708 if (!profile)
691 return url; 709 return url;
692 710
693 // If the input |url| should be assigned to the Instant renderer, make its 711 // If the input |url| should be assigned to the Instant renderer, make its
694 // effective URL distinct from other URLs on the search provider's domain. 712 // effective URL distinct from other URLs on the search provider's domain.
695 if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile)) 713 if (chrome::search::ShouldAssignURLToInstantRenderer(url, profile))
696 return GetEffectiveURLForInstant(url, profile); 714 return GetEffectiveURLForInstant(url, profile);
697 715
716 if (SyncPromoUI::IsWebBasedSigninFlowURL(url))
Charlie Reis 2013/02/28 19:19:46 Please add a comment similar to the one for Instan
tim (not reviewing) 2013/03/01 01:53:57 Done.
717 return GetEffectiveURLForSignin(url);
718
698 // If the input |url| is part of an installed app, the effective URL is an 719 // If the input |url| is part of an installed app, the effective URL is an
699 // extension URL with the ID of that extension as the host. This has the 720 // extension URL with the ID of that extension as the host. This has the
700 // effect of grouping apps together in a common SiteInstance. 721 // effect of grouping apps together in a common SiteInstance.
701 ExtensionService* extension_service = 722 ExtensionService* extension_service =
702 extensions::ExtensionSystem::Get(profile)->extension_service(); 723 extensions::ExtensionSystem::Get(profile)->extension_service();
703 if (!extension_service) 724 if (!extension_service)
704 return url; 725 return url;
705 726
706 const Extension* extension = extension_service->extensions()-> 727 const Extension* extension = extension_service->extensions()->
707 GetHostedAppByURL(ExtensionURLInfo(url)); 728 GetHostedAppByURL(ExtensionURLInfo(url));
(...skipping 17 matching lines...) Expand all
725 // URLs for hosted apps (apart from bookmark apps) should have an extension 746 // URLs for hosted apps (apart from bookmark apps) should have an extension
726 // scheme by now. 747 // scheme by now.
727 748
728 Profile* profile = Profile::FromBrowserContext(browser_context); 749 Profile* profile = Profile::FromBrowserContext(browser_context);
729 if (!profile) 750 if (!profile)
730 return false; 751 return false;
731 752
732 if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile)) 753 if (chrome::search::ShouldAssignURLToInstantRenderer(effective_url, profile))
733 return true; 754 return true;
734 755
756 if (SyncPromoUI::IsWebBasedSigninFlowURL(effective_url))
757 return true;
758
735 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) 759 if (!effective_url.SchemeIs(extensions::kExtensionScheme))
736 return false; 760 return false;
737 761
738 ExtensionService* extension_service = 762 ExtensionService* extension_service =
739 extensions::ExtensionSystem::Get(profile)->extension_service(); 763 extensions::ExtensionSystem::Get(profile)->extension_service();
740 if (!extension_service) 764 if (!extension_service)
741 return false; 765 return false;
742 766
743 const Extension* extension = extension_service->extensions()-> 767 const Extension* extension = extension_service->extensions()->
744 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); 768 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // share any host. 846 // share any host.
823 if (!profile) 847 if (!profile)
824 return true; 848 return true;
825 849
826 InstantService* instant_service = 850 InstantService* instant_service =
827 InstantServiceFactory::GetForProfile(profile); 851 InstantServiceFactory::GetForProfile(profile);
828 if (instant_service && 852 if (instant_service &&
829 instant_service->IsInstantProcess(process_host->GetID())) 853 instant_service->IsInstantProcess(process_host->GetID()))
830 return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile); 854 return chrome::search::ShouldAssignURLToInstantRenderer(site_url, profile);
831 855
856 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
857 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID()))
858 return SyncPromoUI::IsWebBasedSigninFlowURL(site_url);
859
832 ExtensionService* service = 860 ExtensionService* service =
833 extensions::ExtensionSystem::Get(profile)->extension_service(); 861 extensions::ExtensionSystem::Get(profile)->extension_service();
834 extensions::ProcessMap* process_map = service->process_map(); 862 extensions::ProcessMap* process_map = service->process_map();
835 863
836 // Don't allow the Task Manager to share a process with anything else. 864 // Don't allow the Task Manager to share a process with anything else.
837 // Otherwise it can affect the renderers it is observing. 865 // Otherwise it can affect the renderers it is observing.
838 // Note: we could create another RenderProcessHostPrivilege bucket for 866 // Note: we could create another RenderProcessHostPrivilege bucket for
839 // this to allow multiple chrome://tasks instances to share, but that's 867 // this to allow multiple chrome://tasks instances to share, but that's
840 // a very unlikely case without serious consequences. 868 // a very unlikely case without serious consequences.
841 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) 869 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin())
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // Remember the ID of the Instant process to signal the renderer process 946 // Remember the ID of the Instant process to signal the renderer process
919 // on startup in |AppendExtraCommandLineSwitches| below. 947 // on startup in |AppendExtraCommandLineSwitches| below.
920 if (chrome::search::ShouldAssignURLToInstantRenderer( 948 if (chrome::search::ShouldAssignURLToInstantRenderer(
921 site_instance->GetSiteURL(), profile)) { 949 site_instance->GetSiteURL(), profile)) {
922 InstantService* instant_service = 950 InstantService* instant_service =
923 InstantServiceFactory::GetForProfile(profile); 951 InstantServiceFactory::GetForProfile(profile);
924 if (instant_service) 952 if (instant_service)
925 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); 953 instant_service->AddInstantProcess(site_instance->GetProcess()->GetID());
926 } 954 }
927 955
956 if (SyncPromoUI::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
Charlie Reis 2013/02/28 19:19:46 Can you add a comment here saying that we only exp
tim (not reviewing) 2013/03/01 01:53:57 Done.
957 SigninManager* signin_manager =
958 SigninManagerFactory::GetForProfile(profile);
959 if (signin_manager)
960 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
961 }
962
928 ExtensionService* service = 963 ExtensionService* service =
929 extensions::ExtensionSystem::Get(profile)->extension_service(); 964 extensions::ExtensionSystem::Get(profile)->extension_service();
930 if (!service) 965 if (!service)
931 return; 966 return;
932 967
933 const Extension* extension = 968 const Extension* extension =
934 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( 969 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
935 site_instance->GetSiteURL())); 970 site_instance->GetSiteURL()));
936 if (!extension) 971 if (!extension)
937 return; 972 return;
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 io_thread_application_locale_ = locale; 2126 io_thread_application_locale_ = locale;
2092 } 2127 }
2093 2128
2094 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( 2129 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
2095 const std::string& locale) { 2130 const std::string& locale) {
2096 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2097 io_thread_application_locale_ = locale; 2132 io_thread_application_locale_ = locale;
2098 } 2133 }
2099 2134
2100 } // namespace chrome 2135 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/signin/signin_manager.h » ('j') | chrome/browser/signin/signin_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698