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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 12077030: Allow signin to continue even if sync is disabled by policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup after self-review Created 7 years, 10 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/webui/sync_promo/sync_promo_ui.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.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/first_run/first_run.h" 13 #include "chrome/browser/first_run/first_run.h"
14 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_info_cache.h" 17 #include "chrome/browser/profiles/profile_info_cache.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/signin/signin_manager.h"
20 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 21 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 22 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/webui/options/core_options_handler.h" 23 #include "chrome/browser/ui/webui/options/core_options_handler.h"
22 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" 24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
23 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" 25 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
24 #include "chrome/browser/ui/webui/theme_source.h" 26 #include "chrome/browser/ui/webui/theme_source.h"
25 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
28 #include "chrome/common/net/url_util.h" 30 #include "chrome/common/net/url_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // There's no need to show the sync promo on cros since cros users are logged 121 // There's no need to show the sync promo on cros since cros users are logged
120 // into sync already. 122 // into sync already.
121 return false; 123 return false;
122 #endif 124 #endif
123 125
124 // Don't bother if we don't have any kind of network connection. 126 // Don't bother if we don't have any kind of network connection.
125 if (net::NetworkChangeNotifier::IsOffline()) 127 if (net::NetworkChangeNotifier::IsOffline())
126 return false; 128 return false;
127 129
128 // Honor the sync policies. 130 // Honor the sync policies.
129 if (!profile->GetOriginalProfile()->IsSyncAccessible()) 131 profile = profile->GetOriginalProfile();
sail 2013/01/29 19:17:16 Changing passed in parameters is really confusing.
Andrew T Wilson (Slow) 2013/01/30 13:55:50 Done.
130 return false; 132 if (!profile->IsSyncAccessible()) {
133 // Sync is disabled by policy - display the promo if the user is not signed
sail 2013/01/29 19:17:16 I don't understand this. This implies that if sync
Andrew T Wilson (Slow) 2013/01/30 07:43:41 If sync is accessible (meaning not disabled by pol
Andrew T Wilson (Slow) 2013/01/30 13:55:50 Actually, after re-reading your comment, I've chan
sail 2013/01/30 17:51:01 Awesome!
134 // in.
135 SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
136 return signin->GetAuthenticatedUsername().empty();
137 }
131 138
132 // If the user is already signed into sync then don't show the promo. 139 // If the user is already signed into sync then don't show the promo.
133 ProfileSyncService* service = 140 ProfileSyncService* service =
134 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 141 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
135 profile->GetOriginalProfile()); 142 profile->GetOriginalProfile());
136 if (!service || service->HasSyncSetupCompleted()) 143 if (!service || service->HasSyncSetupCompleted())
137 return false; 144 return false;
138 145
139 // Default to allow the promo. 146 // Default to allow the promo.
140 return true; 147 return true;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 g_force_web_based_signin_flow; 314 g_force_web_based_signin_flow;
308 #else 315 #else
309 return false; 316 return false;
310 #endif 317 #endif
311 } 318 }
312 319
313 // static 320 // static
314 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { 321 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) {
315 g_force_web_based_signin_flow = force; 322 g_force_web_based_signin_flow = force;
316 } 323 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698