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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc

Issue 317093002: Show confirmation dialog for unsecure signin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/webui/signin/inline_login_handler_impl.h" 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/signin/about_signin_internals_factory.h" 15 #include "chrome/browser/signin/about_signin_internals_factory.h"
16 #include "chrome/browser/signin/chrome_signin_client_factory.h" 16 #include "chrome/browser/signin/chrome_signin_client_factory.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 18 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 19 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/browser_finder.h" 21 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 23 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
24 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" 24 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/browser/ui/webui/signin/inline_login_ui.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "components/signin/core/browser/about_signin_internals.h" 28 #include "components/signin/core/browser/about_signin_internals.h"
28 #include "components/signin/core/browser/profile_oauth2_token_service.h" 29 #include "components/signin/core/browser/profile_oauth2_token_service.h"
29 #include "components/signin/core/browser/signin_error_controller.h" 30 #include "components/signin/core/browser/signin_error_controller.h"
30 #include "components/signin/core/browser/signin_oauth_helper.h" 31 #include "components/signin/core/browser/signin_oauth_helper.h"
31 #include "content/public/browser/storage_partition.h" 32 #include "content/public/browser/storage_partition.h"
32 #include "content/public/browser/web_ui.h" 33 #include "content/public/browser/web_ui.h"
33 #include "google_apis/gaia/gaia_auth_fetcher.h" 34 #include "google_apis/gaia/gaia_auth_fetcher.h"
34 #include "google_apis/gaia/gaia_auth_util.h" 35 #include "google_apis/gaia/gaia_auth_util.h"
35 #include "google_apis/gaia/gaia_constants.h" 36 #include "google_apis/gaia/gaia_constants.h"
36 #include "google_apis/gaia/gaia_urls.h" 37 #include "google_apis/gaia/gaia_urls.h"
37 #include "net/base/url_util.h" 38 #include "net/base/url_util.h"
38 39
39 namespace { 40 namespace {
40 41
41 class InlineSigninHelper : public SigninOAuthHelper, 42 class InlineSigninHelper : public SigninOAuthHelper,
42 public SigninOAuthHelper::Consumer { 43 public SigninOAuthHelper::Consumer {
43 public: 44 public:
44 InlineSigninHelper( 45 InlineSigninHelper(
45 base::WeakPtr<InlineLoginHandlerImpl> handler, 46 base::WeakPtr<InlineLoginHandlerImpl> handler,
46 net::URLRequestContextGetter* getter, 47 net::URLRequestContextGetter* getter,
47 Profile* profile, 48 Profile* profile,
48 const GURL& current_url, 49 const GURL& current_url,
49 const std::string& email, 50 const std::string& email,
50 const std::string& password, 51 const std::string& password,
51 const std::string& session_index, 52 const std::string& session_index,
52 const std::string& signin_scoped_device_id, 53 const std::string& signin_scoped_device_id,
53 bool choose_what_to_sync); 54 bool choose_what_to_sync,
55 bool confirm_untrusted_signin);
54 56
55 private: 57 private:
56 // Overriden from SigninOAuthHelper::Consumer. 58 // Overriden from SigninOAuthHelper::Consumer.
57 virtual void OnSigninOAuthInformationAvailable( 59 virtual void OnSigninOAuthInformationAvailable(
58 const std::string& email, 60 const std::string& email,
59 const std::string& display_email, 61 const std::string& display_email,
60 const std::string& refresh_token) OVERRIDE; 62 const std::string& refresh_token) OVERRIDE;
61 virtual void OnSigninOAuthInformationFailure( 63 virtual void OnSigninOAuthInformationFailure(
62 const GoogleServiceAuthError& error) OVERRIDE; 64 const GoogleServiceAuthError& error) OVERRIDE;
63 65
64 base::WeakPtr<InlineLoginHandlerImpl> handler_; 66 base::WeakPtr<InlineLoginHandlerImpl> handler_;
65 Profile* profile_; 67 Profile* profile_;
66 GURL current_url_; 68 GURL current_url_;
67 std::string email_; 69 std::string email_;
68 std::string password_; 70 std::string password_;
69 std::string session_index_; 71 std::string session_index_;
70 bool choose_what_to_sync_; 72 bool choose_what_to_sync_;
73 bool confirm_untrusted_signin_;
71 74
72 DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper); 75 DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper);
73 }; 76 };
74 77
75 InlineSigninHelper::InlineSigninHelper( 78 InlineSigninHelper::InlineSigninHelper(
76 base::WeakPtr<InlineLoginHandlerImpl> handler, 79 base::WeakPtr<InlineLoginHandlerImpl> handler,
77 net::URLRequestContextGetter* getter, 80 net::URLRequestContextGetter* getter,
78 Profile* profile, 81 Profile* profile,
79 const GURL& current_url, 82 const GURL& current_url,
80 const std::string& email, 83 const std::string& email,
81 const std::string& password, 84 const std::string& password,
82 const std::string& session_index, 85 const std::string& session_index,
83 const std::string& signin_scoped_device_id, 86 const std::string& signin_scoped_device_id,
84 bool choose_what_to_sync) 87 bool choose_what_to_sync,
88 bool confirm_untrusted_signin)
85 : SigninOAuthHelper(getter, session_index, signin_scoped_device_id, this), 89 : SigninOAuthHelper(getter, session_index, signin_scoped_device_id, this),
86 handler_(handler), 90 handler_(handler),
87 profile_(profile), 91 profile_(profile),
88 current_url_(current_url), 92 current_url_(current_url),
89 email_(email), 93 email_(email),
90 password_(password), 94 password_(password),
91 choose_what_to_sync_(choose_what_to_sync) { 95 session_index_(session_index),
96 choose_what_to_sync_(choose_what_to_sync),
97 confirm_untrusted_signin_(confirm_untrusted_signin) {
92 DCHECK(profile_); 98 DCHECK(profile_);
93 DCHECK(!email_.empty()); 99 DCHECK(!email_.empty());
94 } 100 }
95 101
96 void InlineSigninHelper::OnSigninOAuthInformationAvailable( 102 void InlineSigninHelper::OnSigninOAuthInformationAvailable(
97 const std::string& email, 103 const std::string& email,
98 const std::string& display_email, 104 const std::string& display_email,
99 const std::string& refresh_token) { 105 const std::string& refresh_token) {
100 content::WebContents* contents = NULL; 106 content::WebContents* contents = NULL;
101 Browser* browser = NULL; 107 Browser* browser = NULL;
(...skipping 27 matching lines...) Expand all
129 SigninErrorController* error_controller = 135 SigninErrorController* error_controller =
130 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> 136 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
131 signin_error_controller(); 137 signin_error_controller();
132 OneClickSigninSyncStarter::StartSyncMode start_mode = 138 OneClickSigninSyncStarter::StartSyncMode start_mode =
133 source == signin::SOURCE_SETTINGS || choose_what_to_sync_ ? 139 source == signin::SOURCE_SETTINGS || choose_what_to_sync_ ?
134 (error_controller->HasError() && 140 (error_controller->HasError() &&
135 sync_service && sync_service->HasSyncSetupCompleted()) ? 141 sync_service && sync_service->HasSyncSetupCompleted()) ?
136 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : 142 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE :
137 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : 143 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST :
138 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; 144 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS;
139 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = 145
140 source == signin::SOURCE_SETTINGS || 146 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required;
141 source == signin::SOURCE_WEBSTORE_INSTALL || 147 if (confirm_untrusted_signin_) {
142 choose_what_to_sync_ ? 148 confirmation_required =
143 OneClickSigninSyncStarter::NO_CONFIRMATION : 149 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN;
144 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; 150 } else {
151 confirmation_required =
152 source == signin::SOURCE_SETTINGS ||
153 source == signin::SOURCE_WEBSTORE_INSTALL ||
154 choose_what_to_sync_ ?
155 OneClickSigninSyncStarter::NO_CONFIRMATION :
156 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
157 }
145 158
146 bool start_signin = 159 bool start_signin =
147 !OneClickSigninHelper::HandleCrossAccountError( 160 !OneClickSigninHelper::HandleCrossAccountError(
148 contents, "", 161 contents, "",
149 email, password_, refresh_token, 162 email, password_, refresh_token,
150 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, 163 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
151 source, start_mode, 164 source, start_mode,
152 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, 165 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback,
153 handler_)); 166 handler_));
154 if (start_signin) { 167 if (start_signin) {
(...skipping 22 matching lines...) Expand all
177 AboutSigninInternalsFactory::GetForProfile(profile_); 190 AboutSigninInternalsFactory::GetForProfile(profile_);
178 about_signin_internals->OnRefreshTokenReceived("Failure"); 191 about_signin_internals->OnRefreshTokenReceived("Failure");
179 192
180 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 193 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
181 } 194 }
182 195
183 } // namespace 196 } // namespace
184 197
185 InlineLoginHandlerImpl::InlineLoginHandlerImpl() 198 InlineLoginHandlerImpl::InlineLoginHandlerImpl()
186 : weak_factory_(this), 199 : weak_factory_(this),
187 choose_what_to_sync_(false) { 200 confirm_untrusted_signin_(false) {
188 } 201 }
189 202
190 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {} 203 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {}
191 204
192 bool InlineLoginHandlerImpl::HandleContextMenu( 205 bool InlineLoginHandlerImpl::HandleContextMenu(
193 const content::ContextMenuParams& params) { 206 const content::ContextMenuParams& params) {
194 #ifndef NDEBUG 207 #ifndef NDEBUG
195 return false; 208 return false;
196 #else 209 #else
197 return true; 210 return true;
198 #endif 211 #endif
199 } 212 }
200 213
214 void InlineLoginHandlerImpl::DidCommitProvisionalLoadForFrame(
215 content::RenderFrameHost* render_frame_host,
216 const GURL& url,
217 content::PageTransition transition_type) {
218 if (!web_contents())
219 return;
220
221 // Return early if this is not a gaia iframe navigation.
222 const GURL kGaiaExtOrigin(
223 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/");
224 content::RenderFrameHost* gaia_iframe = InlineLoginUI::GetAuthIframe(
225 web_contents(), kGaiaExtOrigin, "signin-frame");
226 if (render_frame_host != gaia_iframe)
227 return;
228
229 if (url.spec() != url::kAboutBlankURL &&
Charlie Reis 2014/07/23 21:42:00 Let's put a comment here saying that loading any u
guohui 2014/07/23 21:57:51 Done.
guohui 2014/07/23 21:57:51 Done.
230 !gaia::IsGaiaSignonRealm(url.GetOrigin()) &&
231 !signin::IsContinueUrlForWebBasedSigninFlow(url)) {
Charlie Reis 2014/07/23 21:42:00 Does the continue URL get loaded in the sign-in pr
guohui 2014/07/23 21:57:51 The continue URL does get loaded in the signin pro
Charlie Reis 2014/07/23 22:18:06 But it can be specified manually as a URL paramete
guohui 2014/07/23 23:19:46 https://code.google.com/p/chromium/codesearch#chro
Charlie Reis 2014/07/23 23:36:12 Acknowledged.
232 confirm_untrusted_signin_ = true;
233 }
234 }
235
201 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { 236 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) {
202 params.SetString("service", "chromiumsync"); 237 params.SetString("service", "chromiumsync");
203 238
204 content::WebContents* contents = web_ui()->GetWebContents(); 239 content::WebContents* contents = web_ui()->GetWebContents();
205 const GURL& current_url = contents->GetURL(); 240 const GURL& current_url = contents->GetURL();
206 std::string is_constrained; 241 std::string is_constrained;
207 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); 242 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
208 if (is_constrained == "1") 243 if (is_constrained == "1")
209 contents->SetDelegate(this); 244 contents->SetDelegate(this);
210 245
246 content::WebContentsObserver::Observe(contents);
Charlie Reis 2014/07/23 21:42:00 I think this means we only observe when the WebCon
guohui 2014/07/23 21:57:51 We don't explicitly stop observing, so the observa
Charlie Reis 2014/07/23 22:18:06 Is it necessary to keep it around that long? It s
guohui 2014/07/23 23:19:46 sorry i made a mistake in my earlier comment, this
Charlie Reis 2014/07/23 23:36:12 Ah, good. That sounds good to me.
247
211 signin::Source source = signin::GetSourceForPromoURL(current_url); 248 signin::Source source = signin::GetSourceForPromoURL(current_url);
212 OneClickSigninHelper::LogHistogramValue( 249 OneClickSigninHelper::LogHistogramValue(
213 source, one_click_signin::HISTOGRAM_SHOWN); 250 source, one_click_signin::HISTOGRAM_SHOWN);
214 } 251 }
215 252
216 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { 253 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
217 content::WebContents* contents = web_ui()->GetWebContents(); 254 content::WebContents* contents = web_ui()->GetWebContents();
218 const GURL& current_url = contents->GetURL(); 255 const GURL& current_url = contents->GetURL();
219 256
220 const base::DictionaryValue* dict = NULL; 257 const base::DictionaryValue* dict = NULL;
221 args->GetDictionary(0, &dict); 258 args->GetDictionary(0, &dict);
222 259
223 bool skip_for_now = false; 260 bool skip_for_now = false;
224 dict->GetBoolean("skipForNow", &skip_for_now); 261 dict->GetBoolean("skipForNow", &skip_for_now);
225 if (skip_for_now) { 262 if (skip_for_now) {
226 signin::SetUserSkippedPromo(Profile::FromWebUI(web_ui())); 263 signin::SetUserSkippedPromo(Profile::FromWebUI(web_ui()));
227 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 264 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
228 return; 265 return;
229 } 266 }
230 267
231 base::string16 email; 268 base::string16 email_string16;
232 dict->GetString("email", &email); 269 dict->GetString("email", &email_string16);
233 DCHECK(!email.empty()); 270 DCHECK(!email_string16.empty());
234 email_ = base::UTF16ToASCII(email); 271 std::string email(base::UTF16ToASCII(email_string16));
235 base::string16 password; 272
236 dict->GetString("password", &password); 273 base::string16 password_string16;
237 password_ = base::UTF16ToASCII(password); 274 dict->GetString("password", &password_string16);
275 std::string password(base::UTF16ToASCII(password_string16));
238 276
239 // When doing a SAML sign in, this email check may result in a false 277 // When doing a SAML sign in, this email check may result in a false
240 // positive. This happens when the user types one email address in the 278 // positive. This happens when the user types one email address in the
241 // gaia sign in page, but signs in to a different account in the SAML sign in 279 // gaia sign in page, but signs in to a different account in the SAML sign in
242 // page. 280 // page.
243 std::string default_email; 281 std::string default_email;
244 std::string validate_email; 282 std::string validate_email;
245 if (net::GetValueForKeyInQuery(current_url, "email", &default_email) && 283 if (net::GetValueForKeyInQuery(current_url, "email", &default_email) &&
246 net::GetValueForKeyInQuery(current_url, "validateEmail", 284 net::GetValueForKeyInQuery(current_url, "validateEmail",
247 &validate_email) && 285 &validate_email) &&
248 validate_email == "1") { 286 validate_email == "1") {
249 if (!gaia::AreEmailsSame(email_, default_email)) { 287 if (!gaia::AreEmailsSame(email, default_email)) {
250 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 288 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
251 return; 289 return;
252 } 290 }
253 } 291 }
254 292
255 base::string16 session_index; 293 base::string16 session_index_string16;
256 dict->GetString("sessionIndex", &session_index); 294 dict->GetString("sessionIndex", &session_index_string16);
257 session_index_ = base::UTF16ToASCII(session_index); 295 std::string session_index = base::UTF16ToASCII(session_index_string16);
258 DCHECK(!session_index_.empty()); 296 DCHECK(!session_index.empty());
259 dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync_); 297
298 bool choose_what_to_sync = false;
299 dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync);
260 300
261 signin::Source source = signin::GetSourceForPromoURL(current_url); 301 signin::Source source = signin::GetSourceForPromoURL(current_url);
262 OneClickSigninHelper::LogHistogramValue( 302 OneClickSigninHelper::LogHistogramValue(
263 source, one_click_signin::HISTOGRAM_ACCEPTED); 303 source, one_click_signin::HISTOGRAM_ACCEPTED);
264 bool switch_to_advanced = 304 bool switch_to_advanced =
265 choose_what_to_sync_ && (source != signin::SOURCE_SETTINGS); 305 choose_what_to_sync && (source != signin::SOURCE_SETTINGS);
266 OneClickSigninHelper::LogHistogramValue( 306 OneClickSigninHelper::LogHistogramValue(
267 source, 307 source,
268 switch_to_advanced ? one_click_signin::HISTOGRAM_WITH_ADVANCED : 308 switch_to_advanced ? one_click_signin::HISTOGRAM_WITH_ADVANCED :
269 one_click_signin::HISTOGRAM_WITH_DEFAULTS); 309 one_click_signin::HISTOGRAM_WITH_DEFAULTS);
270 310
271 OneClickSigninHelper::CanOfferFor can_offer_for = 311 OneClickSigninHelper::CanOfferFor can_offer_for =
272 OneClickSigninHelper::CAN_OFFER_FOR_ALL; 312 OneClickSigninHelper::CAN_OFFER_FOR_ALL;
273 switch (source) { 313 switch (source) {
274 case signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: 314 case signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT:
275 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; 315 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT;
276 break; 316 break;
277 case signin::SOURCE_REAUTH: { 317 case signin::SOURCE_REAUTH: {
278 std::string primary_username = 318 std::string primary_username =
279 SigninManagerFactory::GetForProfile( 319 SigninManagerFactory::GetForProfile(
280 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername(); 320 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername();
281 if (!gaia::AreEmailsSame(default_email, primary_username)) 321 if (!gaia::AreEmailsSame(default_email, primary_username))
282 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; 322 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT;
283 break; 323 break;
284 } 324 }
285 default: 325 default:
286 // No need to change |can_offer_for|. 326 // No need to change |can_offer_for|.
287 break; 327 break;
288 } 328 }
289 329
290 std::string error_msg; 330 std::string error_msg;
291 bool can_offer = OneClickSigninHelper::CanOffer( 331 bool can_offer = OneClickSigninHelper::CanOffer(
292 contents, can_offer_for, email_, &error_msg); 332 contents, can_offer_for, email, &error_msg);
293 if (!can_offer) { 333 if (!can_offer) {
294 HandleLoginError(error_msg); 334 HandleLoginError(error_msg);
295 return; 335 return;
296 } 336 }
297 337
298 AboutSigninInternals* about_signin_internals = 338 AboutSigninInternals* about_signin_internals =
299 AboutSigninInternalsFactory::GetForProfile(Profile::FromWebUI(web_ui())); 339 AboutSigninInternalsFactory::GetForProfile(Profile::FromWebUI(web_ui()));
300 about_signin_internals->OnAuthenticationResultReceived( 340 about_signin_internals->OnAuthenticationResultReceived(
301 "GAIA Auth Successful"); 341 "GAIA Auth Successful");
302 342
303 content::StoragePartition* partition = 343 content::StoragePartition* partition =
304 content::BrowserContext::GetStoragePartitionForSite( 344 content::BrowserContext::GetStoragePartitionForSite(
305 contents->GetBrowserContext(), 345 contents->GetBrowserContext(),
306 GURL(chrome::kChromeUIChromeSigninURL)); 346 GURL(chrome::kChromeUIChromeSigninURL));
307 347
308 SigninClient* signin_client = 348 SigninClient* signin_client =
309 ChromeSigninClientFactory::GetForProfile(Profile::FromWebUI(web_ui())); 349 ChromeSigninClientFactory::GetForProfile(Profile::FromWebUI(web_ui()));
310 std::string signin_scoped_device_id = 350 std::string signin_scoped_device_id =
311 signin_client->GetSigninScopedDeviceId(); 351 signin_client->GetSigninScopedDeviceId();
312 // InlineSigninHelper will delete itself. 352 // InlineSigninHelper will delete itself.
313 new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(), 353 new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(),
314 Profile::FromWebUI(web_ui()), current_url, 354 Profile::FromWebUI(web_ui()), current_url,
315 email_, password_, session_index_, 355 email, password, session_index,
316 signin_scoped_device_id, choose_what_to_sync_); 356 signin_scoped_device_id, choose_what_to_sync,
357 confirm_untrusted_signin_);
317 358
318 email_.clear();
319 password_.clear();
320 session_index_.clear();
321 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); 359 web_ui()->CallJavascriptFunction("inline.login.closeDialog");
322 } 360 }
323 361
324 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { 362 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) {
325 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 363 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
326 364
327 Browser* browser = GetDesktopBrowser(); 365 Browser* browser = GetDesktopBrowser();
328 if (browser && !error_msg.empty()) { 366 if (browser && !error_msg.empty()) {
329 VLOG(1) << "InlineLoginHandlerImpl::HandleLoginError shows error message: " 367 VLOG(1) << "InlineLoginHandlerImpl::HandleLoginError shows error message: "
330 << error_msg; 368 << error_msg;
331 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg); 369 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg);
332 } 370 }
333
334 email_.clear();
335 password_.clear();
336 session_index_.clear();
337 } 371 }
338 372
339 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { 373 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() {
340 Browser* browser = chrome::FindBrowserWithWebContents( 374 Browser* browser = chrome::FindBrowserWithWebContents(
341 web_ui()->GetWebContents()); 375 web_ui()->GetWebContents());
342 if (!browser) { 376 if (!browser) {
343 browser = chrome::FindLastActiveWithProfile( 377 browser = chrome::FindLastActiveWithProfile(
344 Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); 378 Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop());
345 } 379 }
346 return browser; 380 return browser;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 421 }
388 } 422 }
389 423
390 if (show_account_management) { 424 if (show_account_management) {
391 browser->window()->ShowAvatarBubbleFromAvatarButton( 425 browser->window()->ShowAvatarBubbleFromAvatarButton(
392 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, 426 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
393 signin::ManageAccountsParams()); 427 signin::ManageAccountsParams());
394 } 428 }
395 } 429 }
396 } 430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698