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

Side by Side Diff: chrome/browser/signin/signin_manager.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: 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/signin/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/sync/sync_prefs.h" 30 #include "chrome/browser/sync/sync_prefs.h"
31 #include "chrome/browser/ui/global_error/global_error_service.h" 31 #include "chrome/browser/ui/global_error/global_error_service.h"
32 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 32 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
33 #include "chrome/browser/ui/host_desktop.h" 33 #include "chrome/browser/ui/host_desktop.h"
34 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" 34 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h"
35 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
36 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/render_process_host.h"
40 #include "google_apis/gaia/gaia_auth_fetcher.h" 41 #include "google_apis/gaia/gaia_auth_fetcher.h"
41 #include "google_apis/gaia/gaia_auth_util.h" 42 #include "google_apis/gaia/gaia_auth_util.h"
42 #include "google_apis/gaia/gaia_constants.h" 43 #include "google_apis/gaia/gaia_constants.h"
43 #include "google_apis/gaia/gaia_urls.h" 44 #include "google_apis/gaia/gaia_urls.h"
44 #include "net/cookies/cookie_monster.h" 45 #include "net/cookies/cookie_monster.h"
45 #include "net/url_request/url_request_context.h" 46 #include "net/url_request/url_request_context.h"
46 #include "net/url_request/url_request_context_getter.h" 47 #include "net/url_request/url_request_context_getter.h"
47 #include "third_party/icu/public/i18n/unicode/regex.h" 48 #include "third_party/icu/public/i18n/unicode/regex.h"
48 49
49 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) 50 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS)
50 #include "chrome/browser/policy/user_policy_signin_service.h" 51 #include "chrome/browser/policy/user_policy_signin_service.h"
51 #include "chrome/browser/policy/user_policy_signin_service_factory.h" 52 #include "chrome/browser/policy/user_policy_signin_service_factory.h"
52 #endif 53 #endif
53 54
54 using namespace signin_internals_util; 55 using namespace signin_internals_util;
55 56
56 using content::BrowserThread; 57 using content::BrowserThread;
57 58
58 namespace { 59 namespace {
59 60
60 const char kGetInfoDisplayEmailKey[] = "displayEmail"; 61 const char kGetInfoDisplayEmailKey[] = "displayEmail";
61 const char kGetInfoEmailKey[] = "email"; 62 const char kGetInfoEmailKey[] = "email";
62 63
63 const char kGoogleAccountsUrl[] = "https://accounts.google.com"; 64 const char kGoogleAccountsUrl[] = "https://accounts.google.com";
64 65
66 const int kInvalidProcessId = -1;
67
65 } // namespace 68 } // namespace
66 69
67 // This class fetches GAIA cookie on IO thread on behalf of SigninManager which 70 // This class fetches GAIA cookie on IO thread on behalf of SigninManager which
68 // only lives on the UI thread. 71 // only lives on the UI thread.
69 class SigninManagerCookieHelper 72 class SigninManagerCookieHelper
70 : public base::RefCountedThreadSafe<SigninManagerCookieHelper> { 73 : public base::RefCountedThreadSafe<SigninManagerCookieHelper> {
71 public: 74 public:
72 explicit SigninManagerCookieHelper( 75 explicit SigninManagerCookieHelper(
73 net::URLRequestContextGetter* request_context_getter); 76 net::URLRequestContextGetter* request_context_getter);
74 77
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 UBool match = matcher.matches(status); 195 UBool match = matcher.matches(status);
193 DCHECK(U_SUCCESS(status)); 196 DCHECK(U_SUCCESS(status));
194 return !!match; // !! == convert from UBool to bool. 197 return !!match; // !! == convert from UBool to bool.
195 } 198 }
196 199
197 SigninManager::SigninManager() 200 SigninManager::SigninManager()
198 : profile_(NULL), 201 : profile_(NULL),
199 prohibit_signout_(false), 202 prohibit_signout_(false),
200 had_two_factor_error_(false), 203 had_two_factor_error_(false),
201 type_(SIGNIN_TYPE_NONE), 204 type_(SIGNIN_TYPE_NONE),
202 weak_pointer_factory_(this) { 205 weak_pointer_factory_(this),
206 signin_process_id_(kInvalidProcessId) {
207 }
208
209 void SigninManager::SetSigninProcess(
210 const content::RenderProcessHost* process) {
211 CHECK_EQ(signin_process_id_, kInvalidProcessId);
Roger Tawa OOO till Jul 10th 2013/02/28 16:57:34 Hit this DCHECK while trying to repro crbug.com/17
212 signin_process_id_ = process->GetID();
213 registrar_.Add(this,
214 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
215 content::Source<content::RenderProcessHost>(process));
Charlie Reis 2013/02/28 17:33:02 You can look up the RPH from the ID, using RenderP
216 }
217
218 bool SigninManager::IsSigninProcess(
219 const content::RenderProcessHost* process) const {
220 return process->GetID() == signin_process_id_;
203 } 221 }
204 222
205 SigninManager::~SigninManager() { 223 SigninManager::~SigninManager() {
206 DCHECK(!signin_global_error_.get()) << 224 DCHECK(!signin_global_error_.get()) <<
207 "SigninManager::Initialize called but not SigninManager::Shutdown"; 225 "SigninManager::Initialize called but not SigninManager::Shutdown";
208 } 226 }
209 227
210 void SigninManager::Initialize(Profile* profile) { 228 void SigninManager::Initialize(Profile* profile) {
211 // Should never call Initialize() twice. 229 // Should never call Initialize() twice.
212 DCHECK(!IsInitialized()); 230 DCHECK(!IsInitialized());
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 if (tok_details->service() == 896 if (tok_details->service() ==
879 GaiaConstants::kGaiaOAuth2LoginRefreshToken) { 897 GaiaConstants::kGaiaOAuth2LoginRefreshToken) {
880 ubertoken_fetcher_.reset(new UbertokenFetcher(profile_, this)); 898 ubertoken_fetcher_.reset(new UbertokenFetcher(profile_, this));
881 ubertoken_fetcher_->StartFetchingToken(); 899 ubertoken_fetcher_->StartFetchingToken();
882 900
883 // We only want to do this once per sign-in. 901 // We only want to do this once per sign-in.
884 CleanupNotificationRegistration(); 902 CleanupNotificationRegistration();
885 } 903 }
886 break; 904 break;
887 } 905 }
906 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
907 DCHECK_EQ(signin_process_id_,
908 content::Source<content::RenderProcessHost>(source)->GetID());
909 signin_process_id_ = kInvalidProcessId;
910 registrar_.Remove(this,
911 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
912 source);
913 }
Roger Tawa OOO till Jul 10th 2013/02/28 15:17:34 missing break; statement
888 #endif 914 #endif
889 default: 915 default:
890 NOTREACHED(); 916 NOTREACHED();
891 } 917 }
892 } 918 }
893 919
894 void SigninManager::Shutdown() { 920 void SigninManager::Shutdown() {
895 if (signin_global_error_.get()) { 921 if (signin_global_error_.get()) {
896 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 922 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
897 signin_global_error_.get()); 923 signin_global_error_.get());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 NotifySigninValueChanged(field, value)); 960 NotifySigninValueChanged(field, value));
935 } 961 }
936 962
937 void SigninManager::NotifyDiagnosticsObservers( 963 void SigninManager::NotifyDiagnosticsObservers(
938 const TimedSigninStatusField& field, 964 const TimedSigninStatusField& field,
939 const std::string& value) { 965 const std::string& value) {
940 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 966 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
941 signin_diagnostics_observers_, 967 signin_diagnostics_observers_,
942 NotifySigninValueChanged(field, value)); 968 NotifySigninValueChanged(field, value));
943 } 969 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698