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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 AUTO_ACCEPT_EXPLICIT | 43 AUTO_ACCEPT_EXPLICIT |
44 }; | 44 }; |
45 | 45 |
46 // Return value of CanOfferOnIOThread(). | 46 // Return value of CanOfferOnIOThread(). |
47 enum Offer { | 47 enum Offer { |
48 CAN_OFFER, | 48 CAN_OFFER, |
49 DONT_OFFER, | 49 DONT_OFFER, |
50 IGNORE_REQUEST | 50 IGNORE_REQUEST |
51 }; | 51 }; |
52 | 52 |
53 // Argument to CanOffer(). | |
54 enum CanOfferFor { | |
55 CAN_OFFER_FOR_ALL, | |
56 CAN_OFFER_FOR_INTERSTITAL_ONLY, | |
57 }; | |
58 | |
53 virtual ~OneClickSigninHelper(); | 59 virtual ~OneClickSigninHelper(); |
54 | 60 |
55 // Called only by tests to associate information with a given request. | 61 // Called only by tests to associate information with a given request. |
56 static void AssociateWithRequestForTesting(base::SupportsUserData* request, | 62 static void AssociateWithRequestForTesting(base::SupportsUserData* request, |
57 const std::string& email); | 63 const std::string& email); |
58 | 64 |
59 // Returns true if the one-click signin feature can be offered at this time. | 65 // Returns true if the one-click signin feature can be offered at this time. |
60 // It can be offered if the contents is not in an incognito window. If | 66 // If |email| is not empty, then the profile is checked to see if it's |
61 // |check_connected| is true, then the profile is checked to see if it's | |
62 // already connected to a google account or if the user has already rejected | 67 // already connected to a google account or if the user has already rejected |
63 // one-click sign-in with this email, in which cases a one click signin | 68 // one-click sign-in with this email, in which cases a one click signin |
64 // should not be offered. | 69 // should not be offered. |
70 // | |
71 // If |can_offer_for| is |CAN_OFFER_FOR_INTERSTITAL_ONLY|, then only do the | |
72 // checks that would affect the intertitial page. Otherwise, do the checks | |
Andrew T Wilson (Slow)
2012/12/03 14:54:49
intertitial->interstitial
Roger Tawa OOO till Jul 10th
2012/12/03 22:26:54
Done.
| |
73 // that would affect the interterial and the explicit sign ins. | |
Andrew T Wilson (Slow)
2012/12/03 14:54:49
interterial->interstitial
Roger Tawa OOO till Jul 10th
2012/12/03 22:26:54
Done.
| |
74 // | |
75 // Returns an explanation as a string resource ID for why one-clicked cannot | |
76 // be offered in |error_string_id|. |error_string_id| is valid only if | |
77 // the return value is false. | |
65 static bool CanOffer(content::WebContents* web_contents, | 78 static bool CanOffer(content::WebContents* web_contents, |
79 CanOfferFor can_offer_for, | |
66 const std::string& email, | 80 const std::string& email, |
67 bool check_connected); | 81 int* error_message_id); |
68 | 82 |
69 // Returns true if the one-click signin feature can be offered at this time. | 83 // Returns true if the one-click signin feature can be offered at this time. |
70 // It can be offered if the io_data is not in an incognito window and if the | 84 // It can be offered if the io_data is not in an incognito window and if the |
71 // origin of |url| is a valid Gaia sign in origin. This function is meant | 85 // origin of |url| is a valid Gaia sign in origin. This function is meant |
72 // to called only from the IO thread. | 86 // to called only from the IO thread. |
73 static Offer CanOfferOnIOThread(net::URLRequest* request, | 87 static Offer CanOfferOnIOThread(net::URLRequest* request, |
74 ProfileIOData* io_data); | 88 ProfileIOData* io_data); |
75 | 89 |
76 // Initialize a finch experiment for the infobar. | 90 // Initialize a finch experiment for the infobar. |
77 static void InitializeFieldTrial(); | 91 static void InitializeFieldTrial(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 ProfileIOData* io_data); | 134 ProfileIOData* io_data); |
121 | 135 |
122 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. | 136 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. |
123 static void ShowInfoBarUIThread(const std::string& session_index, | 137 static void ShowInfoBarUIThread(const std::string& session_index, |
124 const std::string& email, | 138 const std::string& email, |
125 AutoAccept auto_accept, | 139 AutoAccept auto_accept, |
126 SyncPromoUI::Source source, | 140 SyncPromoUI::Source source, |
127 int child_id, | 141 int child_id, |
128 int route_id); | 142 int route_id); |
129 | 143 |
144 void RedirectToNTP(); | |
145 | |
146 // Clear all data member of the helper, except for the error. | |
147 void CleanTransientState(); | |
148 | |
130 // content::WebContentsObserver overrides. | 149 // content::WebContentsObserver overrides. |
131 virtual void DidNavigateAnyFrame( | 150 virtual void DidNavigateAnyFrame( |
132 const content::LoadCommittedDetails& details, | 151 const content::LoadCommittedDetails& details, |
133 const content::FrameNavigateParams& params) OVERRIDE; | 152 const content::FrameNavigateParams& params) OVERRIDE; |
134 virtual void DidStopLoading( | 153 virtual void DidStopLoading( |
135 content::RenderViewHost* render_view_host) OVERRIDE; | 154 content::RenderViewHost* render_view_host) OVERRIDE; |
136 | 155 |
137 // SigninTracker::Observer override. | 156 // SigninTracker::Observer override. |
138 virtual void GaiaCredentialsValid() OVERRIDE; | 157 virtual void GaiaCredentialsValid() OVERRIDE; |
139 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | 158 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; |
140 virtual void SigninSuccess() OVERRIDE; | 159 virtual void SigninSuccess() OVERRIDE; |
141 | 160 |
142 // Information about the account that has just logged in. | 161 // Information about the account that has just logged in. |
143 std::string session_index_; | 162 std::string session_index_; |
144 std::string email_; | 163 std::string email_; |
145 std::string password_; | 164 std::string password_; |
146 AutoAccept auto_accept_; | 165 AutoAccept auto_accept_; |
147 SyncPromoUI::Source source_; | 166 SyncPromoUI::Source source_; |
167 std::string error_message_; | |
168 | |
148 scoped_ptr<SigninTracker> signin_tracker_; | 169 scoped_ptr<SigninTracker> signin_tracker_; |
149 | 170 |
150 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); | 171 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); |
151 }; | 172 }; |
152 | 173 |
153 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 174 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
OLD | NEW |