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" |
11 #include "chrome/browser/password_manager/password_manager.h" | |
11 #include "chrome/browser/sync/profile_sync_service_observer.h" | 12 #include "chrome/browser/sync/profile_sync_service_observer.h" |
12 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 13 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
13 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
14 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
16 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
17 | 18 |
18 class Browser; | 19 class Browser; |
19 class GURL; | 20 class GURL; |
20 class ProfileIOData; | 21 class ProfileIOData; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 DONT_OFFER, | 70 DONT_OFFER, |
70 IGNORE_REQUEST | 71 IGNORE_REQUEST |
71 }; | 72 }; |
72 | 73 |
73 // Argument to CanOffer(). | 74 // Argument to CanOffer(). |
74 enum CanOfferFor { | 75 enum CanOfferFor { |
75 CAN_OFFER_FOR_ALL, | 76 CAN_OFFER_FOR_ALL, |
76 CAN_OFFER_FOR_INTERSTITAL_ONLY | 77 CAN_OFFER_FOR_INTERSTITAL_ONLY |
77 }; | 78 }; |
78 | 79 |
80 static void CreateForWebContentsWithPasswordManager( | |
81 content::WebContents* contents, | |
82 PasswordManager* password_manager); | |
83 | |
79 virtual ~OneClickSigninHelper(); | 84 virtual ~OneClickSigninHelper(); |
80 | 85 |
81 // Returns true if the one-click signin feature can be offered at this time. | 86 // Returns true if the one-click signin feature can be offered at this time. |
82 // If |email| is not empty, then the profile is checked to see if it's | 87 // If |email| is not empty, then the profile is checked to see if it's |
83 // already connected to a google account or if the user has already rejected | 88 // already connected to a google account or if the user has already rejected |
84 // one-click sign-in with this email, in which cases a one click signin | 89 // one-click sign-in with this email, in which cases a one click signin |
85 // should not be offered. | 90 // should not be offered. |
86 // | 91 // |
87 // If |can_offer_for| is |CAN_OFFER_FOR_INTERSTITAL_ONLY|, then only do the | 92 // If |can_offer_for| is |CAN_OFFER_FOR_INTERSTITAL_ONLY|, then only do the |
88 // checks that would affect the interstitial page. Otherwise, do the checks | 93 // checks that would affect the interstitial page. Otherwise, do the checks |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 160 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
156 CanOfferOnIOThreadNoSigninCookies); | 161 CanOfferOnIOThreadNoSigninCookies); |
157 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 162 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
158 CanOfferOnIOThreadDisabledByPolicy); | 163 CanOfferOnIOThreadDisabledByPolicy); |
159 | 164 |
160 // Maximum number of navigations away from the set of valid Gaia URLs before | 165 // Maximum number of navigations away from the set of valid Gaia URLs before |
161 // clearing the internal state of the helper. This is necessary to support | 166 // clearing the internal state of the helper. This is necessary to support |
162 // SAML-based accounts, but causes bug crbug.com/181163. | 167 // SAML-based accounts, but causes bug crbug.com/181163. |
163 static const int kMaxNavigationsSince; | 168 static const int kMaxNavigationsSince; |
164 | 169 |
165 explicit OneClickSigninHelper(content::WebContents* web_contents); | 170 OneClickSigninHelper(content::WebContents* web_contents, |
171 PasswordManager* password_manager); | |
166 | 172 |
167 // Returns true if the one-click signin feature can be offered at this time. | 173 // Returns true if the one-click signin feature can be offered at this time. |
168 // It can be offered if the io_data is not in an incognito window and if the | 174 // It can be offered if the io_data is not in an incognito window and if the |
169 // origin of |url| is a valid Gaia sign in origin. This function is meant | 175 // origin of |url| is a valid Gaia sign in origin. This function is meant |
170 // to called only from the IO thread. | 176 // to called only from the IO thread. |
171 static Offer CanOfferOnIOThreadImpl(const GURL& url, | 177 static Offer CanOfferOnIOThreadImpl(const GURL& url, |
172 const std::string& referrer, | 178 const std::string& referrer, |
173 base::SupportsUserData* request, | 179 base::SupportsUserData* request, |
174 ProfileIOData* io_data); | 180 ProfileIOData* io_data); |
175 | 181 |
(...skipping 21 matching lines...) Expand all Loading... | |
197 | 203 |
198 // Clear all data member of the helper, except for the error. | 204 // Clear all data member of the helper, except for the error. |
199 void CleanTransientState(); | 205 void CleanTransientState(); |
200 | 206 |
201 // Unitests that use a TestingProfile should call this. | 207 // Unitests that use a TestingProfile should call this. |
202 // Otherwise, clearing the pending e-mail crashes because the code expects | 208 // Otherwise, clearing the pending e-mail crashes because the code expects |
203 // a real ResourceContext rather than the MockResourceContext a | 209 // a real ResourceContext rather than the MockResourceContext a |
204 // TestingProfile provides. | 210 // TestingProfile provides. |
205 void SetDoNotClearPendingEmailForTesting(); | 211 void SetDoNotClearPendingEmailForTesting(); |
206 | 212 |
207 // Grab Gaia password if available. | 213 void PasswordSubmitted(const content::PasswordForm& form); |
Ilya Sherman
2013/07/27 01:09:48
nit: Docs?
Garrett Casto
2013/08/03 00:38:42
Done.
| |
208 bool OnFormSubmitted(const content::PasswordForm& form); | |
209 | 214 |
210 // content::WebContentsObserver overrides. | 215 // content::WebContentsObserver overrides. |
211 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
212 virtual void NavigateToPendingEntry( | 216 virtual void NavigateToPendingEntry( |
213 const GURL& url, | 217 const GURL& url, |
214 content::NavigationController::ReloadType reload_type) OVERRIDE; | 218 content::NavigationController::ReloadType reload_type) OVERRIDE; |
215 virtual void DidNavigateMainFrame( | 219 virtual void DidNavigateMainFrame( |
216 const content::LoadCommittedDetails& details, | 220 const content::LoadCommittedDetails& details, |
217 const content::FrameNavigateParams& params) OVERRIDE; | 221 const content::FrameNavigateParams& params) OVERRIDE; |
218 virtual void DidStopLoading( | 222 virtual void DidStopLoading( |
219 content::RenderViewHost* render_view_host) OVERRIDE; | 223 content::RenderViewHost* render_view_host) OVERRIDE; |
220 | 224 |
221 // ProfileSyncServiceObserver. | 225 // ProfileSyncServiceObserver. |
(...skipping 28 matching lines...) Expand all Loading... | |
250 // Whether a Gaia URL during the sign in process was not handled by the | 254 // Whether a Gaia URL during the sign in process was not handled by the |
251 // dedicated sign in process (e.g. SAML login, which redirects to a | 255 // dedicated sign in process (e.g. SAML login, which redirects to a |
252 // non-google-controlled domain). | 256 // non-google-controlled domain). |
253 // This is set to true if at least one such URL is detected. | 257 // This is set to true if at least one such URL is detected. |
254 bool untrusted_confirmation_required_; | 258 bool untrusted_confirmation_required_; |
255 | 259 |
256 // Allows unittests to avoid accessing the ResourceContext for clearing a | 260 // Allows unittests to avoid accessing the ResourceContext for clearing a |
257 // pending e-mail. | 261 // pending e-mail. |
258 bool do_not_clear_pending_email_; | 262 bool do_not_clear_pending_email_; |
259 | 263 |
264 // Callback for when passwords are submitted. | |
265 PasswordManager::PasswordSubmittedCallback password_callback_; | |
Ilya Sherman
2013/07/27 01:09:48
Why does this need to be stored as a class member
Garrett Casto
2013/08/03 00:38:42
Same as PrerenderTabHelper. Removed.
| |
266 | |
260 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); | 267 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); |
261 }; | 268 }; |
262 | 269 |
263 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 270 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
OLD | NEW |