Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 12086069: Enable Chrome Signin from Webstore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
46 #include "chrome/common/net/url_util.h" 47 #include "chrome/common/net/url_util.h"
47 #include "chrome/common/pref_names.h" 48 #include "chrome/common/pref_names.h"
48 #include "chrome/common/url_constants.h" 49 #include "chrome/common/url_constants.h"
49 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/page_navigator.h" 51 #include "content/public/browser/page_navigator.h"
51 #include "content/public/browser/web_contents.h" 52 #include "content/public/browser/web_contents.h"
52 #include "content/public/browser/web_contents_view.h" 53 #include "content/public/browser/web_contents_view.h"
53 #include "content/public/common/frame_navigate_params.h" 54 #include "content/public/common/frame_navigate_params.h"
54 #include "content/public/common/page_transition_types.h" 55 #include "content/public/common/page_transition_types.h"
55 #include "content/public/common/password_form.h" 56 #include "content/public/common/password_form.h"
56 #include "google_apis/gaia/gaia_auth_util.h" 57 #include "google_apis/gaia/gaia_auth_util.h"
57 #include "google_apis/gaia/gaia_urls.h" 58 #include "google_apis/gaia/gaia_urls.h"
58 #include "googleurl/src/gurl.h" 59 #include "googleurl/src/gurl.h"
59 #include "grit/chromium_strings.h" 60 #include "grit/chromium_strings.h"
60 #include "grit/generated_resources.h" 61 #include "grit/generated_resources.h"
61 #include "grit/theme_resources.h" 62 #include "grit/theme_resources.h"
63 #include "ipc/ipc_message_macros.h"
62 #include "net/cookies/cookie_monster.h" 64 #include "net/cookies/cookie_monster.h"
63 #include "net/url_request/url_request.h" 65 #include "net/url_request/url_request.h"
64 #include "ui/base/l10n/l10n_util.h" 66 #include "ui/base/l10n/l10n_util.h"
65 #include "ui/base/resource/resource_bundle.h" 67 #include "ui/base/resource/resource_bundle.h"
66 68
67 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); 69 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper);
68 70
69 namespace { 71 namespace {
70 72
71 // Set to true if this chrome instance is in the blue-button-on-white-bar 73 // Set to true if this chrome instance is in the blue-button-on-white-bar
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 752
751 // Post to IO thread to clear pending email. 753 // Post to IO thread to clear pending email.
752 Profile* profile = 754 Profile* profile =
753 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 755 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
754 content::BrowserThread::PostTask( 756 content::BrowserThread::PostTask(
755 content::BrowserThread::IO, FROM_HERE, 757 content::BrowserThread::IO, FROM_HERE,
756 base::Bind(&ClearPendingEmailOnIOThread, 758 base::Bind(&ClearPendingEmailOnIOThread,
757 base::Unretained(profile->GetResourceContext()))); 759 base::Unretained(profile->GetResourceContext())));
758 } 760 }
759 761
760 void OneClickSigninHelper::DidNavigateAnyFrame( 762 bool OneClickSigninHelper::OnMessageReceived(const IPC::Message& message) {
761 const content::LoadCommittedDetails& details, 763 bool handled = true;
762 const content::FrameNavigateParams& params) { 764 IPC_BEGIN_MESSAGE_MAP(OneClickSigninHelper, message)
765 IPC_MESSAGE_HANDLER(OneClickSigninHostMsg_FormSubmitted, OnFormSubmitted)
766 IPC_MESSAGE_UNHANDLED(handled = false)
767 IPC_END_MESSAGE_MAP()
768
769 return handled;
Roger Tawa OOO till Jul 10th 2013/01/31 13:27:16 If a message is not handled here, should the base
guohui 2013/01/31 16:44:02 The base class WebContentsObserver just returns fa
770 }
771
772 bool OneClickSigninHelper::OnFormSubmitted(const content::PasswordForm& form) {
773 // |password_| used to be set in DidNavigateAnyFrame, this is too late because
774 // it is not executed until the end of redirect chains and password may
775 // get lost if one of the redirects requires context swap.
776
763 // We only need to scrape the password for Gaia logins. 777 // We only need to scrape the password for Gaia logins.
764 const content::PasswordForm& form = params.password_form;
765 if (form.origin.is_valid() && 778 if (form.origin.is_valid() &&
766 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { 779 gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) {
767 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; 780 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password";
768 password_ = UTF16ToUTF8(params.password_form.password_value); 781 password_ = UTF16ToUTF8(form.password_value);
769 } 782 }
783
784 return true;
770 } 785 }
771 786
772 void OneClickSigninHelper::DidStopLoading( 787 void OneClickSigninHelper::DidStopLoading(
773 content::RenderViewHost* render_view_host) { 788 content::RenderViewHost* render_view_host) {
774 // If the user left the sign in process, clear all members. 789 // If the user left the sign in process, clear all members.
775 // TODO(rogerta): might need to allow some youtube URLs. 790 // TODO(rogerta): might need to allow some youtube URLs.
776 content::WebContents* contents = web_contents(); 791 content::WebContents* contents = web_contents();
777 const GURL url = contents->GetURL(); 792 const GURL url = contents->GetURL();
778 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); 793 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec();
779 794
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 AddEmailToOneClickRejectedList(profile, email_); 909 AddEmailToOneClickRejectedList(profile, email_);
895 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", 910 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse",
896 one_click_signin::HISTOGRAM_REJECTED, 911 one_click_signin::HISTOGRAM_REJECTED,
897 one_click_signin::HISTOGRAM_MAX); 912 one_click_signin::HISTOGRAM_MAX);
898 break; 913 break;
899 default: 914 default:
900 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; 915 NOTREACHED() << "Invalid auto_accept=" << auto_accept_;
901 break; 916 break;
902 } 917 }
903 918
904 // If this explicit sign in is not from settings page, show the NTP after 919 // If this explicit sign in is not from settings page/webostre, show the NTP
905 // sign in completes. In the case of the settings page, it will get closed 920 // after sign in completes. In the case of the settings page, it will get
906 // by SyncSetupHandler. 921 // closed by SyncSetupHandler. In the case of webstore, it will redirect back
922 // to webstore.
907 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && 923 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT &&
908 source_ != SyncPromoUI::SOURCE_SETTINGS) { 924 source_ != SyncPromoUI::SOURCE_SETTINGS &&
925 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) {
909 signin_tracker_.reset(new SigninTracker(profile, this)); 926 signin_tracker_.reset(new SigninTracker(profile, this));
910 } 927 }
911 928
912 CleanTransientState(); 929 CleanTransientState();
913 } 930 }
914 931
915 void OneClickSigninHelper::GaiaCredentialsValid() { 932 void OneClickSigninHelper::GaiaCredentialsValid() {
916 } 933 }
917 934
918 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { 935 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) {
(...skipping 13 matching lines...) Expand all
932 break; 949 break;
933 } 950 }
934 } 951 }
935 952
936 RedirectToNTP(); 953 RedirectToNTP();
937 } 954 }
938 955
939 void OneClickSigninHelper::SigninSuccess() { 956 void OneClickSigninHelper::SigninSuccess() {
940 RedirectToNTP(); 957 RedirectToNTP();
941 } 958 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698