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/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | |
13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/api/infobars/one_click_signin_infobar_delegate.h" | 16 #include "chrome/browser/api/infobars/one_click_signin_infobar_delegate.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
19 #include "chrome/browser/google/google_util.h" | |
18 #include "chrome/browser/infobars/infobar_tab_helper.h" | 20 #include "chrome/browser/infobars/infobar_tab_helper.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
21 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_info_cache.h" | 24 #include "chrome/browser/profiles/profile_info_cache.h" |
23 #include "chrome/browser/profiles/profile_io_data.h" | 25 #include "chrome/browser/profiles/profile_io_data.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/signin/signin_manager.h" | 27 #include "chrome/browser/signin/signin_manager.h" |
26 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
27 #include "chrome/browser/signin/signin_names_io_thread.h" | 29 #include "chrome/browser/signin/signin_names_io_thread.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
45 #include "content/public/browser/web_contents_view.h" | 47 #include "content/public/browser/web_contents_view.h" |
46 #include "content/public/common/frame_navigate_params.h" | 48 #include "content/public/common/frame_navigate_params.h" |
47 #include "content/public/common/page_transition_types.h" | 49 #include "content/public/common/page_transition_types.h" |
48 #include "content/public/common/password_form.h" | 50 #include "content/public/common/password_form.h" |
49 #include "google_apis/gaia/gaia_auth_util.h" | 51 #include "google_apis/gaia/gaia_auth_util.h" |
50 #include "google_apis/gaia/gaia_urls.h" | 52 #include "google_apis/gaia/gaia_urls.h" |
51 #include "googleurl/src/gurl.h" | 53 #include "googleurl/src/gurl.h" |
52 #include "grit/chromium_strings.h" | 54 #include "grit/chromium_strings.h" |
53 #include "grit/generated_resources.h" | 55 #include "grit/generated_resources.h" |
54 #include "grit/theme_resources.h" | 56 #include "grit/theme_resources.h" |
55 #include "net/base/escape.h" | |
56 #include "net/cookies/cookie_monster.h" | 57 #include "net/cookies/cookie_monster.h" |
57 #include "net/url_request/url_request.h" | 58 #include "net/url_request/url_request.h" |
58 #include "ui/base/l10n/l10n_util.h" | 59 #include "ui/base/l10n/l10n_util.h" |
59 #include "ui/base/resource/resource_bundle.h" | 60 #include "ui/base/resource/resource_bundle.h" |
60 | 61 |
61 #include <functional> | 62 #include <functional> |
62 | 63 |
63 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper) | 64 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper) |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
67 // Set to true if this chrome instance is in the blue-button-on-white-bar | 68 // Set to true if this chrome instance is in the blue-button-on-white-bar |
68 // experimental group. | 69 // experimental group. |
69 bool use_blue_on_white = false; | 70 bool use_blue_on_white = false; |
70 | 71 |
72 // Add a specific email to the list of emails rejected for one-click | |
73 // sign-in, for this profile. | |
74 void AddEmailToOneClickRejectedList(Profile* profile, | |
75 const std::string& email) { | |
76 PrefService* pref_service = profile->GetPrefs(); | |
77 ListPrefUpdate updater(pref_service, | |
78 prefs::kReverseAutologinRejectedEmailList); | |
79 updater->AppendIfNotPresent(new base::StringValue(email)); | |
80 } | |
81 | |
71 // Start syncing with the given user information. | 82 // Start syncing with the given user information. |
72 void StartSync(Browser* browser, | 83 void StartSync(Browser* browser, |
73 OneClickSigninHelper::AutoAccept auto_accept, | 84 OneClickSigninHelper::AutoAccept auto_accept, |
74 const std::string& session_index, | 85 const std::string& session_index, |
75 const std::string& email, | 86 const std::string& email, |
76 const std::string& password, | 87 const std::string& password, |
77 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 88 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
78 // The starter deletes itself once its done. | 89 // The starter deletes itself once its done. |
79 new OneClickSigninSyncStarter(browser, session_index, email, password, | 90 new OneClickSigninSyncStarter(browser, session_index, email, password, |
80 start_mode); | 91 start_mode); |
81 | 92 |
82 int action = one_click_signin::HISTOGRAM_MAX; | 93 int action = one_click_signin::HISTOGRAM_MAX; |
83 switch (auto_accept) { | 94 switch (auto_accept) { |
84 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 95 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
85 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; | 96 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; |
86 break; | 97 break; |
87 case OneClickSigninHelper::AUTO_ACCEPT: | 98 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
88 action = | 99 action = |
89 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 100 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
90 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : | 101 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : |
91 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 102 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
92 break; | 103 break; |
93 case OneClickSigninHelper::NO_AUTO_ACCEPT: | 104 case OneClickSigninHelper::AUTO_ACCEPT_NONE: |
94 action = | 105 action = |
95 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 106 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
96 one_click_signin::HISTOGRAM_WITH_DEFAULTS : | 107 one_click_signin::HISTOGRAM_WITH_DEFAULTS : |
97 one_click_signin::HISTOGRAM_WITH_ADVANCED; | 108 one_click_signin::HISTOGRAM_WITH_ADVANCED; |
98 break; | 109 break; |
99 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: | 110 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: |
100 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 111 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
101 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 112 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
102 break; | 113 break; |
103 default: | 114 default: |
104 NOTREACHED() << "Invalid auto_accept: " << auto_accept; | 115 NOTREACHED() << "Invalid auto_accept: " << auto_accept; |
105 break; | 116 break; |
106 } | 117 } |
107 | 118 |
108 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 119 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
109 one_click_signin::HISTOGRAM_MAX); | 120 one_click_signin::HISTOGRAM_MAX); |
110 } | 121 } |
111 | 122 |
112 // Determines the source of the sign in. Its either one of the known sign in | 123 // Determines the source of the sign in and the continue URL. Its either one |
113 // access point (first run, NTP, menu, settings) or its an implicit sign in | 124 // of the known sign in access point (first run, NTP, menu, settings) or its |
114 // via another Google property. In the former case, "service" is also | 125 // an implicit sign in via another Google property. In the former case, |
115 // checked to make sure its "chromiumsync". | 126 // "service" is also checked to make sure its "chromiumsync". |
116 SyncPromoUI::Source GetSigninSource(const GURL& url) { | 127 SyncPromoUI::Source GetSigninSource(const GURL& url, GURL* continue_url) { |
117 std::string value; | 128 std::string value; |
118 chrome_common_net::GetValueForKeyInQuery(url, "service", &value); | 129 chrome_common_net::GetValueForKeyInQuery(url, "service", &value); |
119 bool is_explicit_signin = value == "chromiumsync"; | 130 bool is_explicit_signin = value == "chromiumsync"; |
tim (not reviewing)
2012/12/14 19:48:29
We do this here, but then at the GetSigninSource c
Roger Tawa OOO till Jul 10th
2012/12/16 03:03:46
This function is really the "definitive" check for
| |
120 | 131 |
121 chrome_common_net::GetValueForKeyInQuery(url, "continue", &value); | 132 // Find the final continue URL for this sign in. In some cases, Gaia can |
122 SyncPromoUI::Source source = | 133 // continue to itself, with the original continue URL buried under a couple |
123 SyncPromoUI::GetSourceForSyncPromoURL(GURL( | 134 // of layers of indirection. Peel those layers away. |
124 net::UnescapeURLComponent(value, | 135 GURL local_continue_url = url; |
125 net::UnescapeRule::URL_SPECIAL_CHARS))); | 136 do { |
137 local_continue_url = | |
138 SyncPromoUI::GetNextPageURLForSyncPromoURL(local_continue_url); | |
139 } while (gaia::IsGaiaSignonRealm(local_continue_url.GetOrigin())); | |
126 | 140 |
127 if (!is_explicit_signin) | 141 if (continue_url && local_continue_url.is_valid()) { |
128 source = SyncPromoUI::SOURCE_UNKNOWN; | 142 DCHECK(!continue_url->is_valid() || *continue_url == local_continue_url); |
143 *continue_url = local_continue_url; | |
144 } | |
129 | 145 |
130 return source; | 146 return is_explicit_signin ? |
147 SyncPromoUI::GetSourceForSyncPromoURL(local_continue_url) : | |
148 SyncPromoUI::SOURCE_UNKNOWN; | |
149 } | |
150 | |
151 // Returns true if |url| is a valid URL that can occur during the sign in | |
152 // process. Valid URLs are of the form: | |
153 // | |
154 // https://accounts.google.{TLD}/... | |
155 // https://accounts.youtube.com/... | |
156 // https://accounts.blogger.com/... | |
157 // | |
158 // All special headers used by one click sign in occur on | |
159 // https://accounts.google.com URLs. However, the sign process may redirect | |
tim (not reviewing)
2012/12/14 19:48:29
typo - However, the signin* process may redirect
Roger Tawa OOO till Jul 10th
2012/12/16 03:03:46
Done.
| |
160 // to intermediate Gaia URLs that do not end with .com. For example, an account | |
161 // that uses SMS 2-factor outside the US may redirect to country specific URLs. | |
162 // | |
163 // The sign in process may also redirect to youtube and blogger account URLs | |
164 // so that Gaia acts as a single signon service. | |
165 bool IsValidGaiaSigninRedirectOrResponseURL(const GURL& url) { | |
166 std::string hostname = url.host(); | |
167 if (google_util::IsGoogleHostname(hostname, google_util::ALLOW_SUBDOMAIN)) { | |
168 // Also using IsGaiaSignonRealm() to handle overriding with command line. | |
169 return gaia::IsGaiaSignonRealm(url.GetOrigin()) || | |
170 StartsWithASCII(hostname, "accounts.", false); | |
171 } | |
172 | |
173 GURL origin = url.GetOrigin(); | |
174 if (origin == GURL("https://accounts.youtube.com") || | |
175 origin == GURL("https://accounts.blogger.com")) | |
176 return true; | |
177 | |
178 return false; | |
131 } | 179 } |
132 | 180 |
133 // This class is associated as user data with a given URLRequest object, in | 181 // This class is associated as user data with a given URLRequest object, in |
134 // order to pass information from one response to another during the process | 182 // order to pass information from one response to another during the process |
135 // of signing the user into their Gaia account. This class is only meant | 183 // of signing the user into their Gaia account. This class is only meant |
136 // to be used from the IO thread. | 184 // to be used from the IO thread. |
137 class OneClickSigninRequestUserData : public base::SupportsUserData::Data { | 185 class OneClickSigninRequestUserData : public base::SupportsUserData::Data { |
138 public: | 186 public: |
139 const std::string& email() const { return email_; } | 187 const std::string& email() const { return email_; } |
140 | 188 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 // ConfirmInfoBarDelegate overrides. | 250 // ConfirmInfoBarDelegate overrides. |
203 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 251 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
204 virtual bool Accept() OVERRIDE; | 252 virtual bool Accept() OVERRIDE; |
205 virtual bool Cancel() OVERRIDE; | 253 virtual bool Cancel() OVERRIDE; |
206 virtual string16 GetLinkText() const OVERRIDE; | 254 virtual string16 GetLinkText() const OVERRIDE; |
207 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 255 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
208 | 256 |
209 // OneClickSigninInfoBarDelegate overrides. | 257 // OneClickSigninInfoBarDelegate overrides. |
210 virtual void GetAlternateColors(AlternateColors* alt_colors) OVERRIDE; | 258 virtual void GetAlternateColors(AlternateColors* alt_colors) OVERRIDE; |
211 | 259 |
212 // Add a specific email to the list of emails rejected for one-click | |
213 // sign-in, for this profile. | |
214 void AddEmailToOneClickRejectedList(const std::string& email); | |
215 | |
216 // Record the specified action in the histogram for one-click sign in. | 260 // Record the specified action in the histogram for one-click sign in. |
217 void RecordHistogramAction(int action); | 261 void RecordHistogramAction(int action); |
218 | 262 |
219 // Information about the account that has just logged in. | 263 // Information about the account that has just logged in. |
220 std::string session_index_; | 264 std::string session_index_; |
221 std::string email_; | 265 std::string email_; |
222 std::string password_; | 266 std::string password_; |
223 | 267 |
224 // Whether any UI controls in the infobar were pressed or not. | 268 // Whether any UI controls in the infobar were pressed or not. |
225 bool button_pressed_; | 269 bool button_pressed_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 } | 313 } |
270 | 314 |
271 string16 OneClickInfoBarDelegateImpl::GetButtonLabel( | 315 string16 OneClickInfoBarDelegateImpl::GetButtonLabel( |
272 InfoBarButton button) const { | 316 InfoBarButton button) const { |
273 return l10n_util::GetStringUTF16( | 317 return l10n_util::GetStringUTF16( |
274 (button == BUTTON_OK) ? IDS_ONE_CLICK_SIGNIN_INFOBAR_OK_BUTTON | 318 (button == BUTTON_OK) ? IDS_ONE_CLICK_SIGNIN_INFOBAR_OK_BUTTON |
275 : IDS_ONE_CLICK_SIGNIN_INFOBAR_CANCEL_BUTTON); | 319 : IDS_ONE_CLICK_SIGNIN_INFOBAR_CANCEL_BUTTON); |
276 } | 320 } |
277 | 321 |
278 bool OneClickInfoBarDelegateImpl::Accept() { | 322 bool OneClickInfoBarDelegateImpl::Accept() { |
323 content::WebContents* web_contents = owner()->GetWebContents(); | |
324 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
325 Profile* profile = Profile::FromBrowserContext( | |
326 web_contents->GetBrowserContext()); | |
327 | |
279 // User has accepted one-click sign-in for this account. Never ask again for | 328 // User has accepted one-click sign-in for this account. Never ask again for |
280 // this profile. | 329 // this profile. |
281 Profile* profile = Profile::FromBrowserContext( | |
282 owner()->GetWebContents()->GetBrowserContext()); | |
283 SigninManager::DisableOneClickSignIn(profile); | 330 SigninManager::DisableOneClickSignIn(profile); |
284 | |
285 content::WebContents* web_contents = owner()->GetWebContents(); | |
286 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
287 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); | 331 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); |
288 chrome::FindBrowserWithWebContents(web_contents)->window()-> | 332 chrome::FindBrowserWithWebContents(web_contents)->window()-> |
289 ShowOneClickSigninBubble(base::Bind(&StartSync, browser, | 333 ShowOneClickSigninBubble( |
290 OneClickSigninHelper::NO_AUTO_ACCEPT, | 334 base::Bind(&StartSync, browser, |
291 session_index_, email_, password_)); | 335 OneClickSigninHelper::AUTO_ACCEPT_NONE, session_index_, |
336 email_, password_)); | |
292 button_pressed_ = true; | 337 button_pressed_ = true; |
293 return true; | 338 return true; |
294 } | 339 } |
295 | 340 |
296 bool OneClickInfoBarDelegateImpl::Cancel() { | 341 bool OneClickInfoBarDelegateImpl::Cancel() { |
297 AddEmailToOneClickRejectedList(email_); | 342 AddEmailToOneClickRejectedList(Profile::FromBrowserContext( |
343 owner()->GetWebContents()->GetBrowserContext()), email_); | |
298 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); | 344 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); |
299 button_pressed_ = true; | 345 button_pressed_ = true; |
300 return true; | 346 return true; |
301 } | 347 } |
302 | 348 |
303 string16 OneClickInfoBarDelegateImpl::GetLinkText() const { | 349 string16 OneClickInfoBarDelegateImpl::GetLinkText() const { |
304 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 350 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
305 } | 351 } |
306 | 352 |
307 bool OneClickInfoBarDelegateImpl::LinkClicked( | 353 bool OneClickInfoBarDelegateImpl::LinkClicked( |
(...skipping 14 matching lines...) Expand all Loading... | |
322 alt_colors->infobar_top_color = SK_ColorWHITE; | 368 alt_colors->infobar_top_color = SK_ColorWHITE; |
323 alt_colors->button_text_color = SK_ColorWHITE; | 369 alt_colors->button_text_color = SK_ColorWHITE; |
324 alt_colors->button_background_color = SkColorSetRGB(71, 135, 237); | 370 alt_colors->button_background_color = SkColorSetRGB(71, 135, 237); |
325 alt_colors->button_border_color = SkColorSetRGB(48, 121, 237); | 371 alt_colors->button_border_color = SkColorSetRGB(48, 121, 237); |
326 return; | 372 return; |
327 } | 373 } |
328 | 374 |
329 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); | 375 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); |
330 } | 376 } |
331 | 377 |
332 void OneClickInfoBarDelegateImpl::AddEmailToOneClickRejectedList( | |
333 const std::string& email) { | |
334 Profile* profile = Profile::FromBrowserContext( | |
335 owner()->GetWebContents()->GetBrowserContext()); | |
336 PrefService* pref_service = profile->GetPrefs(); | |
337 ListPrefUpdate updater(pref_service, | |
338 prefs::kReverseAutologinRejectedEmailList); | |
339 updater->AppendIfNotPresent(new base::StringValue(email)); | |
340 } | |
341 | |
342 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { | 378 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { |
343 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 379 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
344 one_click_signin::HISTOGRAM_MAX); | 380 one_click_signin::HISTOGRAM_MAX); |
345 } | 381 } |
346 | 382 |
347 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) | 383 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
348 : content::WebContentsObserver(web_contents), | 384 : content::WebContentsObserver(web_contents), |
349 auto_accept_(NO_AUTO_ACCEPT), | 385 auto_accept_(AUTO_ACCEPT_NONE), |
350 source_(SyncPromoUI::SOURCE_UNKNOWN) { | 386 source_(SyncPromoUI::SOURCE_UNKNOWN) { |
351 } | 387 } |
352 | 388 |
353 OneClickSigninHelper::~OneClickSigninHelper() { | 389 OneClickSigninHelper::~OneClickSigninHelper() { |
354 } | 390 } |
355 | 391 |
356 // static | 392 // static |
357 void OneClickSigninHelper::AssociateWithRequestForTesting( | 393 void OneClickSigninHelper::AssociateWithRequestForTesting( |
358 base::SupportsUserData* request, | 394 base::SupportsUserData* request, |
359 const std::string& email) { | 395 const std::string& email) { |
360 OneClickSigninRequestUserData::AssociateWithRequest(request, email); | 396 OneClickSigninRequestUserData::AssociateWithRequest(request, email); |
361 } | 397 } |
362 | 398 |
363 // static | 399 // static |
364 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, | 400 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, |
365 CanOfferFor can_offer_for, | 401 CanOfferFor can_offer_for, |
366 const std::string& email, | 402 const std::string& email, |
367 int* error_message_id) { | 403 int* error_message_id) { |
368 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 404 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
405 VLOG(1) << "OneClickSigninHelper::CanOffer"; | |
369 | 406 |
370 if (error_message_id) | 407 if (error_message_id) |
371 *error_message_id = 0; | 408 *error_message_id = 0; |
372 | 409 |
373 if (!web_contents) | 410 if (!web_contents) |
374 return false; | 411 return false; |
375 | 412 |
376 if (web_contents->GetBrowserContext()->IsOffTheRecord()) | 413 if (web_contents->GetBrowserContext()->IsOffTheRecord()) |
377 return false; | 414 return false; |
378 | 415 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 ProfileSyncService* service = | 488 ProfileSyncService* service = |
452 ProfileSyncServiceFactory::GetForProfile(profile); | 489 ProfileSyncServiceFactory::GetForProfile(profile); |
453 if (!service) | 490 if (!service) |
454 return false; | 491 return false; |
455 | 492 |
456 if (service->FirstSetupInProgress()) | 493 if (service->FirstSetupInProgress()) |
457 return false; | 494 return false; |
458 } | 495 } |
459 } | 496 } |
460 | 497 |
498 VLOG(1) << "OneClickSigninHelper::CanOffer: yes we can"; | |
461 return true; | 499 return true; |
462 } | 500 } |
463 | 501 |
464 // static | 502 // static |
465 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( | 503 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( |
466 net::URLRequest* request, | 504 net::URLRequest* request, |
467 ProfileIOData* io_data) { | 505 ProfileIOData* io_data) { |
468 return CanOfferOnIOThreadImpl(request->url(), request->referrer(), | 506 return CanOfferOnIOThreadImpl(request->url(), request->referrer(), |
469 request, io_data); | 507 request, io_data); |
470 } | 508 } |
471 | 509 |
472 // static | 510 // static |
473 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( | 511 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( |
474 const GURL& url, | 512 const GURL& url, |
475 const std::string& referrer, | 513 const std::string& referrer, |
476 base::SupportsUserData* request, | 514 base::SupportsUserData* request, |
477 ProfileIOData* io_data) { | 515 ProfileIOData* io_data) { |
478 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) | 516 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) |
479 return IGNORE_REQUEST; | 517 return IGNORE_REQUEST; |
480 | 518 |
481 if (!io_data) | 519 if (!io_data) |
482 return DONT_OFFER; | 520 return DONT_OFFER; |
483 | 521 |
484 if (!SyncPromoUI::UseWebBasedSigninFlow()) | 522 if (!SyncPromoUI::UseWebBasedSigninFlow()) |
485 return DONT_OFFER; | 523 return DONT_OFFER; |
486 | 524 |
487 // Don't offer if the source is known, as that means it's an explicit sign | |
488 // in request. | |
489 if (GetSigninSource(url) != SyncPromoUI::SOURCE_UNKNOWN || | |
490 GetSigninSource(GURL(referrer)) != SyncPromoUI::SOURCE_UNKNOWN) { | |
491 return DONT_OFFER; | |
492 } | |
493 | |
494 if (!ProfileSyncService::IsSyncEnabled()) | 525 if (!ProfileSyncService::IsSyncEnabled()) |
495 return DONT_OFFER; | 526 return DONT_OFFER; |
496 | 527 |
497 // Check for incognito before other parts of the io_data, since those | 528 // Check for incognito before other parts of the io_data, since those |
498 // members may not be initalized. | 529 // members may not be initalized. |
499 if (io_data->is_incognito()) | 530 if (io_data->is_incognito()) |
500 return DONT_OFFER; | 531 return DONT_OFFER; |
501 | 532 |
502 if (!io_data->reverse_autologin_enabled()->GetValue()) | 533 if (!io_data->reverse_autologin_enabled()->GetValue()) |
503 return DONT_OFFER; | 534 return DONT_OFFER; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request, | 592 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request, |
562 int child_id, | 593 int child_id, |
563 int route_id) { | 594 int route_id) { |
564 std::string google_chrome_signin_value; | 595 std::string google_chrome_signin_value; |
565 std::string google_accounts_signin_value; | 596 std::string google_accounts_signin_value; |
566 request->GetResponseHeaderByName("Google-Chrome-SignIn", | 597 request->GetResponseHeaderByName("Google-Chrome-SignIn", |
567 &google_chrome_signin_value); | 598 &google_chrome_signin_value); |
568 request->GetResponseHeaderByName("Google-Accounts-SignIn", | 599 request->GetResponseHeaderByName("Google-Accounts-SignIn", |
569 &google_accounts_signin_value); | 600 &google_accounts_signin_value); |
570 | 601 |
571 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" | 602 if (!google_accounts_signin_value.empty() || |
572 << " g-a-s='" << google_accounts_signin_value << "'" | 603 !google_chrome_signin_value.empty()) { |
573 << " g-c-s='" << google_chrome_signin_value << "'"; | 604 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" |
605 << " g-a-s='" << google_accounts_signin_value << "'" | |
606 << " g-c-s='" << google_chrome_signin_value << "'"; | |
607 } | |
574 | 608 |
575 if (!SyncPromoUI::UseWebBasedSigninFlow() && | 609 if (!SyncPromoUI::UseWebBasedSigninFlow() && |
576 google_accounts_signin_value.empty()) { | 610 google_accounts_signin_value.empty()) { |
577 return; | 611 return; |
578 } | 612 } |
579 | 613 |
580 if (!gaia::IsGaiaSignonRealm(request->original_url().GetOrigin())) | 614 if (!gaia::IsGaiaSignonRealm(request->original_url().GetOrigin())) |
581 return; | 615 return; |
582 | 616 |
583 // Parse Google-Accounts-SignIn. | 617 // Parse Google-Accounts-SignIn. |
(...skipping 12 matching lines...) Expand all Loading... | |
596 session_index = value; | 630 session_index = value; |
597 } | 631 } |
598 } | 632 } |
599 | 633 |
600 // Later in the chain of this request, we'll need to check the email address | 634 // Later in the chain of this request, we'll need to check the email address |
601 // in the IO thread (see CanOfferOnIOThread). So save the email address as | 635 // in the IO thread (see CanOfferOnIOThread). So save the email address as |
602 // user data on the request (only for web-based flow). | 636 // user data on the request (only for web-based flow). |
603 if (SyncPromoUI::UseWebBasedSigninFlow() && !email.empty()) | 637 if (SyncPromoUI::UseWebBasedSigninFlow() && !email.empty()) |
604 OneClickSigninRequestUserData::AssociateWithRequest(request, email); | 638 OneClickSigninRequestUserData::AssociateWithRequest(request, email); |
605 | 639 |
606 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" | 640 if (!email.empty() || !session_index.empty()) { |
607 << " email=" << email | 641 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" |
608 << " sessionindex=" << session_index; | 642 << " email=" << email |
643 << " sessionindex=" << session_index; | |
644 } | |
609 | 645 |
610 // Parse Google-Chrome-SignIn. | 646 // Parse Google-Chrome-SignIn. |
611 AutoAccept auto_accept = NO_AUTO_ACCEPT; | 647 AutoAccept auto_accept = AUTO_ACCEPT_NONE; |
612 SyncPromoUI::Source source = SyncPromoUI::SOURCE_UNKNOWN; | 648 SyncPromoUI::Source source = SyncPromoUI::SOURCE_UNKNOWN; |
649 GURL continue_url; | |
613 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 650 if (SyncPromoUI::UseWebBasedSigninFlow()) { |
614 std::vector<std::string> tokens; | 651 std::vector<std::string> tokens; |
615 base::SplitString(google_chrome_signin_value, ',', &tokens); | 652 base::SplitString(google_chrome_signin_value, ',', &tokens); |
616 for (size_t i = 0; i < tokens.size(); ++i) { | 653 for (size_t i = 0; i < tokens.size(); ++i) { |
617 const std::string& token = tokens[i]; | 654 const std::string& token = tokens[i]; |
618 if (token == "accepted") { | 655 if (token == "accepted") { |
619 auto_accept = AUTO_ACCEPT; | 656 auto_accept = AUTO_ACCEPT_ACCEPTED; |
620 } else if (token == "configure") { | 657 } else if (token == "configure") { |
621 auto_accept = AUTO_ACCEPT_CONFIGURE; | 658 auto_accept = AUTO_ACCEPT_CONFIGURE; |
622 } else if (token == "rejected-for-profile") { | 659 } else if (token == "rejected-for-profile") { |
623 auto_accept = REJECTED_FOR_PROFILE; | 660 auto_accept = AUTO_ACCEPT_REJECTED_FOR_PROFILE; |
624 } | 661 } |
625 } | 662 } |
626 | 663 |
627 // If this is an explicit sign in (i.e., first run, NTP, menu,settings) | 664 // If this is an explicit sign in (i.e., first run, NTP, menu,settings) |
628 // then force the auto accept type to explicit. | 665 // then force the auto accept type to explicit. |
629 source = GetSigninSource(request->original_url()); | 666 source = GetSigninSource(request->original_url(), &continue_url); |
630 if (source == SyncPromoUI::SOURCE_UNKNOWN) | |
631 source = GetSigninSource(GURL(request->referrer())); | |
632 | |
633 if (source != SyncPromoUI::SOURCE_UNKNOWN) | 667 if (source != SyncPromoUI::SOURCE_UNKNOWN) |
634 auto_accept = AUTO_ACCEPT_EXPLICIT; | 668 auto_accept = AUTO_ACCEPT_EXPLICIT; |
635 } | 669 } |
636 | 670 |
637 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" | 671 if (auto_accept != AUTO_ACCEPT_NONE) { |
638 << " auto_accept=" << auto_accept; | 672 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" |
673 << " auto_accept=" << auto_accept; | |
674 } | |
639 | 675 |
640 // If |session_index|, |email|, and |auto_accept| all have their default | 676 // If |session_index|, |email|, |auto_accept|, and |continue_url| all have |
641 // value, don't bother posting a task to the UI thread. It will be a noop | 677 // their default value, don't bother posting a task to the UI thread. |
642 // anyway. | 678 // It will be a noop anyway. |
643 // | 679 // |
644 // The two headers above may (but not always) come in different http requests | 680 // The two headers above may (but not always) come in different http requests |
645 // so a post to the UI thread is still needed if |auto_accept| is not its | 681 // so a post to the UI thread is still needed if |auto_accept| is not its |
646 // default value, but |email| and |session_index| are. | 682 // default value, but |email| and |session_index| are. |
647 if (session_index.empty() && email.empty() && auto_accept == NO_AUTO_ACCEPT) | 683 if (session_index.empty() && email.empty() && |
684 auto_accept == AUTO_ACCEPT_NONE && !continue_url.is_valid()) { | |
648 return; | 685 return; |
686 } | |
649 | 687 |
650 content::BrowserThread::PostTask( | 688 content::BrowserThread::PostTask( |
651 content::BrowserThread::UI, FROM_HERE, | 689 content::BrowserThread::UI, FROM_HERE, |
652 base::Bind(&OneClickSigninHelper::ShowInfoBarUIThread, session_index, | 690 base::Bind(&OneClickSigninHelper::ShowInfoBarUIThread, session_index, |
653 email, auto_accept, source, child_id, route_id)); | 691 email, auto_accept, source, continue_url, child_id, route_id)); |
654 } | 692 } |
655 | 693 |
656 // static | 694 // static |
657 void OneClickSigninHelper::ShowInfoBarUIThread( | 695 void OneClickSigninHelper::ShowInfoBarUIThread( |
658 const std::string& session_index, | 696 const std::string& session_index, |
659 const std::string& email, | 697 const std::string& email, |
660 AutoAccept auto_accept, | 698 AutoAccept auto_accept, |
661 SyncPromoUI::Source source, | 699 SyncPromoUI::Source source, |
700 const GURL& continue_url, | |
662 int child_id, | 701 int child_id, |
663 int route_id) { | 702 int route_id) { |
664 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 703 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
665 | 704 |
666 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, | 705 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, |
667 route_id); | 706 route_id); |
668 | 707 |
669 // TODO(mathp): The appearance of this infobar should be tested using a | 708 // TODO(mathp): The appearance of this infobar should be tested using a |
670 // browser_test. | 709 // browser_test. |
671 OneClickSigninHelper* helper = | 710 OneClickSigninHelper* helper = |
(...skipping 19 matching lines...) Expand all Loading... | |
691 | 730 |
692 // Save the email in the one-click signin manager. The manager may | 731 // Save the email in the one-click signin manager. The manager may |
693 // not exist if the contents is incognito or if the profile is already | 732 // not exist if the contents is incognito or if the profile is already |
694 // connected to a Google account. | 733 // connected to a Google account. |
695 if (!session_index.empty()) | 734 if (!session_index.empty()) |
696 helper->session_index_ = session_index; | 735 helper->session_index_ = session_index; |
697 | 736 |
698 if (!email.empty()) | 737 if (!email.empty()) |
699 helper->email_ = email; | 738 helper->email_ = email; |
700 | 739 |
701 if (auto_accept != NO_AUTO_ACCEPT) { | 740 if (auto_accept != AUTO_ACCEPT_NONE) { |
702 helper->auto_accept_ = auto_accept; | 741 helper->auto_accept_ = auto_accept; |
703 helper->source_ = source; | 742 helper->source_ = source; |
704 } | 743 } |
744 | |
745 if (continue_url.is_valid()) { | |
746 // When Gaia finally redirects to the continue URL, Gaia will add some | |
747 // extra query parameters. So ignore the parameters when checking to see | |
748 // if the user has continued. | |
749 GURL::Replacements replacements; | |
750 replacements.ClearQuery(); | |
751 helper->continue_url_ = continue_url.ReplaceComponents(replacements); | |
752 } | |
705 } | 753 } |
706 | 754 |
707 void OneClickSigninHelper::RedirectToNTP() { | 755 void OneClickSigninHelper::RedirectToNTP() { |
756 VLOG(1) << "OneClickSigninHelper::RedirectToNTP"; | |
757 | |
708 // Redirect to NTP with sign in bubble visible. | 758 // Redirect to NTP with sign in bubble visible. |
709 content::WebContents* contents = web_contents(); | 759 content::WebContents* contents = web_contents(); |
710 Profile* profile = | 760 Profile* profile = |
711 Profile::FromBrowserContext(contents->GetBrowserContext()); | 761 Profile::FromBrowserContext(contents->GetBrowserContext()); |
712 PrefService* pref_service = profile->GetPrefs(); | 762 PrefService* pref_service = profile->GetPrefs(); |
713 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | 763 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); |
714 pref_service->SetString(prefs::kSyncPromoErrorMessage, error_message_); | 764 pref_service->SetString(prefs::kSyncPromoErrorMessage, error_message_); |
715 | 765 |
716 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL), | 766 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL), |
717 content::Referrer(), | 767 content::Referrer(), |
718 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 768 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
719 std::string()); | 769 std::string()); |
720 | 770 |
721 error_message_.clear(); | 771 error_message_.clear(); |
722 signin_tracker_.reset(); | 772 signin_tracker_.reset(); |
723 } | 773 } |
724 | 774 |
725 void OneClickSigninHelper::CleanTransientState() { | 775 void OneClickSigninHelper::CleanTransientState() { |
776 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; | |
726 email_.clear(); | 777 email_.clear(); |
727 password_.clear(); | 778 password_.clear(); |
728 auto_accept_ = NO_AUTO_ACCEPT; | 779 auto_accept_ = AUTO_ACCEPT_NONE; |
729 source_ = SyncPromoUI::SOURCE_UNKNOWN; | 780 source_ = SyncPromoUI::SOURCE_UNKNOWN; |
781 continue_url_ = GURL(); | |
730 } | 782 } |
731 | 783 |
732 void OneClickSigninHelper::DidNavigateAnyFrame( | 784 void OneClickSigninHelper::DidNavigateAnyFrame( |
733 const content::LoadCommittedDetails& details, | 785 const content::LoadCommittedDetails& details, |
734 const content::FrameNavigateParams& params) { | 786 const content::FrameNavigateParams& params) { |
735 // We only need to scrape the password for Gaia logins. | 787 // We only need to scrape the password for Gaia logins. |
736 const content::PasswordForm& form = params.password_form; | 788 const content::PasswordForm& form = params.password_form; |
737 if (form.origin.is_valid() && | 789 if (form.origin.is_valid() && |
738 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { | 790 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { |
739 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; | 791 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; |
740 password_ = UTF16ToUTF8(params.password_form.password_value); | 792 password_ = UTF16ToUTF8(params.password_form.password_value); |
741 } | 793 } |
742 } | 794 } |
743 | 795 |
744 void OneClickSigninHelper::DidStopLoading( | 796 void OneClickSigninHelper::DidStopLoading( |
745 content::RenderViewHost* render_view_host) { | 797 content::RenderViewHost* render_view_host) { |
746 // If the user left the sign in process, clear all members. | 798 // If the user left the sign in process, clear all members. |
747 // TODO(rogerta): might need to allow some youtube URLs. | 799 // TODO(rogerta): might need to allow some youtube URLs. |
748 content::WebContents* contents = web_contents(); | 800 content::WebContents* contents = web_contents(); |
749 if (!gaia::IsGaiaSignonRealm(contents->GetURL().GetOrigin())) { | 801 const GURL url = contents->GetURL(); |
750 CleanTransientState(); | 802 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); |
751 return; | |
752 } | |
753 | 803 |
754 if (!error_message_.empty()) { | 804 // If an error has already occured during the sign in flow, make sure to |
805 // display it to the user and abort the process. Do this only for | |
806 // explicit sign ins. | |
807 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { | |
808 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; | |
755 RedirectToNTP(); | 809 RedirectToNTP(); |
756 return; | 810 return; |
757 } | 811 } |
758 | 812 |
813 // If there is no valid email or password yet, there is nothing to do. | |
759 if (email_.empty() || password_.empty()) | 814 if (email_.empty() || password_.empty()) |
760 return; | 815 return; |
761 | 816 |
817 bool last_minute_source_change = false; | |
tim (not reviewing)
2012/12/14 19:48:29
I'm a bit confused, how does the user saying "I wa
Roger Tawa OOO till Jul 10th
2012/12/16 03:03:46
It was kind of explained at line 845 below, but I
| |
818 | |
819 if (SyncPromoUI::UseWebBasedSigninFlow()) { | |
820 if (IsValidGaiaSigninRedirectOrResponseURL(url)) | |
821 return; | |
822 | |
823 // During an explicit sign in, if the user has not yet reached the final | |
824 // continue URL, wait for it to arrive. Note that Gaia will add some extra | |
825 // query parameters to the continue URL. Ignore them when checking to | |
826 // see if the user has continued. | |
827 // | |
828 // If this is not an explicit sign in, we don't need to check if we landed | |
829 // on the right continue URL. This is important because the continue URL | |
830 // may itself lead to a redirect, which means this function will never see | |
831 // the continue URL go by. | |
832 if (source_ != SyncPromoUI::SOURCE_UNKNOWN) { | |
tim (not reviewing)
2012/12/14 19:48:29
Use AUTO_ACCEPT_EXPLICIT instead of SOURCE_UNKNOWN
Roger Tawa OOO till Jul 10th
2012/12/16 03:03:46
Done. Where also below?
tim (not reviewing)
2012/12/18 01:25:48
Hmm... good question.
| |
833 GURL::Replacements replacements; | |
834 replacements.ClearQuery(); | |
835 const bool continue_url_match = | |
836 url.ReplaceComponents(replacements) == continue_url_; | |
837 if (!continue_url_match) { | |
838 VLOG(1) << "OneClickSigninHelper::DidStopLoading: invalid url='" | |
839 << url.spec() | |
840 << "' expected continue url=" << continue_url_; | |
841 CleanTransientState(); | |
842 return; | |
843 } | |
844 | |
845 // In explicit sign ins, the user may have checked the box | |
846 // "Let me choose what to sync". This is reflected as a change in the | |
847 // source of the continue URL. Make one last check of the current URL | |
848 // to see if there is a valid source and its set to "settings". If so, | |
tim (not reviewing)
2012/12/14 19:48:29
nit- it's set to settings
Roger Tawa OOO till Jul 10th
2012/12/16 03:03:46
Done.
| |
849 // it overrides the current source. | |
850 SyncPromoUI::Source source = | |
851 SyncPromoUI::GetSourceForSyncPromoURL(url); | |
852 if (source == SyncPromoUI::SOURCE_SETTINGS) { | |
853 source_ = SyncPromoUI::SOURCE_SETTINGS; | |
854 last_minute_source_change = true; | |
855 } | |
856 } | |
857 } | |
858 | |
762 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 859 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
860 Profile* profile = | |
861 Profile::FromBrowserContext(contents->GetBrowserContext()); | |
763 InfoBarTabHelper* infobar_tab_helper = | 862 InfoBarTabHelper* infobar_tab_helper = |
764 InfoBarTabHelper::FromWebContents(contents); | 863 InfoBarTabHelper::FromWebContents(contents); |
765 | 864 |
865 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | |
866 << " auto_accept=" << auto_accept_ | |
867 << " source=" << source_; | |
868 | |
766 switch (auto_accept_) { | 869 switch (auto_accept_) { |
767 case AUTO_ACCEPT: | 870 case AUTO_ACCEPT_NONE: |
871 if (SyncPromoUI::UseWebBasedSigninFlow()) { | |
872 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | |
873 one_click_signin::HISTOGRAM_DISMISSED, | |
874 one_click_signin::HISTOGRAM_MAX); | |
875 } else { | |
876 infobar_tab_helper->AddInfoBar( | |
877 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, | |
878 email_, password_)); | |
879 } | |
880 break; | |
881 case AUTO_ACCEPT_ACCEPTED: | |
882 SigninManager::DisableOneClickSignIn(profile); | |
768 browser->window()->ShowOneClickSigninBubble( | 883 browser->window()->ShowOneClickSigninBubble( |
769 base::Bind(&StartSync, browser, auto_accept_, session_index_, | 884 base::Bind(&StartSync, browser, auto_accept_, session_index_, |
770 email_, password_)); | 885 email_, password_)); |
771 break; | 886 break; |
772 case NO_AUTO_ACCEPT: | |
773 infobar_tab_helper->AddInfoBar( | |
774 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, | |
775 email_, password_)); | |
776 break; | |
777 case AUTO_ACCEPT_CONFIGURE: | 887 case AUTO_ACCEPT_CONFIGURE: |
888 SigninManager::DisableOneClickSignIn(profile); | |
778 StartSync(browser, auto_accept_, session_index_, email_, password_, | 889 StartSync(browser, auto_accept_, session_index_, email_, password_, |
779 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 890 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
780 break; | 891 break; |
781 case AUTO_ACCEPT_EXPLICIT: | 892 case AUTO_ACCEPT_EXPLICIT: |
782 StartSync(browser, auto_accept_, session_index_, email_, password_, | 893 StartSync(browser, auto_accept_, session_index_, email_, password_, |
783 source_ == SyncPromoUI::SOURCE_SETTINGS ? | 894 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
784 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 895 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
785 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 896 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
897 | |
898 // If this was a last minute switch to the settings page, this means the | |
899 // started with first-run/NTP/wrench menu, and checked the "configure | |
900 // first" checkbox. Replace the default blank continue page with an | |
901 // about:blank page, so that when the settings page is displayed, it | |
902 // reuses the tab. | |
903 if (last_minute_source_change) { | |
904 contents->GetController().LoadURL( | |
905 GURL("about:blank"), content::Referrer(), | |
906 content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | |
907 } | |
786 break; | 908 break; |
787 case REJECTED_FOR_PROFILE: | 909 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: |
910 AddEmailToOneClickRejectedList(profile, email_); | |
788 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 911 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", |
789 one_click_signin::HISTOGRAM_REJECTED, | 912 one_click_signin::HISTOGRAM_REJECTED, |
790 one_click_signin::HISTOGRAM_MAX); | 913 one_click_signin::HISTOGRAM_MAX); |
791 break; | 914 break; |
792 default: | 915 default: |
793 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 916 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
794 break; | 917 break; |
795 } | 918 } |
796 | 919 |
797 // If this explicit sign in is not from settings page, show the NTP after | 920 // If this explicit sign in is not from settings page, show the NTP after |
798 // sign in completes. In the case of the settings page, it will get closed | 921 // sign in completes. In the case of the settings page, it will get closed |
799 // by SyncSetupHandler. | 922 // by SyncSetupHandler. |
800 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && | 923 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && |
801 source_ != SyncPromoUI::SOURCE_SETTINGS) { | 924 source_ != SyncPromoUI::SOURCE_SETTINGS) { |
802 Profile* profile = | |
803 Profile::FromBrowserContext(contents->GetBrowserContext()); | |
804 signin_tracker_.reset(new SigninTracker(profile, this)); | 925 signin_tracker_.reset(new SigninTracker(profile, this)); |
805 } | 926 } |
806 | 927 |
807 CleanTransientState(); | 928 CleanTransientState(); |
808 } | 929 } |
809 | 930 |
810 void OneClickSigninHelper::GaiaCredentialsValid() { | 931 void OneClickSigninHelper::GaiaCredentialsValid() { |
811 } | 932 } |
812 | 933 |
813 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { | 934 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { |
(...skipping 13 matching lines...) Expand all Loading... | |
827 break; | 948 break; |
828 } | 949 } |
829 } | 950 } |
830 | 951 |
831 RedirectToNTP(); | 952 RedirectToNTP(); |
832 } | 953 } |
833 | 954 |
834 void OneClickSigninHelper::SigninSuccess() { | 955 void OneClickSigninHelper::SigninSuccess() { |
835 RedirectToNTP(); | 956 RedirectToNTP(); |
836 } | 957 } |
OLD | NEW |