| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/signin/signin_manager_factory.h" | 41 #include "chrome/browser/signin/signin_manager_factory.h" |
| 42 #include "chrome/browser/signin/signin_names_io_thread.h" | 42 #include "chrome/browser/signin/signin_names_io_thread.h" |
| 43 #include "chrome/browser/sync/profile_sync_service.h" | 43 #include "chrome/browser/sync/profile_sync_service.h" |
| 44 #include "chrome/browser/sync/profile_sync_service_factory.h" | 44 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 45 #include "chrome/browser/tab_contents/tab_util.h" | 45 #include "chrome/browser/tab_contents/tab_util.h" |
| 46 #include "chrome/browser/ui/browser_finder.h" | 46 #include "chrome/browser/ui/browser_finder.h" |
| 47 #include "chrome/browser/ui/browser_list.h" | 47 #include "chrome/browser/ui/browser_list.h" |
| 48 #include "chrome/browser/ui/browser_tabstrip.h" | 48 #include "chrome/browser/ui/browser_tabstrip.h" |
| 49 #include "chrome/browser/ui/browser_window.h" | 49 #include "chrome/browser/ui/browser_window.h" |
| 50 #include "chrome/browser/ui/chrome_pages.h" | 50 #include "chrome/browser/ui/chrome_pages.h" |
| 51 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | |
| 52 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" | 51 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" |
| 53 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 52 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| 54 #include "chrome/browser/ui/sync/signin_histogram.h" | |
| 55 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 53 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 56 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 54 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 55 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 58 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 56 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 59 #include "chrome/common/chrome_version_info.h" | 57 #include "chrome/common/chrome_version_info.h" |
| 60 #include "chrome/common/net/url_util.h" | 58 #include "chrome/common/net/url_util.h" |
| 61 #include "chrome/common/pref_names.h" | 59 #include "chrome/common/pref_names.h" |
| 62 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
| 63 #include "chrome/grit/chromium_strings.h" | 61 #include "chrome/grit/chromium_strings.h" |
| 64 #include "chrome/grit/generated_resources.h" | 62 #include "chrome/grit/generated_resources.h" |
| 65 #include "components/autofill/core/common/password_form.h" | 63 #include "components/autofill/core/common/password_form.h" |
| 66 #include "components/google/core/browser/google_util.h" | 64 #include "components/google/core/browser/google_util.h" |
| 67 #include "components/password_manager/core/browser/password_manager.h" | 65 #include "components/password_manager/core/browser/password_manager.h" |
| 68 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 66 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 69 #include "components/signin/core/browser/signin_client.h" | 67 #include "components/signin/core/browser/signin_client.h" |
| 70 #include "components/signin/core/browser/signin_error_controller.h" | 68 #include "components/signin/core/browser/signin_error_controller.h" |
| 71 #include "components/signin/core/browser/signin_manager.h" | 69 #include "components/signin/core/browser/signin_manager.h" |
| 72 #include "components/signin/core/browser/signin_manager_cookie_helper.h" | 70 #include "components/signin/core/browser/signin_manager_cookie_helper.h" |
| 71 #include "components/signin/core/browser/signin_metrics.h" |
| 73 #include "components/signin/core/common/profile_management_switches.h" | 72 #include "components/signin/core/common/profile_management_switches.h" |
| 74 #include "components/sync_driver/sync_prefs.h" | 73 #include "components/sync_driver/sync_prefs.h" |
| 75 #include "content/public/browser/browser_thread.h" | 74 #include "content/public/browser/browser_thread.h" |
| 76 #include "content/public/browser/navigation_entry.h" | 75 #include "content/public/browser/navigation_entry.h" |
| 77 #include "content/public/browser/page_navigator.h" | 76 #include "content/public/browser/page_navigator.h" |
| 78 #include "content/public/browser/render_frame_host.h" | 77 #include "content/public/browser/render_frame_host.h" |
| 79 #include "content/public/browser/render_process_host.h" | 78 #include "content/public/browser/render_process_host.h" |
| 80 #include "content/public/browser/web_contents.h" | 79 #include "content/public/browser/web_contents.h" |
| 81 #include "content/public/browser/web_contents_delegate.h" | 80 #include "content/public/browser/web_contents_delegate.h" |
| 82 #include "content/public/common/frame_navigate_params.h" | 81 #include "content/public/common/frame_navigate_params.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 222 |
| 224 // Add a specific email to the list of emails rejected for one-click | 223 // Add a specific email to the list of emails rejected for one-click |
| 225 // sign-in, for this profile. | 224 // sign-in, for this profile. |
| 226 void AddEmailToOneClickRejectedList(Profile* profile, | 225 void AddEmailToOneClickRejectedList(Profile* profile, |
| 227 const std::string& email) { | 226 const std::string& email) { |
| 228 ListPrefUpdate updater(profile->GetPrefs(), | 227 ListPrefUpdate updater(profile->GetPrefs(), |
| 229 prefs::kReverseAutologinRejectedEmailList); | 228 prefs::kReverseAutologinRejectedEmailList); |
| 230 updater->AppendIfNotPresent(new base::StringValue(email)); | 229 updater->AppendIfNotPresent(new base::StringValue(email)); |
| 231 } | 230 } |
| 232 | 231 |
| 233 void LogOneClickHistogramValue(int action) { | |
| 234 UMA_HISTOGRAM_ENUMERATION("Signin.OneClickActions", action, | |
| 235 one_click_signin::HISTOGRAM_MAX); | |
| 236 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, | |
| 237 one_click_signin::HISTOGRAM_MAX); | |
| 238 } | |
| 239 | |
| 240 void RedirectToNtpOrAppsPageWithIds(int child_id, | 232 void RedirectToNtpOrAppsPageWithIds(int child_id, |
| 241 int route_id, | 233 int route_id, |
| 242 signin::Source source) { | 234 signin_metrics::Source source) { |
| 243 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, | 235 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, |
| 244 route_id); | 236 route_id); |
| 245 if (!web_contents) | 237 if (!web_contents) |
| 246 return; | 238 return; |
| 247 | 239 |
| 248 OneClickSigninHelper::RedirectToNtpOrAppsPage(web_contents, source); | 240 OneClickSigninHelper::RedirectToNtpOrAppsPage(web_contents, source); |
| 249 } | 241 } |
| 250 | 242 |
| 251 // Start syncing with the given user information. | 243 // Start syncing with the given user information. |
| 252 void StartSync(const OneClickSigninHelper::StartSyncArgs& args, | 244 void StartSync(const OneClickSigninHelper::StartSyncArgs& args, |
| 253 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 245 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 254 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { | 246 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { |
| 255 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); | 247 OneClickSigninHelper::LogHistogramValue(signin_metrics::HISTOGRAM_UNDO); |
| 256 return; | 248 return; |
| 257 } | 249 } |
| 258 | 250 |
| 259 // The wrapper deletes itself once it's done. | 251 // The wrapper deletes itself once it's done. |
| 260 OneClickSigninHelper::SyncStarterWrapper* wrapper = | 252 OneClickSigninHelper::SyncStarterWrapper* wrapper = |
| 261 new OneClickSigninHelper::SyncStarterWrapper(args, start_mode); | 253 new OneClickSigninHelper::SyncStarterWrapper(args, start_mode); |
| 262 wrapper->Start(); | 254 wrapper->Start(); |
| 263 | 255 |
| 264 int action = one_click_signin::HISTOGRAM_MAX; | 256 int action = signin_metrics::HISTOGRAM_MAX; |
| 265 switch (args.auto_accept) { | 257 switch (args.auto_accept) { |
| 266 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 258 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
| 267 break; | 259 break; |
| 268 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | 260 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
| 269 action = | 261 action = |
| 270 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 262 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
| 271 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : | 263 signin_metrics::HISTOGRAM_AUTO_WITH_DEFAULTS : |
| 272 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 264 signin_metrics::HISTOGRAM_AUTO_WITH_ADVANCED; |
| 273 break; | 265 break; |
| 274 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: | 266 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: |
| 275 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 267 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 276 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 268 action = signin_metrics::HISTOGRAM_AUTO_WITH_ADVANCED; |
| 277 break; | 269 break; |
| 278 default: | 270 default: |
| 279 NOTREACHED() << "Invalid auto_accept: " << args.auto_accept; | 271 NOTREACHED() << "Invalid auto_accept: " << args.auto_accept; |
| 280 break; | 272 break; |
| 281 } | 273 } |
| 282 if (action != one_click_signin::HISTOGRAM_MAX) | 274 if (action != signin_metrics::HISTOGRAM_MAX) |
| 283 LogOneClickHistogramValue(action); | 275 OneClickSigninHelper::LogHistogramValue(action); |
| 284 } | 276 } |
| 285 | 277 |
| 286 void StartExplicitSync(const OneClickSigninHelper::StartSyncArgs& args, | 278 void StartExplicitSync(const OneClickSigninHelper::StartSyncArgs& args, |
| 287 content::WebContents* contents, | 279 content::WebContents* contents, |
| 288 OneClickSigninSyncStarter::StartSyncMode start_mode, | 280 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 289 ConfirmEmailDialogDelegate::Action action) { | 281 ConfirmEmailDialogDelegate::Action action) { |
| 290 bool enable_inline = !switches::IsEnableWebBasedSignin(); | 282 bool enable_inline = !switches::IsEnableWebBasedSignin(); |
| 291 if (action == ConfirmEmailDialogDelegate::START_SYNC) { | 283 if (action == ConfirmEmailDialogDelegate::START_SYNC) { |
| 292 StartSync(args, start_mode); | 284 StartSync(args, start_mode); |
| 293 if (!enable_inline) { | 285 if (!enable_inline) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 324 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { | 316 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { |
| 325 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 317 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 326 DCHECK(io_data); | 318 DCHECK(io_data); |
| 327 io_data->set_reverse_autologin_pending_email(std::string()); | 319 io_data->set_reverse_autologin_pending_email(std::string()); |
| 328 } | 320 } |
| 329 | 321 |
| 330 // Determines the source of the sign in and the continue URL. It's either one | 322 // Determines the source of the sign in and the continue URL. It's either one |
| 331 // of the known sign-in access points (first run, NTP, Apps page, menu, or | 323 // of the known sign-in access points (first run, NTP, Apps page, menu, or |
| 332 // settings) or it's an implicit sign in via another Google property. In the | 324 // settings) or it's an implicit sign in via another Google property. In the |
| 333 // former case, "service" is also checked to make sure its "chromiumsync". | 325 // former case, "service" is also checked to make sure its "chromiumsync". |
| 334 signin::Source GetSigninSource(const GURL& url, GURL* continue_url) { | 326 signin_metrics::Source GetSigninSource(const GURL& url, GURL* continue_url) { |
| 335 DCHECK(url.is_valid()); | 327 DCHECK(url.is_valid()); |
| 336 std::string value; | 328 std::string value; |
| 337 net::GetValueForKeyInQuery(url, "service", &value); | 329 net::GetValueForKeyInQuery(url, "service", &value); |
| 338 bool possibly_an_explicit_signin = value == "chromiumsync"; | 330 bool possibly_an_explicit_signin = value == "chromiumsync"; |
| 339 | 331 |
| 340 // Find the final continue URL for this sign in. In some cases, Gaia can | 332 // Find the final continue URL for this sign in. In some cases, Gaia can |
| 341 // continue to itself, with the original continue URL buried under a couple | 333 // continue to itself, with the original continue URL buried under a couple |
| 342 // of layers of indirection. Peel those layers away. The final destination | 334 // of layers of indirection. Peel those layers away. The final destination |
| 343 // can also be "IsGaiaSignonRealm" so stop if we get to the end (but be sure | 335 // can also be "IsGaiaSignonRealm" so stop if we get to the end (but be sure |
| 344 // we always extract at least one "continue" value). | 336 // we always extract at least one "continue" value). |
| 345 GURL local_continue_url = signin::GetNextPageURLForPromoURL(url); | 337 GURL local_continue_url = signin::GetNextPageURLForPromoURL(url); |
| 346 while (gaia::IsGaiaSignonRealm(local_continue_url.GetOrigin())) { | 338 while (gaia::IsGaiaSignonRealm(local_continue_url.GetOrigin())) { |
| 347 GURL next_continue_url = | 339 GURL next_continue_url = |
| 348 signin::GetNextPageURLForPromoURL(local_continue_url); | 340 signin::GetNextPageURLForPromoURL(local_continue_url); |
| 349 if (!next_continue_url.is_valid()) | 341 if (!next_continue_url.is_valid()) |
| 350 break; | 342 break; |
| 351 local_continue_url = next_continue_url; | 343 local_continue_url = next_continue_url; |
| 352 } | 344 } |
| 353 | 345 |
| 354 if (continue_url && local_continue_url.is_valid()) { | 346 if (continue_url && local_continue_url.is_valid()) { |
| 355 DCHECK(!continue_url->is_valid() || *continue_url == local_continue_url); | 347 DCHECK(!continue_url->is_valid() || *continue_url == local_continue_url); |
| 356 *continue_url = local_continue_url; | 348 *continue_url = local_continue_url; |
| 357 } | 349 } |
| 358 | 350 |
| 359 return possibly_an_explicit_signin ? | 351 return possibly_an_explicit_signin ? |
| 360 signin::GetSourceForPromoURL(local_continue_url) : | 352 signin::GetSourceForPromoURL(local_continue_url) : |
| 361 signin::SOURCE_UNKNOWN; | 353 signin_metrics::SOURCE_UNKNOWN; |
| 362 } | 354 } |
| 363 | 355 |
| 364 // Returns true if |url| is a valid URL that can occur during the sign in | 356 // Returns true if |url| is a valid URL that can occur during the sign in |
| 365 // process. Valid URLs are of the form: | 357 // process. Valid URLs are of the form: |
| 366 // | 358 // |
| 367 // https://accounts.google.{TLD}/... | 359 // https://accounts.google.{TLD}/... |
| 368 // https://accounts.youtube.com/... | 360 // https://accounts.youtube.com/... |
| 369 // https://accounts.blogger.com/... | 361 // https://accounts.blogger.com/... |
| 370 // | 362 // |
| 371 // All special headers used by one click sign in occur on | 363 // All special headers used by one click sign in occur on |
| (...skipping 16 matching lines...) Expand all Loading... |
| 388 origin == GURL("https://accounts.blogger.com")) | 380 origin == GURL("https://accounts.blogger.com")) |
| 389 return true; | 381 return true; |
| 390 | 382 |
| 391 return false; | 383 return false; |
| 392 } | 384 } |
| 393 | 385 |
| 394 // Tells when we are in the process of showing either the signin to chrome page | 386 // Tells when we are in the process of showing either the signin to chrome page |
| 395 // or the one click sign in to chrome page. | 387 // or the one click sign in to chrome page. |
| 396 // NOTE: This should only be used for logging purposes since it relies on hard | 388 // NOTE: This should only be used for logging purposes since it relies on hard |
| 397 // coded URLs that could change. | 389 // coded URLs that could change. |
| 398 bool AreWeShowingSignin(GURL url, signin::Source source, std::string email) { | 390 bool AreWeShowingSignin(GURL url, |
| 391 signin_metrics::Source source, |
| 392 std::string email) { |
| 399 GURL::Replacements replacements; | 393 GURL::Replacements replacements; |
| 400 replacements.ClearQuery(); | 394 replacements.ClearQuery(); |
| 401 GURL clean_login_url = | 395 GURL clean_login_url = |
| 402 GaiaUrls::GetInstance()->service_login_url().ReplaceComponents( | 396 GaiaUrls::GetInstance()->service_login_url().ReplaceComponents( |
| 403 replacements); | 397 replacements); |
| 404 | 398 |
| 405 return (url.ReplaceComponents(replacements) == clean_login_url && | 399 return (url.ReplaceComponents(replacements) == clean_login_url && |
| 406 source != signin::SOURCE_UNKNOWN) || | 400 source != signin_metrics::SOURCE_UNKNOWN) || |
| 407 (IsValidGaiaSigninRedirectOrResponseURL(url) && | 401 (IsValidGaiaSigninRedirectOrResponseURL(url) && |
| 408 url.spec().find("ChromeLoginPrompt") != std::string::npos && | 402 url.spec().find("ChromeLoginPrompt") != std::string::npos && |
| 409 !email.empty()); | 403 !email.empty()); |
| 410 } | 404 } |
| 411 | 405 |
| 412 // If profile is valid then get signin scoped device id from signin client. | 406 // If profile is valid then get signin scoped device id from signin client. |
| 413 // Otherwise returns empty string. | 407 // Otherwise returns empty string. |
| 414 std::string GetSigninScopedDeviceId(Profile* profile) { | 408 std::string GetSigninScopedDeviceId(Profile* profile) { |
| 415 std::string signin_scoped_device_id; | 409 std::string signin_scoped_device_id; |
| 416 SigninClient* signin_client = | 410 SigninClient* signin_client = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 482 |
| 489 | 483 |
| 490 // StartSyncArgs -------------------------------------------------------------- | 484 // StartSyncArgs -------------------------------------------------------------- |
| 491 | 485 |
| 492 OneClickSigninHelper::StartSyncArgs::StartSyncArgs() | 486 OneClickSigninHelper::StartSyncArgs::StartSyncArgs() |
| 493 : profile(NULL), | 487 : profile(NULL), |
| 494 browser(NULL), | 488 browser(NULL), |
| 495 auto_accept(AUTO_ACCEPT_NONE), | 489 auto_accept(AUTO_ACCEPT_NONE), |
| 496 web_contents(NULL), | 490 web_contents(NULL), |
| 497 confirmation_required(OneClickSigninSyncStarter::NO_CONFIRMATION), | 491 confirmation_required(OneClickSigninSyncStarter::NO_CONFIRMATION), |
| 498 source(signin::SOURCE_UNKNOWN) {} | 492 source(signin_metrics::SOURCE_UNKNOWN) {} |
| 499 | 493 |
| 500 OneClickSigninHelper::StartSyncArgs::StartSyncArgs( | 494 OneClickSigninHelper::StartSyncArgs::StartSyncArgs( |
| 501 Profile* profile, | 495 Profile* profile, |
| 502 Browser* browser, | 496 Browser* browser, |
| 503 OneClickSigninHelper::AutoAccept auto_accept, | 497 OneClickSigninHelper::AutoAccept auto_accept, |
| 504 const std::string& session_index, | 498 const std::string& session_index, |
| 505 const std::string& email, | 499 const std::string& email, |
| 506 const std::string& password, | 500 const std::string& password, |
| 507 const std::string& refresh_token, | 501 const std::string& refresh_token, |
| 508 content::WebContents* web_contents, | 502 content::WebContents* web_contents, |
| 509 bool untrusted_confirmation_required, | 503 bool untrusted_confirmation_required, |
| 510 signin::Source source, | 504 signin_metrics::Source source, |
| 511 OneClickSigninSyncStarter::Callback callback) | 505 OneClickSigninSyncStarter::Callback callback) |
| 512 : profile(profile), | 506 : profile(profile), |
| 513 browser(browser), | 507 browser(browser), |
| 514 auto_accept(auto_accept), | 508 auto_accept(auto_accept), |
| 515 session_index(session_index), | 509 session_index(session_index), |
| 516 email(email), | 510 email(email), |
| 517 password(password), | 511 password(password), |
| 518 refresh_token(refresh_token), | 512 refresh_token(refresh_token), |
| 519 web_contents(web_contents), | 513 web_contents(web_contents), |
| 520 source(source), | 514 source(source), |
| 521 callback(callback) { | 515 callback(callback) { |
| 522 DCHECK(session_index.empty() != refresh_token.empty()); | 516 DCHECK(session_index.empty() != refresh_token.empty()); |
| 523 if (untrusted_confirmation_required) { | 517 if (untrusted_confirmation_required) { |
| 524 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; | 518 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; |
| 525 } else if (source == signin::SOURCE_SETTINGS) { | 519 } else if (source == signin_metrics::SOURCE_SETTINGS) { |
| 526 // Do not display a status confirmation for re-auth. | 520 // Do not display a status confirmation for re-auth. |
| 527 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; | 521 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; |
| 528 } else { | 522 } else { |
| 529 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; | 523 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; |
| 530 } | 524 } |
| 531 } | 525 } |
| 532 | 526 |
| 533 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {} | 527 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {} |
| 534 | 528 |
| 535 // SyncStarterWrapper --------------------------------------------------------- | 529 // SyncStarterWrapper --------------------------------------------------------- |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 664 |
| 671 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); | 665 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); |
| 672 | 666 |
| 673 // static | 667 // static |
| 674 const int OneClickSigninHelper::kMaxNavigationsSince = 10; | 668 const int OneClickSigninHelper::kMaxNavigationsSince = 10; |
| 675 | 669 |
| 676 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) | 670 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
| 677 : content::WebContentsObserver(web_contents), | 671 : content::WebContentsObserver(web_contents), |
| 678 showing_signin_(false), | 672 showing_signin_(false), |
| 679 auto_accept_(AUTO_ACCEPT_NONE), | 673 auto_accept_(AUTO_ACCEPT_NONE), |
| 680 source_(signin::SOURCE_UNKNOWN), | 674 source_(signin_metrics::SOURCE_UNKNOWN), |
| 681 switched_to_advanced_(false), | 675 switched_to_advanced_(false), |
| 682 untrusted_navigations_since_signin_visit_(0), | 676 untrusted_navigations_since_signin_visit_(0), |
| 683 untrusted_confirmation_required_(false), | 677 untrusted_confirmation_required_(false), |
| 684 do_not_clear_pending_email_(false), | 678 do_not_clear_pending_email_(false), |
| 685 do_not_start_sync_for_testing_(false), | 679 do_not_start_sync_for_testing_(false), |
| 686 weak_pointer_factory_(this) { | 680 weak_pointer_factory_(this) { |
| 687 ChromePasswordManagerClient* client = | 681 ChromePasswordManagerClient* client = |
| 688 ChromePasswordManagerClient::FromWebContents(web_contents); | 682 ChromePasswordManagerClient::FromWebContents(web_contents); |
| 689 // May be NULL during testing. | 683 // May be NULL during testing. |
| 690 if (client) { | 684 if (client) { |
| 691 client->GetPasswordManager()->AddSubmissionCallback( | 685 client->GetPasswordManager()->AddSubmissionCallback( |
| 692 base::Bind(&OneClickSigninHelper::PasswordSubmitted, | 686 base::Bind(&OneClickSigninHelper::PasswordSubmitted, |
| 693 weak_pointer_factory_.GetWeakPtr())); | 687 weak_pointer_factory_.GetWeakPtr())); |
| 694 } | 688 } |
| 695 } | 689 } |
| 696 | 690 |
| 697 OneClickSigninHelper::~OneClickSigninHelper() {} | 691 OneClickSigninHelper::~OneClickSigninHelper() {} |
| 698 | 692 |
| 699 // static | 693 // static |
| 700 void OneClickSigninHelper::LogHistogramValue( | 694 void OneClickSigninHelper::LogHistogramValue(int action) { |
| 701 signin::Source source, int action) { | |
| 702 switch (source) { | |
| 703 case signin::SOURCE_START_PAGE: | |
| 704 UMA_HISTOGRAM_ENUMERATION("Signin.StartPageActions", action, | |
| 705 one_click_signin::HISTOGRAM_MAX); | |
| 706 break; | |
| 707 case signin::SOURCE_NTP_LINK: | |
| 708 UMA_HISTOGRAM_ENUMERATION("Signin.NTPLinkActions", action, | |
| 709 one_click_signin::HISTOGRAM_MAX); | |
| 710 break; | |
| 711 case signin::SOURCE_MENU: | |
| 712 UMA_HISTOGRAM_ENUMERATION("Signin.MenuActions", action, | |
| 713 one_click_signin::HISTOGRAM_MAX); | |
| 714 break; | |
| 715 case signin::SOURCE_SETTINGS: | |
| 716 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action, | |
| 717 one_click_signin::HISTOGRAM_MAX); | |
| 718 break; | |
| 719 case signin::SOURCE_EXTENSION_INSTALL_BUBBLE: | |
| 720 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action, | |
| 721 one_click_signin::HISTOGRAM_MAX); | |
| 722 break; | |
| 723 case signin::SOURCE_APP_LAUNCHER: | |
| 724 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action, | |
| 725 one_click_signin::HISTOGRAM_MAX); | |
| 726 break; | |
| 727 case signin::SOURCE_APPS_PAGE_LINK: | |
| 728 UMA_HISTOGRAM_ENUMERATION("Signin.AppsPageLinkActions", action, | |
| 729 one_click_signin::HISTOGRAM_MAX); | |
| 730 break; | |
| 731 case signin::SOURCE_BOOKMARK_BUBBLE: | |
| 732 UMA_HISTOGRAM_ENUMERATION("Signin.BookmarkBubbleActions", action, | |
| 733 one_click_signin::HISTOGRAM_MAX); | |
| 734 break; | |
| 735 case signin::SOURCE_AVATAR_BUBBLE_SIGN_IN: | |
| 736 UMA_HISTOGRAM_ENUMERATION("Signin.AvatarBubbleActions", action, | |
| 737 one_click_signin::HISTOGRAM_MAX); | |
| 738 break; | |
| 739 case signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: | |
| 740 UMA_HISTOGRAM_ENUMERATION("Signin.AvatarBubbleActions", action, | |
| 741 one_click_signin::HISTOGRAM_MAX); | |
| 742 break; | |
| 743 case signin::SOURCE_DEVICES_PAGE: | |
| 744 UMA_HISTOGRAM_ENUMERATION("Signin.DevicesPageActions", action, | |
| 745 one_click_signin::HISTOGRAM_MAX); | |
| 746 break; | |
| 747 case signin::SOURCE_REAUTH: | |
| 748 UMA_HISTOGRAM_ENUMERATION("Signin.ReauthActions", action, | |
| 749 one_click_signin::HISTOGRAM_MAX); | |
| 750 break; | |
| 751 default: | |
| 752 // This switch statement needs to be updated when the enum Source changes. | |
| 753 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 12, | |
| 754 kSourceEnumHasChangedButNotThisSwitchStatement); | |
| 755 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action, | |
| 756 one_click_signin::HISTOGRAM_MAX); | |
| 757 } | |
| 758 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, | 695 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
| 759 one_click_signin::HISTOGRAM_MAX); | 696 signin_metrics::HISTOGRAM_MAX); |
| 760 } | 697 } |
| 761 | 698 |
| 762 // static | 699 // static |
| 763 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, | 700 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, |
| 764 CanOfferFor can_offer_for, | 701 CanOfferFor can_offer_for, |
| 765 const std::string& email, | 702 const std::string& email, |
| 766 std::string* error_message) { | 703 std::string* error_message) { |
| 767 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 704 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 768 VLOG(1) << "OneClickSigninHelper::CanOffer"; | 705 VLOG(1) << "OneClickSigninHelper::CanOffer"; |
| 769 | 706 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 744 } |
| 808 | 745 |
| 809 if (can_offer_for != CAN_OFFER_FOR_SECONDARY_ACCOUNT) { | 746 if (can_offer_for != CAN_OFFER_FOR_SECONDARY_ACCOUNT) { |
| 810 // If the signin manager already has an authenticated name, then this is a | 747 // If the signin manager already has an authenticated name, then this is a |
| 811 // re-auth scenario. Make sure the email just signed in corresponds to | 748 // re-auth scenario. Make sure the email just signed in corresponds to |
| 812 // the one sign in manager expects. | 749 // the one sign in manager expects. |
| 813 std::string current_email = manager->GetAuthenticatedUsername(); | 750 std::string current_email = manager->GetAuthenticatedUsername(); |
| 814 const bool same_email = gaia::AreEmailsSame(current_email, email); | 751 const bool same_email = gaia::AreEmailsSame(current_email, email); |
| 815 if (!current_email.empty() && !same_email) { | 752 if (!current_email.empty() && !same_email) { |
| 816 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", | 753 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", |
| 817 signin::HISTOGRAM_ACCOUNT_MISSMATCH, | 754 signin_metrics::HISTOGRAM_ACCOUNT_MISSMATCH, |
| 818 signin::HISTOGRAM_MAX); | 755 signin_metrics::HISTOGRAM_MAX); |
| 819 if (error_message) { | 756 if (error_message) { |
| 820 error_message->assign( | 757 error_message->assign( |
| 821 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, | 758 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, |
| 822 base::UTF8ToUTF16(current_email))); | 759 base::UTF8ToUTF16(current_email))); |
| 823 } | 760 } |
| 824 return false; | 761 return false; |
| 825 } | 762 } |
| 826 | 763 |
| 827 // If some profile, not just the current one, is already connected to this | 764 // If some profile, not just the current one, is already connected to this |
| 828 // account, don't show the infobar. | 765 // account, don't show the infobar. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 io_data->set_reverse_autologin_pending_email(email); | 911 io_data->set_reverse_autologin_pending_email(email); |
| 975 | 912 |
| 976 if (!email.empty() || !session_index.empty()) { | 913 if (!email.empty() || !session_index.empty()) { |
| 977 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" | 914 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" |
| 978 << " email=" << email | 915 << " email=" << email |
| 979 << " sessionindex=" << session_index; | 916 << " sessionindex=" << session_index; |
| 980 } | 917 } |
| 981 | 918 |
| 982 // Parse Google-Chrome-SignIn. | 919 // Parse Google-Chrome-SignIn. |
| 983 AutoAccept auto_accept = AUTO_ACCEPT_NONE; | 920 AutoAccept auto_accept = AUTO_ACCEPT_NONE; |
| 984 signin::Source source = signin::SOURCE_UNKNOWN; | 921 signin_metrics::Source source = signin_metrics::SOURCE_UNKNOWN; |
| 985 GURL continue_url; | 922 GURL continue_url; |
| 986 std::vector<std::string> tokens; | 923 std::vector<std::string> tokens; |
| 987 base::SplitString(google_chrome_signin_value, ',', &tokens); | 924 base::SplitString(google_chrome_signin_value, ',', &tokens); |
| 988 for (size_t i = 0; i < tokens.size(); ++i) { | 925 for (size_t i = 0; i < tokens.size(); ++i) { |
| 989 const std::string& token = tokens[i]; | 926 const std::string& token = tokens[i]; |
| 990 if (token == "accepted") { | 927 if (token == "accepted") { |
| 991 auto_accept = AUTO_ACCEPT_ACCEPTED; | 928 auto_accept = AUTO_ACCEPT_ACCEPTED; |
| 992 } else if (token == "configure") { | 929 } else if (token == "configure") { |
| 993 auto_accept = AUTO_ACCEPT_CONFIGURE; | 930 auto_accept = AUTO_ACCEPT_CONFIGURE; |
| 994 } else if (token == "rejected-for-profile") { | 931 } else if (token == "rejected-for-profile") { |
| 995 auto_accept = AUTO_ACCEPT_REJECTED_FOR_PROFILE; | 932 auto_accept = AUTO_ACCEPT_REJECTED_FOR_PROFILE; |
| 996 } | 933 } |
| 997 } | 934 } |
| 998 | 935 |
| 999 // If this is an explicit sign in (i.e., first run, NTP, Apps page, menu, | 936 // If this is an explicit sign in (i.e., first run, NTP, Apps page, menu, |
| 1000 // settings) then force the auto accept type to explicit. | 937 // settings) then force the auto accept type to explicit. |
| 1001 source = GetSigninSource(request->url(), &continue_url); | 938 source = GetSigninSource(request->url(), &continue_url); |
| 1002 if (source != signin::SOURCE_UNKNOWN) | 939 if (source != signin_metrics::SOURCE_UNKNOWN) |
| 1003 auto_accept = AUTO_ACCEPT_EXPLICIT; | 940 auto_accept = AUTO_ACCEPT_EXPLICIT; |
| 1004 | 941 |
| 1005 if (auto_accept != AUTO_ACCEPT_NONE) { | 942 if (auto_accept != AUTO_ACCEPT_NONE) { |
| 1006 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" | 943 VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:" |
| 1007 << " auto_accept=" << auto_accept; | 944 << " auto_accept=" << auto_accept; |
| 1008 } | 945 } |
| 1009 | 946 |
| 1010 // If |session_index|, |email|, |auto_accept|, and |continue_url| all have | 947 // If |session_index|, |email|, |auto_accept|, and |continue_url| all have |
| 1011 // their default value, don't bother posting a task to the UI thread. | 948 // their default value, don't bother posting a task to the UI thread. |
| 1012 // It will be a noop anyway. | 949 // It will be a noop anyway. |
| 1013 // | 950 // |
| 1014 // The two headers above may (but not always) come in different http requests | 951 // The two headers above may (but not always) come in different http requests |
| 1015 // so a post to the UI thread is still needed if |auto_accept| is not its | 952 // so a post to the UI thread is still needed if |auto_accept| is not its |
| 1016 // default value, but |email| and |session_index| are. | 953 // default value, but |email| and |session_index| are. |
| 1017 if (session_index.empty() && email.empty() && | 954 if (session_index.empty() && email.empty() && |
| 1018 auto_accept == AUTO_ACCEPT_NONE && !continue_url.is_valid()) { | 955 auto_accept == AUTO_ACCEPT_NONE && !continue_url.is_valid()) { |
| 1019 return; | 956 return; |
| 1020 } | 957 } |
| 1021 | 958 |
| 1022 content::BrowserThread::PostTask( | 959 content::BrowserThread::PostTask( |
| 1023 content::BrowserThread::UI, FROM_HERE, | 960 content::BrowserThread::UI, FROM_HERE, |
| 1024 base::Bind(&OneClickSigninHelper::ShowInfoBarUIThread, session_index, | 961 base::Bind(&OneClickSigninHelper::ShowInfoBarUIThread, session_index, |
| 1025 email, auto_accept, source, continue_url, child_id, route_id)); | 962 email, auto_accept, source, continue_url, child_id, route_id)); |
| 1026 } | 963 } |
| 1027 | 964 |
| 1028 // static | 965 // static |
| 1029 void OneClickSigninHelper::LogConfirmHistogramValue(int action) { | 966 void OneClickSigninHelper::LogConfirmHistogramValue(int action) { |
| 1030 UMA_HISTOGRAM_ENUMERATION("Signin.OneClickConfirmation", action, | 967 UMA_HISTOGRAM_ENUMERATION("Signin.OneClickConfirmation", action, |
| 1031 one_click_signin::HISTOGRAM_CONFIRM_MAX); | 968 signin_metrics::HISTOGRAM_CONFIRM_MAX); |
| 1032 } | 969 } |
| 1033 // static | 970 // static |
| 1034 void OneClickSigninHelper::ShowInfoBarUIThread( | 971 void OneClickSigninHelper::ShowInfoBarUIThread( |
| 1035 const std::string& session_index, | 972 const std::string& session_index, |
| 1036 const std::string& email, | 973 const std::string& email, |
| 1037 AutoAccept auto_accept, | 974 AutoAccept auto_accept, |
| 1038 signin::Source source, | 975 signin_metrics::Source source, |
| 1039 const GURL& continue_url, | 976 const GURL& continue_url, |
| 1040 int child_id, | 977 int child_id, |
| 1041 int route_id) { | 978 int route_id) { |
| 1042 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 979 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 1043 | 980 |
| 1044 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, | 981 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, |
| 1045 route_id); | 982 route_id); |
| 1046 if (!web_contents) | 983 if (!web_contents) |
| 1047 return; | 984 return; |
| 1048 | 985 |
| 1049 // TODO(mathp): The appearance of this infobar should be tested using a | 986 // TODO(mathp): The appearance of this infobar should be tested using a |
| 1050 // browser_test. | 987 // browser_test. |
| 1051 OneClickSigninHelper* helper = | 988 OneClickSigninHelper* helper = |
| 1052 OneClickSigninHelper::FromWebContents(web_contents); | 989 OneClickSigninHelper::FromWebContents(web_contents); |
| 1053 if (!helper) | 990 if (!helper) |
| 1054 return; | 991 return; |
| 1055 | 992 |
| 1056 if (auto_accept != AUTO_ACCEPT_NONE) | 993 if (auto_accept != AUTO_ACCEPT_NONE) |
| 1057 helper->auto_accept_ = auto_accept; | 994 helper->auto_accept_ = auto_accept; |
| 1058 | 995 |
| 1059 if (source != signin::SOURCE_UNKNOWN && | 996 if (source != signin_metrics::SOURCE_UNKNOWN && |
| 1060 helper->source_ == signin::SOURCE_UNKNOWN) { | 997 helper->source_ == signin_metrics::SOURCE_UNKNOWN) { |
| 1061 helper->source_ = source; | 998 helper->source_ = source; |
| 1062 } | 999 } |
| 1063 | 1000 |
| 1064 // Save the email in the one-click signin manager. The manager may | 1001 // Save the email in the one-click signin manager. The manager may |
| 1065 // not exist if the contents is incognito or if the profile is already | 1002 // not exist if the contents is incognito or if the profile is already |
| 1066 // connected to a Google account. | 1003 // connected to a Google account. |
| 1067 if (!session_index.empty()) | 1004 if (!session_index.empty()) |
| 1068 helper->session_index_ = session_index; | 1005 helper->session_index_ = session_index; |
| 1069 | 1006 |
| 1070 if (!email.empty()) | 1007 if (!email.empty()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 } | 1058 } |
| 1122 | 1059 |
| 1123 // static | 1060 // static |
| 1124 bool OneClickSigninHelper::HandleCrossAccountError( | 1061 bool OneClickSigninHelper::HandleCrossAccountError( |
| 1125 Profile* profile, | 1062 Profile* profile, |
| 1126 const std::string& session_index, | 1063 const std::string& session_index, |
| 1127 const std::string& email, | 1064 const std::string& email, |
| 1128 const std::string& password, | 1065 const std::string& password, |
| 1129 const std::string& refresh_token, | 1066 const std::string& refresh_token, |
| 1130 OneClickSigninHelper::AutoAccept auto_accept, | 1067 OneClickSigninHelper::AutoAccept auto_accept, |
| 1131 signin::Source source, | 1068 signin_metrics::Source source, |
| 1132 OneClickSigninSyncStarter::StartSyncMode start_mode, | 1069 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 1133 OneClickSigninSyncStarter::Callback sync_callback) { | 1070 OneClickSigninSyncStarter::Callback sync_callback) { |
| 1134 std::string last_email = | 1071 std::string last_email = |
| 1135 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1072 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 1136 | 1073 |
| 1137 if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email)) { | 1074 if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email)) { |
| 1138 // If the new email address is different from the email address that | 1075 // If the new email address is different from the email address that |
| 1139 // just signed in, show a confirmation dialog on top of the current active | 1076 // just signed in, show a confirmation dialog on top of the current active |
| 1140 // tab. | 1077 // tab. |
| 1141 | 1078 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1162 contents, | 1099 contents, |
| 1163 start_mode)); | 1100 start_mode)); |
| 1164 return true; | 1101 return true; |
| 1165 } | 1102 } |
| 1166 | 1103 |
| 1167 return false; | 1104 return false; |
| 1168 } | 1105 } |
| 1169 | 1106 |
| 1170 // static | 1107 // static |
| 1171 void OneClickSigninHelper::RedirectToNtpOrAppsPage( | 1108 void OneClickSigninHelper::RedirectToNtpOrAppsPage( |
| 1172 content::WebContents* contents, signin::Source source) { | 1109 content::WebContents* contents, signin_metrics::Source source) { |
| 1173 // Do nothing if a navigation is pending, since this call can be triggered | 1110 // Do nothing if a navigation is pending, since this call can be triggered |
| 1174 // from DidStartLoading. This avoids deleting the pending entry while we are | 1111 // from DidStartLoading. This avoids deleting the pending entry while we are |
| 1175 // still navigating to it. See crbug/346632. | 1112 // still navigating to it. See crbug/346632. |
| 1176 if (contents->GetController().GetPendingEntry()) | 1113 if (contents->GetController().GetPendingEntry()) |
| 1177 return; | 1114 return; |
| 1178 | 1115 |
| 1179 VLOG(1) << "RedirectToNtpOrAppsPage"; | 1116 VLOG(1) << "RedirectToNtpOrAppsPage"; |
| 1180 // Redirect to NTP/Apps page and display a confirmation bubble | 1117 // Redirect to NTP/Apps page and display a confirmation bubble |
| 1181 GURL url(source == signin::SOURCE_APPS_PAGE_LINK ? | 1118 GURL url(source == signin_metrics::SOURCE_APPS_PAGE_LINK ? |
| 1182 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); | 1119 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); |
| 1183 content::OpenURLParams params(url, | 1120 content::OpenURLParams params(url, |
| 1184 content::Referrer(), | 1121 content::Referrer(), |
| 1185 CURRENT_TAB, | 1122 CURRENT_TAB, |
| 1186 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 1123 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1187 false); | 1124 false); |
| 1188 contents->OpenURL(params); | 1125 contents->OpenURL(params); |
| 1189 } | 1126 } |
| 1190 | 1127 |
| 1191 // static | 1128 // static |
| 1192 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( | 1129 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( |
| 1193 content::WebContents* contents, signin::Source source) { | 1130 content::WebContents* contents, signin_metrics::Source source) { |
| 1194 if (source != signin::SOURCE_SETTINGS) { | 1131 if (source != signin_metrics::SOURCE_SETTINGS) { |
| 1195 RedirectToNtpOrAppsPage(contents, source); | 1132 RedirectToNtpOrAppsPage(contents, source); |
| 1196 } | 1133 } |
| 1197 } | 1134 } |
| 1198 | 1135 |
| 1199 void OneClickSigninHelper::RedirectToSignin() { | 1136 void OneClickSigninHelper::RedirectToSignin() { |
| 1200 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; | 1137 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; |
| 1201 | 1138 |
| 1202 // Extract the existing sounce=X value. Default to "2" if missing. | 1139 // Extract the existing sounce=X value. Default to "2" if missing. |
| 1203 signin::Source source = signin::GetSourceForPromoURL(continue_url_); | 1140 signin_metrics::Source source = signin::GetSourceForPromoURL(continue_url_); |
| 1204 if (source == signin::SOURCE_UNKNOWN) | 1141 if (source == signin_metrics::SOURCE_UNKNOWN) |
| 1205 source = signin::SOURCE_MENU; | 1142 source = signin_metrics::SOURCE_MENU; |
| 1206 GURL page = signin::GetPromoURL(source, false); | 1143 GURL page = signin::GetPromoURL(source, false); |
| 1207 | 1144 |
| 1208 content::WebContents* contents = web_contents(); | 1145 content::WebContents* contents = web_contents(); |
| 1209 contents->GetController().LoadURL(page, | 1146 contents->GetController().LoadURL(page, |
| 1210 content::Referrer(), | 1147 content::Referrer(), |
| 1211 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 1148 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 1212 std::string()); | 1149 std::string()); |
| 1213 } | 1150 } |
| 1214 | 1151 |
| 1215 void OneClickSigninHelper::CleanTransientState() { | 1152 void OneClickSigninHelper::CleanTransientState() { |
| 1216 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; | 1153 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; |
| 1217 showing_signin_ = false; | 1154 showing_signin_ = false; |
| 1218 email_.clear(); | 1155 email_.clear(); |
| 1219 password_.clear(); | 1156 password_.clear(); |
| 1220 auto_accept_ = AUTO_ACCEPT_NONE; | 1157 auto_accept_ = AUTO_ACCEPT_NONE; |
| 1221 source_ = signin::SOURCE_UNKNOWN; | 1158 source_ = signin_metrics::SOURCE_UNKNOWN; |
| 1222 switched_to_advanced_ = false; | 1159 switched_to_advanced_ = false; |
| 1223 continue_url_ = GURL(); | 1160 continue_url_ = GURL(); |
| 1224 untrusted_navigations_since_signin_visit_ = 0; | 1161 untrusted_navigations_since_signin_visit_ = 0; |
| 1225 untrusted_confirmation_required_ = false; | 1162 untrusted_confirmation_required_ = false; |
| 1226 error_message_.clear(); | 1163 error_message_.clear(); |
| 1227 | 1164 |
| 1228 // Post to IO thread to clear pending email. | 1165 // Post to IO thread to clear pending email. |
| 1229 if (!do_not_clear_pending_email_) { | 1166 if (!do_not_clear_pending_email_) { |
| 1230 Profile* profile = | 1167 Profile* profile = |
| 1231 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 1168 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 | 1269 |
| 1333 // Redirect to the landing page and display an error popup. | 1270 // Redirect to the landing page and display an error popup. |
| 1334 RedirectToNtpOrAppsPage(web_contents(), source_); | 1271 RedirectToNtpOrAppsPage(web_contents(), source_); |
| 1335 LoginUIServiceFactory::GetForProfile(profile)-> | 1272 LoginUIServiceFactory::GetForProfile(profile)-> |
| 1336 DisplayLoginResult(browser, base::UTF8ToUTF16(error_message_)); | 1273 DisplayLoginResult(browser, base::UTF8ToUTF16(error_message_)); |
| 1337 CleanTransientState(); | 1274 CleanTransientState(); |
| 1338 return; | 1275 return; |
| 1339 } | 1276 } |
| 1340 | 1277 |
| 1341 if (AreWeShowingSignin(url, source_, email_)) { | 1278 if (AreWeShowingSignin(url, source_, email_)) { |
| 1342 if (!showing_signin_) { | 1279 if (!showing_signin_) |
| 1343 if (source_ == signin::SOURCE_UNKNOWN) | 1280 LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); |
| 1344 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); | |
| 1345 else | |
| 1346 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); | |
| 1347 } | |
| 1348 showing_signin_ = true; | 1281 showing_signin_ = true; |
| 1349 } | 1282 } |
| 1350 | 1283 |
| 1351 // When Gaia finally redirects to the continue URL, Gaia will add some | 1284 // When Gaia finally redirects to the continue URL, Gaia will add some |
| 1352 // extra query parameters. So ignore the parameters when checking to see | 1285 // extra query parameters. So ignore the parameters when checking to see |
| 1353 // if the user has continued. Sometimes locales will redirect to a country- | 1286 // if the user has continued. Sometimes locales will redirect to a country- |
| 1354 // specific TLD so just make sure it's a valid domain instead of comparing | 1287 // specific TLD so just make sure it's a valid domain instead of comparing |
| 1355 // for an exact match. | 1288 // for an exact match. |
| 1356 GURL::Replacements replacements; | 1289 GURL::Replacements replacements; |
| 1357 replacements.ClearQuery(); | 1290 replacements.ClearQuery(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 // During an explicit sign in, if the user has not yet reached the final | 1338 // During an explicit sign in, if the user has not yet reached the final |
| 1406 // continue URL, wait for it to arrive. Note that Gaia will add some extra | 1339 // continue URL, wait for it to arrive. Note that Gaia will add some extra |
| 1407 // query parameters to the continue URL. Ignore them when checking to | 1340 // query parameters to the continue URL. Ignore them when checking to |
| 1408 // see if the user has continued. | 1341 // see if the user has continued. |
| 1409 // | 1342 // |
| 1410 // If this is not an explicit sign in, we don't need to check if we landed | 1343 // If this is not an explicit sign in, we don't need to check if we landed |
| 1411 // on the right continue URL. This is important because the continue URL | 1344 // on the right continue URL. This is important because the continue URL |
| 1412 // may itself lead to a redirect, which means this function will never see | 1345 // may itself lead to a redirect, which means this function will never see |
| 1413 // the continue URL go by. | 1346 // the continue URL go by. |
| 1414 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT) { | 1347 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT) { |
| 1415 DCHECK(source_ != signin::SOURCE_UNKNOWN); | 1348 DCHECK(source_ != signin_metrics::SOURCE_UNKNOWN); |
| 1416 if (!continue_url_match) { | 1349 if (!continue_url_match) { |
| 1417 VLOG(1) << "OneClickSigninHelper::DidStopLoading: invalid url='" | 1350 VLOG(1) << "OneClickSigninHelper::DidStopLoading: invalid url='" |
| 1418 << url.spec() | 1351 << url.spec() |
| 1419 << "' expected continue url=" << continue_url_; | 1352 << "' expected continue url=" << continue_url_; |
| 1420 CleanTransientState(); | 1353 CleanTransientState(); |
| 1421 return; | 1354 return; |
| 1422 } | 1355 } |
| 1423 | 1356 |
| 1424 // In explicit sign ins, the user may have changed the box | 1357 // In explicit sign ins, the user may have changed the box |
| 1425 // "Let me choose what to sync". This is reflected as a change in the | 1358 // "Let me choose what to sync". This is reflected as a change in the |
| 1426 // source of the continue URL. Make one last check of the current URL | 1359 // source of the continue URL. Make one last check of the current URL |
| 1427 // to see if there is a valid source. If so, it overrides the | 1360 // to see if there is a valid source. If so, it overrides the |
| 1428 // current source. | 1361 // current source. |
| 1429 // | 1362 // |
| 1430 // If the source was changed to SOURCE_SETTINGS, we want | 1363 // If the source was changed to SOURCE_SETTINGS, we want |
| 1431 // OneClickSigninSyncStarter to reuse the current tab to display the | 1364 // OneClickSigninSyncStarter to reuse the current tab to display the |
| 1432 // advanced configuration. | 1365 // advanced configuration. |
| 1433 signin::Source source = signin::GetSourceForPromoURL(url); | 1366 signin_metrics::Source source = signin::GetSourceForPromoURL(url); |
| 1434 if (source != source_) { | 1367 if (source != source_) { |
| 1435 source_ = source; | 1368 source_ = source; |
| 1436 switched_to_advanced_ = source == signin::SOURCE_SETTINGS; | 1369 switched_to_advanced_ = source == signin_metrics::SOURCE_SETTINGS; |
| 1437 } | 1370 } |
| 1438 } | 1371 } |
| 1439 | 1372 |
| 1440 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 1373 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 1441 | 1374 |
| 1442 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | 1375 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." |
| 1443 << " auto_accept=" << auto_accept_ | 1376 << " auto_accept=" << auto_accept_ |
| 1444 << " source=" << source_; | 1377 << " source=" << source_; |
| 1445 | 1378 |
| 1446 switch (auto_accept_) { | 1379 switch (auto_accept_) { |
| 1447 case AUTO_ACCEPT_NONE: | 1380 case AUTO_ACCEPT_NONE: |
| 1448 if (showing_signin_) | 1381 if (showing_signin_) |
| 1449 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); | 1382 LogHistogramValue(signin_metrics::HISTOGRAM_DISMISSED); |
| 1450 break; | 1383 break; |
| 1451 case AUTO_ACCEPT_ACCEPTED: | 1384 case AUTO_ACCEPT_ACCEPTED: |
| 1452 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1385 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
| 1453 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1386 LogHistogramValue(signin_metrics::HISTOGRAM_WITH_DEFAULTS); |
| 1454 SigninManager::DisableOneClickSignIn(profile->GetPrefs()); | 1387 SigninManager::DisableOneClickSignIn(profile->GetPrefs()); |
| 1455 // Start syncing with the default settings - prompt the user to sign in | 1388 // Start syncing with the default settings - prompt the user to sign in |
| 1456 // first. | 1389 // first. |
| 1457 if (!do_not_start_sync_for_testing_) { | 1390 if (!do_not_start_sync_for_testing_) { |
| 1458 StartSync( | 1391 StartSync( |
| 1459 StartSyncArgs(profile, browser, auto_accept_, | 1392 StartSyncArgs(profile, browser, auto_accept_, |
| 1460 session_index_, email_, password_, "", | 1393 session_index_, email_, password_, "", |
| 1461 NULL /* don't force sync setup in same tab */, | 1394 NULL /* don't force sync setup in same tab */, |
| 1462 true /* confirmation_required */, source_, | 1395 true /* confirmation_required */, source_, |
| 1463 CreateSyncStarterCallback()), | 1396 CreateSyncStarterCallback()), |
| 1464 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1397 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 1465 } | 1398 } |
| 1466 break; | 1399 break; |
| 1467 case AUTO_ACCEPT_CONFIGURE: | 1400 case AUTO_ACCEPT_CONFIGURE: |
| 1468 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1401 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
| 1469 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1402 LogHistogramValue(signin_metrics::HISTOGRAM_WITH_ADVANCED); |
| 1470 SigninManager::DisableOneClickSignIn(profile->GetPrefs()); | 1403 SigninManager::DisableOneClickSignIn(profile->GetPrefs()); |
| 1471 // Display the extra confirmation (even in the SAML case) in case this | 1404 // Display the extra confirmation (even in the SAML case) in case this |
| 1472 // was an untrusted renderer. | 1405 // was an untrusted renderer. |
| 1473 if (!do_not_start_sync_for_testing_) { | 1406 if (!do_not_start_sync_for_testing_) { |
| 1474 StartSync( | 1407 StartSync( |
| 1475 StartSyncArgs(profile, browser, auto_accept_, | 1408 StartSyncArgs(profile, browser, auto_accept_, |
| 1476 session_index_, email_, password_, "", | 1409 session_index_, email_, password_, "", |
| 1477 NULL /* don't force sync setup in same tab */, | 1410 NULL /* don't force sync setup in same tab */, |
| 1478 true /* confirmation_required */, source_, | 1411 true /* confirmation_required */, source_, |
| 1479 CreateSyncStarterCallback()), | 1412 CreateSyncStarterCallback()), |
| 1480 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1413 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 1481 } | 1414 } |
| 1482 break; | 1415 break; |
| 1483 case AUTO_ACCEPT_EXPLICIT: { | 1416 case AUTO_ACCEPT_EXPLICIT: { |
| 1484 signin::Source original_source = | 1417 signin_metrics::Source original_source = |
| 1485 signin::GetSourceForPromoURL(original_continue_url_); | 1418 signin::GetSourceForPromoURL(original_continue_url_); |
| 1486 if (switched_to_advanced_) { | 1419 if (switched_to_advanced_) { |
| 1487 LogHistogramValue(original_source, | 1420 LogHistogramValue(signin_metrics::HISTOGRAM_WITH_ADVANCED); |
| 1488 one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1421 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
| 1489 LogHistogramValue(original_source, | |
| 1490 one_click_signin::HISTOGRAM_ACCEPTED); | |
| 1491 } else { | 1422 } else { |
| 1492 LogHistogramValue(source_, one_click_signin::HISTOGRAM_ACCEPTED); | 1423 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
| 1493 LogHistogramValue(source_, one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1424 LogHistogramValue(signin_metrics::HISTOGRAM_WITH_DEFAULTS); |
| 1494 } | 1425 } |
| 1495 | 1426 |
| 1496 // - If sign in was initiated from the NTP or the hotdog menu, sync with | 1427 // - If sign in was initiated from the NTP or the hotdog menu, sync with |
| 1497 // default settings. | 1428 // default settings. |
| 1498 // - If sign in was initiated from the settings page for first time sync | 1429 // - If sign in was initiated from the settings page for first time sync |
| 1499 // set up, show the advanced sync settings dialog. | 1430 // set up, show the advanced sync settings dialog. |
| 1500 // - If sign in was initiated from the settings page due to a re-auth when | 1431 // - If sign in was initiated from the settings page due to a re-auth when |
| 1501 // sync was already setup, simply navigate back to the settings page. | 1432 // sync was already setup, simply navigate back to the settings page. |
| 1502 ProfileSyncService* sync_service = | 1433 ProfileSyncService* sync_service = |
| 1503 ProfileSyncServiceFactory::GetForProfile(profile); | 1434 ProfileSyncServiceFactory::GetForProfile(profile); |
| 1504 SigninErrorController* error_controller = | 1435 SigninErrorController* error_controller = |
| 1505 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | 1436 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 1506 signin_error_controller(); | 1437 signin_error_controller(); |
| 1507 | 1438 |
| 1508 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1439 OneClickSigninSyncStarter::StartSyncMode start_mode = |
| 1509 source_ == signin::SOURCE_SETTINGS ? | 1440 source_ == signin_metrics::SOURCE_SETTINGS ? |
| 1510 (error_controller->HasError() && | 1441 (error_controller->HasError() && |
| 1511 sync_service && sync_service->HasSyncSetupCompleted()) ? | 1442 sync_service && sync_service->HasSyncSetupCompleted()) ? |
| 1512 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : | 1443 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : |
| 1513 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1444 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
| 1514 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1445 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
| 1515 | 1446 |
| 1516 if (!HandleCrossAccountError(profile, session_index_, email_, password_, | 1447 if (!HandleCrossAccountError(profile, session_index_, email_, password_, |
| 1517 "", auto_accept_, source_, start_mode, | 1448 "", auto_accept_, source_, start_mode, |
| 1518 CreateSyncStarterCallback())) { | 1449 CreateSyncStarterCallback())) { |
| 1519 if (!do_not_start_sync_for_testing_) { | 1450 if (!do_not_start_sync_for_testing_) { |
| 1520 StartSync( | 1451 StartSync( |
| 1521 StartSyncArgs(profile, browser, auto_accept_, | 1452 StartSyncArgs(profile, browser, auto_accept_, |
| 1522 session_index_, email_, password_, "", | 1453 session_index_, email_, password_, "", |
| 1523 contents, | 1454 contents, |
| 1524 untrusted_confirmation_required_, source_, | 1455 untrusted_confirmation_required_, source_, |
| 1525 CreateSyncStarterCallback()), | 1456 CreateSyncStarterCallback()), |
| 1526 start_mode); | 1457 start_mode); |
| 1527 } | 1458 } |
| 1528 | 1459 |
| 1529 // If this explicit sign in is not from settings page/webstore, show | 1460 // If this explicit sign in is not from settings page/webstore, show |
| 1530 // the NTP/Apps page after sign in completes. In the case of the | 1461 // the NTP/Apps page after sign in completes. In the case of the |
| 1531 // settings page, it will get auto-closed after sync setup. In the case | 1462 // settings page, it will get auto-closed after sync setup. In the case |
| 1532 // of webstore, it will redirect back to webstore. | 1463 // of webstore, it will redirect back to webstore. |
| 1533 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); | 1464 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); |
| 1534 } | 1465 } |
| 1535 | 1466 |
| 1536 // Observe the sync service if the settings tab requested a gaia sign in, | 1467 // Observe the sync service if the settings tab requested a gaia sign in, |
| 1537 // so that when sign in and sync setup are successful, we can redirect to | 1468 // so that when sign in and sync setup are successful, we can redirect to |
| 1538 // the correct URL, or auto-close the gaia sign in tab. | 1469 // the correct URL, or auto-close the gaia sign in tab. |
| 1539 if (original_source == signin::SOURCE_SETTINGS) { | 1470 if (original_source == signin_metrics::SOURCE_SETTINGS) { |
| 1540 // The observer deletes itself once it's done. | 1471 // The observer deletes itself once it's done. |
| 1541 new OneClickSigninSyncObserver(contents, original_continue_url_); | 1472 new OneClickSigninSyncObserver(contents, original_continue_url_); |
| 1542 } | 1473 } |
| 1543 break; | 1474 break; |
| 1544 } | 1475 } |
| 1545 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: | 1476 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: |
| 1546 AddEmailToOneClickRejectedList(profile, email_); | 1477 AddEmailToOneClickRejectedList(profile, email_); |
| 1547 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); | 1478 LogHistogramValue(signin_metrics::HISTOGRAM_REJECTED); |
| 1548 break; | 1479 break; |
| 1549 default: | 1480 default: |
| 1550 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 1481 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
| 1551 break; | 1482 break; |
| 1552 } | 1483 } |
| 1553 | 1484 |
| 1554 CleanTransientState(); | 1485 CleanTransientState(); |
| 1555 } | 1486 } |
| 1556 | 1487 |
| 1557 OneClickSigninSyncStarter::Callback | 1488 OneClickSigninSyncStarter::Callback |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1572 // If the web contents is showing a blank page and not about to be closed, | 1503 // If the web contents is showing a blank page and not about to be closed, |
| 1573 // redirect to the NTP or apps page. | 1504 // redirect to the NTP or apps page. |
| 1574 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1505 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
| 1575 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1506 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
| 1576 RedirectToNtpOrAppsPage( | 1507 RedirectToNtpOrAppsPage( |
| 1577 web_contents(), | 1508 web_contents(), |
| 1578 signin::GetSourceForPromoURL(original_continue_url_)); | 1509 signin::GetSourceForPromoURL(original_continue_url_)); |
| 1579 } | 1510 } |
| 1580 } | 1511 } |
| 1581 } | 1512 } |
| OLD | NEW |