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 11 matching lines...) Expand all Loading... |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/supports_user_data.h" | 25 #include "base/supports_user_data.h" |
26 #include "base/values.h" | 26 #include "base/values.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
30 #include "chrome/browser/history/history_service.h" | 30 #include "chrome/browser/history/history_service.h" |
31 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
| 32 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
32 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/profiles/profile_info_cache.h" | 34 #include "chrome/browser/profiles/profile_info_cache.h" |
34 #include "chrome/browser/profiles/profile_io_data.h" | 35 #include "chrome/browser/profiles/profile_io_data.h" |
35 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
36 #include "chrome/browser/search/search.h" | 37 #include "chrome/browser/search/search.h" |
37 #include "chrome/browser/signin/chrome_signin_client.h" | 38 #include "chrome/browser/signin/chrome_signin_client.h" |
38 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 39 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
39 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
40 #include "chrome/browser/signin/signin_manager_factory.h" | 41 #include "chrome/browser/signin/signin_manager_factory.h" |
41 #include "chrome/browser/signin/signin_names_io_thread.h" | 42 #include "chrome/browser/signin/signin_names_io_thread.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 666 } |
666 | 667 |
667 | 668 |
668 // OneClickSigninHelper ------------------------------------------------------- | 669 // OneClickSigninHelper ------------------------------------------------------- |
669 | 670 |
670 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); | 671 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); |
671 | 672 |
672 // static | 673 // static |
673 const int OneClickSigninHelper::kMaxNavigationsSince = 10; | 674 const int OneClickSigninHelper::kMaxNavigationsSince = 10; |
674 | 675 |
675 OneClickSigninHelper::OneClickSigninHelper( | 676 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
676 content::WebContents* web_contents, | |
677 password_manager::PasswordManager* password_manager) | |
678 : content::WebContentsObserver(web_contents), | 677 : content::WebContentsObserver(web_contents), |
679 showing_signin_(false), | 678 showing_signin_(false), |
680 auto_accept_(AUTO_ACCEPT_NONE), | 679 auto_accept_(AUTO_ACCEPT_NONE), |
681 source_(signin::SOURCE_UNKNOWN), | 680 source_(signin::SOURCE_UNKNOWN), |
682 switched_to_advanced_(false), | 681 switched_to_advanced_(false), |
683 untrusted_navigations_since_signin_visit_(0), | 682 untrusted_navigations_since_signin_visit_(0), |
684 untrusted_confirmation_required_(false), | 683 untrusted_confirmation_required_(false), |
685 do_not_clear_pending_email_(false), | 684 do_not_clear_pending_email_(false), |
686 do_not_start_sync_for_testing_(false), | 685 do_not_start_sync_for_testing_(false), |
687 weak_pointer_factory_(this) { | 686 weak_pointer_factory_(this) { |
| 687 ChromePasswordManagerClient* client = |
| 688 ChromePasswordManagerClient::FromWebContents(web_contents); |
688 // May be NULL during testing. | 689 // May be NULL during testing. |
689 if (password_manager) { | 690 if (client) { |
690 password_manager->AddSubmissionCallback( | 691 client->GetPasswordManager()->AddSubmissionCallback( |
691 base::Bind(&OneClickSigninHelper::PasswordSubmitted, | 692 base::Bind(&OneClickSigninHelper::PasswordSubmitted, |
692 weak_pointer_factory_.GetWeakPtr())); | 693 weak_pointer_factory_.GetWeakPtr())); |
693 } | 694 } |
694 } | 695 } |
695 | 696 |
696 OneClickSigninHelper::~OneClickSigninHelper() {} | 697 OneClickSigninHelper::~OneClickSigninHelper() {} |
697 | 698 |
698 // static | 699 // static |
699 void OneClickSigninHelper::LogHistogramValue( | 700 void OneClickSigninHelper::LogHistogramValue( |
700 signin::Source source, int action) { | 701 signin::Source source, int action) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 12, | 753 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 12, |
753 kSourceEnumHasChangedButNotThisSwitchStatement); | 754 kSourceEnumHasChangedButNotThisSwitchStatement); |
754 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action, | 755 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action, |
755 one_click_signin::HISTOGRAM_MAX); | 756 one_click_signin::HISTOGRAM_MAX); |
756 } | 757 } |
757 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, | 758 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
758 one_click_signin::HISTOGRAM_MAX); | 759 one_click_signin::HISTOGRAM_MAX); |
759 } | 760 } |
760 | 761 |
761 // static | 762 // static |
762 void OneClickSigninHelper::CreateForWebContentsWithPasswordManager( | |
763 content::WebContents* contents, | |
764 password_manager::PasswordManager* password_manager) { | |
765 if (!FromWebContents(contents)) { | |
766 contents->SetUserData(UserDataKey(), | |
767 new OneClickSigninHelper(contents, password_manager)); | |
768 } | |
769 } | |
770 | |
771 // static | |
772 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, | 763 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, |
773 CanOfferFor can_offer_for, | 764 CanOfferFor can_offer_for, |
774 const std::string& email, | 765 const std::string& email, |
775 std::string* error_message) { | 766 std::string* error_message) { |
776 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 767 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
777 VLOG(1) << "OneClickSigninHelper::CanOffer"; | 768 VLOG(1) << "OneClickSigninHelper::CanOffer"; |
778 | 769 |
779 if (error_message) | 770 if (error_message) |
780 error_message->clear(); | 771 error_message->clear(); |
781 | 772 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 // If the web contents is showing a blank page and not about to be closed, | 1572 // If the web contents is showing a blank page and not about to be closed, |
1582 // redirect to the NTP or apps page. | 1573 // redirect to the NTP or apps page. |
1583 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1574 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
1584 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1575 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
1585 RedirectToNtpOrAppsPage( | 1576 RedirectToNtpOrAppsPage( |
1586 web_contents(), | 1577 web_contents(), |
1587 signin::GetSourceForPromoURL(original_continue_url_)); | 1578 signin::GetSourceForPromoURL(original_continue_url_)); |
1588 } | 1579 } |
1589 } | 1580 } |
1590 } | 1581 } |
OLD | NEW |