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 22 matching lines...) Expand all Loading... | |
33 #include "chrome/browser/signin/signin_names_io_thread.h" | 33 #include "chrome/browser/signin/signin_names_io_thread.h" |
34 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
35 #include "chrome/browser/sync/profile_sync_service_factory.h" | 35 #include "chrome/browser/sync/profile_sync_service_factory.h" |
36 #include "chrome/browser/sync/sync_prefs.h" | 36 #include "chrome/browser/sync/sync_prefs.h" |
37 #include "chrome/browser/tab_contents/tab_util.h" | 37 #include "chrome/browser/tab_contents/tab_util.h" |
38 #include "chrome/browser/ui/browser_finder.h" | 38 #include "chrome/browser/ui/browser_finder.h" |
39 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
40 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 40 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
41 #include "chrome/browser/ui/sync/one_click_signin_infobar_delegate.h" | 41 #include "chrome/browser/ui/sync/one_click_signin_infobar_delegate.h" |
42 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 42 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
43 #include "chrome/common/one_click_signin_messages.h" | |
43 #include "chrome/common/chrome_notification_types.h" | 44 #include "chrome/common/chrome_notification_types.h" |
44 #include "chrome/common/chrome_switches.h" | 45 #include "chrome/common/chrome_switches.h" |
45 #include "chrome/common/chrome_version_info.h" | 46 #include "chrome/common/chrome_version_info.h" |
47 #include "chrome/common/net/url_util.h" | |
46 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
47 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
48 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
49 #include "content/public/browser/page_navigator.h" | 51 #include "content/public/browser/page_navigator.h" |
50 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
51 #include "content/public/browser/web_contents_view.h" | 53 #include "content/public/browser/web_contents_view.h" |
52 #include "content/public/common/frame_navigate_params.h" | 54 #include "content/public/common/frame_navigate_params.h" |
53 #include "content/public/common/page_transition_types.h" | 55 #include "content/public/common/page_transition_types.h" |
54 #include "content/public/common/password_form.h" | 56 #include "content/public/common/password_form.h" |
55 #include "google_apis/gaia/gaia_auth_util.h" | 57 #include "google_apis/gaia/gaia_auth_util.h" |
56 #include "google_apis/gaia/gaia_urls.h" | 58 #include "google_apis/gaia/gaia_urls.h" |
57 #include "googleurl/src/gurl.h" | 59 #include "googleurl/src/gurl.h" |
58 #include "grit/chromium_strings.h" | 60 #include "grit/chromium_strings.h" |
59 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
60 #include "grit/theme_resources.h" | 62 #include "grit/theme_resources.h" |
63 #include "ipc/ipc_message_macros.h" | |
61 #include "net/base/url_util.h" | 64 #include "net/base/url_util.h" |
62 #include "net/cookies/cookie_monster.h" | 65 #include "net/cookies/cookie_monster.h" |
63 #include "net/url_request/url_request.h" | 66 #include "net/url_request/url_request.h" |
64 #include "ui/base/l10n/l10n_util.h" | 67 #include "ui/base/l10n/l10n_util.h" |
65 #include "ui/base/resource/resource_bundle.h" | 68 #include "ui/base/resource/resource_bundle.h" |
66 | 69 |
67 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); | 70 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); |
68 | 71 |
69 namespace { | 72 namespace { |
70 | 73 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 | 754 |
752 // Post to IO thread to clear pending email. | 755 // Post to IO thread to clear pending email. |
753 Profile* profile = | 756 Profile* profile = |
754 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 757 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
755 content::BrowserThread::PostTask( | 758 content::BrowserThread::PostTask( |
756 content::BrowserThread::IO, FROM_HERE, | 759 content::BrowserThread::IO, FROM_HERE, |
757 base::Bind(&ClearPendingEmailOnIOThread, | 760 base::Bind(&ClearPendingEmailOnIOThread, |
758 base::Unretained(profile->GetResourceContext()))); | 761 base::Unretained(profile->GetResourceContext()))); |
759 } | 762 } |
760 | 763 |
761 void OneClickSigninHelper::DidNavigateAnyFrame( | 764 bool OneClickSigninHelper::OnMessageReceived(const IPC::Message& message) { |
762 const content::LoadCommittedDetails& details, | 765 bool handled = true; |
763 const content::FrameNavigateParams& params) { | 766 IPC_BEGIN_MESSAGE_MAP(OneClickSigninHelper, message) |
767 IPC_MESSAGE_HANDLER(OneClickSigninHostMsg_FormSubmitted, OnFormSubmitted) | |
768 IPC_MESSAGE_UNHANDLED(handled = false) | |
769 IPC_END_MESSAGE_MAP() | |
770 | |
771 return handled; | |
772 } | |
773 | |
774 bool OneClickSigninHelper::OnFormSubmitted(const content::PasswordForm& form) { | |
775 // |password_| used to be set in DidNavigateAnyFrame, this is too late because | |
776 // it is not executed until the end of redirect chains and password may | |
777 // get lost if one of the redirects requires context swap. | |
778 | |
764 // We only need to scrape the password for Gaia logins. | 779 // We only need to scrape the password for Gaia logins. |
765 const content::PasswordForm& form = params.password_form; | |
766 if (form.origin.is_valid() && | 780 if (form.origin.is_valid() && |
767 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { | 781 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { |
768 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; | 782 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; |
769 password_ = UTF16ToUTF8(params.password_form.password_value); | 783 password_ = UTF16ToUTF8(form.password_value); |
770 } | 784 } |
785 | |
786 return true; | |
771 } | 787 } |
772 | 788 |
773 void OneClickSigninHelper::DidStopLoading( | 789 void OneClickSigninHelper::DidStopLoading( |
774 content::RenderViewHost* render_view_host) { | 790 content::RenderViewHost* render_view_host) { |
775 // If the user left the sign in process, clear all members. | 791 // If the user left the sign in process, clear all members. |
776 // TODO(rogerta): might need to allow some youtube URLs. | 792 // TODO(rogerta): might need to allow some youtube URLs. |
777 content::WebContents* contents = web_contents(); | 793 content::WebContents* contents = web_contents(); |
778 const GURL url = contents->GetURL(); | 794 const GURL url = contents->GetURL(); |
779 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); | 795 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); |
780 | 796 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 AddEmailToOneClickRejectedList(profile, email_); | 911 AddEmailToOneClickRejectedList(profile, email_); |
896 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 912 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", |
897 one_click_signin::HISTOGRAM_REJECTED, | 913 one_click_signin::HISTOGRAM_REJECTED, |
898 one_click_signin::HISTOGRAM_MAX); | 914 one_click_signin::HISTOGRAM_MAX); |
899 break; | 915 break; |
900 default: | 916 default: |
901 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 917 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
902 break; | 918 break; |
903 } | 919 } |
904 | 920 |
905 // If this explicit sign in is not from settings page, show the NTP after | 921 // If this explicit sign in is not from settings page/webostre, show the NTP |
Charlie Reis
2013/02/01 19:40:50
nit: webstore
| |
906 // sign in completes. In the case of the settings page, it will get closed | 922 // after sign in completes. In the case of the settings page, it will get |
907 // by SyncSetupHandler. | 923 // closed by SyncSetupHandler. In the case of webstore, it will redirect back |
924 // to webstore. | |
908 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && | 925 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && |
909 source_ != SyncPromoUI::SOURCE_SETTINGS) { | 926 source_ != SyncPromoUI::SOURCE_SETTINGS && |
927 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | |
910 signin_tracker_.reset(new SigninTracker(profile, this)); | 928 signin_tracker_.reset(new SigninTracker(profile, this)); |
911 } | 929 } |
912 | 930 |
913 CleanTransientState(); | 931 CleanTransientState(); |
914 } | 932 } |
915 | 933 |
916 void OneClickSigninHelper::GaiaCredentialsValid() { | 934 void OneClickSigninHelper::GaiaCredentialsValid() { |
917 } | 935 } |
918 | 936 |
919 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { | 937 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { |
(...skipping 13 matching lines...) Expand all Loading... | |
933 break; | 951 break; |
934 } | 952 } |
935 } | 953 } |
936 | 954 |
937 RedirectToNTP(); | 955 RedirectToNTP(); |
938 } | 956 } |
939 | 957 |
940 void OneClickSigninHelper::SigninSuccess() { | 958 void OneClickSigninHelper::SigninSuccess() { |
941 RedirectToNTP(); | 959 RedirectToNTP(); |
942 } | 960 } |
OLD | NEW |