| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "grit/chromium_strings.h" | 41 #include "grit/chromium_strings.h" |
| 42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| 43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 44 #include "net/cookies/cookie_monster.h" | 44 #include "net/cookies/cookie_monster.h" |
| 45 #include "net/url_request/url_request.h" | 45 #include "net/url_request/url_request.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 48 #include "webkit/forms/password_form.h" | 48 #include "webkit/forms/password_form.h" |
| 49 #include "webkit/forms/password_form_dom_manager.h" | 49 #include "webkit/forms/password_form_dom_manager.h" |
| 50 | 50 |
| 51 int OneClickSigninHelper::kUserDataKey; |
| 52 |
| 51 namespace { | 53 namespace { |
| 52 | 54 |
| 53 // Set to true if this chrome instance is in the blue-button-on-white-bar | 55 // Set to true if this chrome instance is in the blue-button-on-white-bar |
| 54 // experimental group. | 56 // experimental group. |
| 55 bool use_blue_on_white = false; | 57 bool use_blue_on_white = false; |
| 56 | 58 |
| 57 // Start syncing with the given user information. | 59 // Start syncing with the given user information. |
| 58 void StartSync(content::WebContents* web_contents, | 60 void StartSync(content::WebContents* web_contents, |
| 59 const std::string& session_index, | 61 const std::string& session_index, |
| 60 const std::string& email, | 62 const std::string& email, |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 373 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 372 | 374 |
| 373 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, | 375 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, |
| 374 route_id); | 376 route_id); |
| 375 | 377 |
| 376 // TODO(mathp): The appearance of this infobar should be tested using a | 378 // TODO(mathp): The appearance of this infobar should be tested using a |
| 377 // browser_test. | 379 // browser_test. |
| 378 if (!web_contents || !CanOffer(web_contents, email, true)) | 380 if (!web_contents || !CanOffer(web_contents, email, true)) |
| 379 return; | 381 return; |
| 380 | 382 |
| 381 TabContents* tab_contents = TabContents::FromWebContents(web_contents); | 383 OneClickSigninHelper* one_click_signin_tab_helper = |
| 382 if (!tab_contents) | 384 OneClickSigninHelper::FromWebContents(web_contents); |
| 385 // The manager may not exist if the contents is incognito or if the profile is |
| 386 // already connected to a Google account. |
| 387 if (!one_click_signin_tab_helper) |
| 383 return; | 388 return; |
| 384 | 389 |
| 385 // Save the email in the one-click signin manager. The manager may | 390 one_click_signin_tab_helper->SaveSessionIndexAndEmail(session_index, email); |
| 386 // not exist if the contents is incognito or if the profile is already | |
| 387 // connected to a Google account. | |
| 388 OneClickSigninHelper* helper = tab_contents->one_click_signin_helper(); | |
| 389 if (helper) | |
| 390 helper->SaveSessionIndexAndEmail(session_index, email); | |
| 391 } | 391 } |
| 392 | 392 |
| 393 void OneClickSigninHelper::DidNavigateAnyFrame( | 393 void OneClickSigninHelper::DidNavigateAnyFrame( |
| 394 const content::LoadCommittedDetails& details, | 394 const content::LoadCommittedDetails& details, |
| 395 const content::FrameNavigateParams& params) { | 395 const content::FrameNavigateParams& params) { |
| 396 if (params.password_form.origin.is_valid()) | 396 if (params.password_form.origin.is_valid()) |
| 397 SavePassword(UTF16ToUTF8(params.password_form.password_value)); | 397 SavePassword(UTF16ToUTF8(params.password_form.password_value)); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void OneClickSigninHelper::DidStopLoading( | 400 void OneClickSigninHelper::DidStopLoading( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 418 session_index_ = session_index; | 418 session_index_ = session_index; |
| 419 email_ = email; | 419 email_ = email; |
| 420 } | 420 } |
| 421 | 421 |
| 422 void OneClickSigninHelper::SavePassword(const std::string& password) { | 422 void OneClickSigninHelper::SavePassword(const std::string& password) { |
| 423 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of | 423 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of |
| 424 // challenge, its possible for the user to never complete the signin. | 424 // challenge, its possible for the user to never complete the signin. |
| 425 // Should have a way to detect this and clear the password member. | 425 // Should have a way to detect this and clear the password member. |
| 426 password_ = password; | 426 password_ = password; |
| 427 } | 427 } |
| OLD | NEW |