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 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // Per-tab one-click signin helper. When a user signs in to a Google service | 28 // Per-tab one-click signin helper. When a user signs in to a Google service |
29 // and the profile is not yet connected to a Google account, will start the | 29 // and the profile is not yet connected to a Google account, will start the |
30 // process of helping the user connect his profile with one click. The process | 30 // process of helping the user connect his profile with one click. The process |
31 // begins with an infobar and is followed with a confirmation dialog explaining | 31 // begins with an infobar and is followed with a confirmation dialog explaining |
32 // more about what this means. | 32 // more about what this means. |
33 class OneClickSigninHelper | 33 class OneClickSigninHelper |
34 : public content::WebContentsObserver, | 34 : public content::WebContentsObserver, |
35 public content::WebContentsUserData<OneClickSigninHelper>, | 35 public content::WebContentsUserData<OneClickSigninHelper>, |
36 public SigninTracker::Observer { | 36 public SigninTracker::Observer { |
37 public: | 37 public: |
| 38 // Represents user's decision about sign in process. |
38 enum AutoAccept { | 39 enum AutoAccept { |
39 AUTO_ACCEPT, | 40 // User decision not yet known. Assume cancel. |
40 NO_AUTO_ACCEPT, | 41 AUTO_ACCEPT_NONE, |
| 42 |
| 43 // User has explicitly accepted to sign in. A bubble is shown with the |
| 44 // option to start sync, configure it first, or abort. |
| 45 AUTO_ACCEPT_ACCEPTED, |
| 46 |
| 47 // User has explicitly accepted to sign in, but wants to configure sync |
| 48 // settings before turing it on. |
41 AUTO_ACCEPT_CONFIGURE, | 49 AUTO_ACCEPT_CONFIGURE, |
42 REJECTED_FOR_PROFILE, | 50 |
| 51 // User has explicitly rejected to sign in. Furthermore, the user does |
| 52 // not want to be prompted to see the interstitial again in this profile. |
| 53 AUTO_ACCEPT_REJECTED_FOR_PROFILE, |
| 54 |
| 55 // This is an explicit sign in from either first run, NTP, wrench menu, |
| 56 // or settings page. The user will be signed in automatically with sync |
| 57 // enabled using default settings. |
43 AUTO_ACCEPT_EXPLICIT | 58 AUTO_ACCEPT_EXPLICIT |
44 }; | 59 }; |
45 | 60 |
46 // Return value of CanOfferOnIOThread(). | 61 // Return value of CanOfferOnIOThread(). |
47 enum Offer { | 62 enum Offer { |
48 CAN_OFFER, | 63 CAN_OFFER, |
49 DONT_OFFER, | 64 DONT_OFFER, |
50 IGNORE_REQUEST | 65 IGNORE_REQUEST |
51 }; | 66 }; |
52 | 67 |
53 // Argument to CanOffer(). | 68 // Argument to CanOffer(). |
54 enum CanOfferFor { | 69 enum CanOfferFor { |
55 CAN_OFFER_FOR_ALL, | 70 CAN_OFFER_FOR_ALL, |
56 CAN_OFFER_FOR_INTERSTITAL_ONLY, | 71 CAN_OFFER_FOR_INTERSTITAL_ONLY |
57 }; | 72 }; |
58 | 73 |
59 virtual ~OneClickSigninHelper(); | 74 virtual ~OneClickSigninHelper(); |
60 | 75 |
61 // Called only by tests to associate information with a given request. | 76 // Called only by tests to associate information with a given request. |
62 static void AssociateWithRequestForTesting(base::SupportsUserData* request, | 77 static void AssociateWithRequestForTesting(base::SupportsUserData* request, |
63 const std::string& email); | 78 const std::string& email); |
64 | 79 |
65 // Returns true if the one-click signin feature can be offered at this time. | 80 // Returns true if the one-click signin feature can be offered at this time. |
66 // If |email| is not empty, then the profile is checked to see if it's | 81 // If |email| is not empty, then the profile is checked to see if it's |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // Returns true if the one-click signin feature can be offered at this time. | 145 // Returns true if the one-click signin feature can be offered at this time. |
131 // It can be offered if the io_data is not in an incognito window and if the | 146 // It can be offered if the io_data is not in an incognito window and if the |
132 // origin of |url| is a valid Gaia sign in origin. This function is meant | 147 // origin of |url| is a valid Gaia sign in origin. This function is meant |
133 // to called only from the IO thread. | 148 // to called only from the IO thread. |
134 static Offer CanOfferOnIOThreadImpl(const GURL& url, | 149 static Offer CanOfferOnIOThreadImpl(const GURL& url, |
135 const std::string& referrer, | 150 const std::string& referrer, |
136 base::SupportsUserData* request, | 151 base::SupportsUserData* request, |
137 ProfileIOData* io_data); | 152 ProfileIOData* io_data); |
138 | 153 |
139 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. | 154 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. |
| 155 // |session_index| and |email| are extracted from the Google-Accounts-SignIn |
| 156 // header. |auto_accept| is extracted from the Google-Chrome-SignIn header. |
| 157 // |source| is used to determine which of the explicit sign in mechanism is |
| 158 // being used. |
| 159 // |
| 160 // |continue_url| is where Gaia will continue to when the sign in process is |
| 161 // done. For explicit sign ins, this is a URL chrome controls. For one-click |
| 162 // sign in, this could be any google property. This URL is used to know |
| 163 // when the sign process is over and to collect infomation from the user |
| 164 // entered on the Gaia sign in page (for explicit sign ins). |
140 static void ShowInfoBarUIThread(const std::string& session_index, | 165 static void ShowInfoBarUIThread(const std::string& session_index, |
141 const std::string& email, | 166 const std::string& email, |
142 AutoAccept auto_accept, | 167 AutoAccept auto_accept, |
143 SyncPromoUI::Source source, | 168 SyncPromoUI::Source source, |
| 169 const GURL& continue_url, |
144 int child_id, | 170 int child_id, |
145 int route_id); | 171 int route_id); |
146 | 172 |
147 void RedirectToNTP(); | 173 void RedirectToNTP(); |
148 | 174 |
149 // Clear all data member of the helper, except for the error. | 175 // Clear all data member of the helper, except for the error. |
150 void CleanTransientState(); | 176 void CleanTransientState(); |
151 | 177 |
152 // content::WebContentsObserver overrides. | 178 // content::WebContentsObserver overrides. |
153 virtual void DidNavigateAnyFrame( | 179 virtual void DidNavigateAnyFrame( |
154 const content::LoadCommittedDetails& details, | 180 const content::LoadCommittedDetails& details, |
155 const content::FrameNavigateParams& params) OVERRIDE; | 181 const content::FrameNavigateParams& params) OVERRIDE; |
156 virtual void DidStopLoading( | 182 virtual void DidStopLoading( |
157 content::RenderViewHost* render_view_host) OVERRIDE; | 183 content::RenderViewHost* render_view_host) OVERRIDE; |
158 | 184 |
159 // SigninTracker::Observer override. | 185 // SigninTracker::Observer override. |
160 virtual void GaiaCredentialsValid() OVERRIDE; | 186 virtual void GaiaCredentialsValid() OVERRIDE; |
161 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | 187 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; |
162 virtual void SigninSuccess() OVERRIDE; | 188 virtual void SigninSuccess() OVERRIDE; |
163 | 189 |
164 // Information about the account that has just logged in. | 190 // Information about the account that has just logged in. |
165 std::string session_index_; | 191 std::string session_index_; |
166 std::string email_; | 192 std::string email_; |
167 std::string password_; | 193 std::string password_; |
168 AutoAccept auto_accept_; | 194 AutoAccept auto_accept_; |
169 SyncPromoUI::Source source_; | 195 SyncPromoUI::Source source_; |
| 196 GURL continue_url_; |
170 std::string error_message_; | 197 std::string error_message_; |
171 | 198 |
172 scoped_ptr<SigninTracker> signin_tracker_; | 199 scoped_ptr<SigninTracker> signin_tracker_; |
173 | 200 |
174 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); | 201 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); |
175 }; | 202 }; |
176 | 203 |
177 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 204 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
OLD | NEW |