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

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

Issue 10829029: sync: don't display one-click if setup is in progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 4 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/infobars/infobar_tab_helper.h" 13 #include "chrome/browser/infobars/infobar_tab_helper.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_info_cache.h" 16 #include "chrome/browser/profiles/profile_info_cache.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/signin/signin_manager.h" 18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
21 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 22 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
22 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
23 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" 26 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
26 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" 27 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return false; 219 return false;
219 220
220 if (check_connected) { 221 if (check_connected) {
221 SigninManager* manager = 222 SigninManager* manager =
222 SigninManagerFactory::GetForProfile(profile); 223 SigninManagerFactory::GetForProfile(profile);
223 if (!manager) 224 if (!manager)
224 return false; 225 return false;
225 226
226 if (!manager->GetAuthenticatedUsername().empty()) 227 if (!manager->GetAuthenticatedUsername().empty())
227 return false; 228 return false;
229
230 // If we're about to show a one-click infobar but the user has started
231 // a concurrent signin flow (perhaps via the promo), we may not have yet
232 // established an authenticated username but we still shouldn't move
233 // forward with two simultaneous signin processes. This is a bit
234 // contentious as the one-click flow is a much smoother flow from the user
235 // perspective, but it's much more difficult to hijack the other flow from
236 // here as it is to bail.
237 ProfileSyncService* service =
238 ProfileSyncServiceFactory::GetForProfile(profile);
239 if (!service)
240 return false;
241
242 if (service->FirstSetupInProgress())
243 return false;
228 } 244 }
229 245
230 return true; 246 return true;
231 } 247 }
232 248
233 // static 249 // static
234 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request, 250 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request,
235 int child_id, 251 int child_id,
236 int route_id) { 252 int route_id) {
237 // See if the response contains the Google-Accounts-SignIn header. 253 // See if the response contains the Google-Accounts-SignIn header.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 session_index_ = session_index; 363 session_index_ = session_index;
348 email_ = email; 364 email_ = email;
349 } 365 }
350 366
351 void OneClickSigninHelper::SavePassword(const std::string& password) { 367 void OneClickSigninHelper::SavePassword(const std::string& password) {
352 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of 368 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of
353 // challenge, its possible for the user to never complete the signin. 369 // challenge, its possible for the user to never complete the signin.
354 // Should have a way to detect this and clear the password member. 370 // Should have a way to detect this and clear the password member.
355 password_ = password; 371 password_ = password;
356 } 372 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.h ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698