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

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: Fix windows sync integration test failure 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 "content/public/browser/url_data_source.h" 30 #include "content/public/browser/url_data_source.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) { 114 bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) {
113 return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount); 115 return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount);
114 } 116 }
115 117
116 // static 118 // static
117 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) { 119 bool SyncPromoUI::ShouldShowSyncPromo(Profile* profile) {
118 #if defined(OS_CHROMEOS) 120 #if defined(OS_CHROMEOS)
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 #else
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 // Display the signin promo if the user is not signed in.
129 if (!profile->GetOriginalProfile()->IsSyncAccessible()) 131 SigninManager* signin = SigninManagerFactory::GetForProfile(
130 return false; 132 profile->GetOriginalProfile());
131 133 return signin->GetAuthenticatedUsername().empty();
132 // If the user is already signed into sync then don't show the promo. 134 #endif
133 ProfileSyncService* service =
134 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
135 profile->GetOriginalProfile());
136 if (!service || service->HasSyncSetupCompleted())
137 return false;
138
139 // Default to allow the promo.
140 return true;
141 } 135 }
142 136
143 // static 137 // static
144 void SyncPromoUI::RegisterUserPrefs(PrefServiceSyncable* prefs) { 138 void SyncPromoUI::RegisterUserPrefs(PrefServiceSyncable* prefs) {
145 prefs->RegisterIntegerPref(prefs::kSyncPromoStartupCount, 0, 139 prefs->RegisterIntegerPref(prefs::kSyncPromoStartupCount, 0,
146 PrefServiceSyncable::UNSYNCABLE_PREF); 140 PrefServiceSyncable::UNSYNCABLE_PREF);
147 prefs->RegisterBooleanPref(prefs::kSyncPromoUserSkipped, false, 141 prefs->RegisterBooleanPref(prefs::kSyncPromoUserSkipped, false,
148 PrefServiceSyncable::UNSYNCABLE_PREF); 142 PrefServiceSyncable::UNSYNCABLE_PREF);
149 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true, 143 prefs->RegisterBooleanPref(prefs::kSyncPromoShowOnFirstRunAllowed, true,
150 PrefServiceSyncable::UNSYNCABLE_PREF); 144 PrefServiceSyncable::UNSYNCABLE_PREF);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 g_force_web_based_signin_flow; 299 g_force_web_based_signin_flow;
306 #else 300 #else
307 return false; 301 return false;
308 #endif 302 #endif
309 } 303 }
310 304
311 // static 305 // static
312 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { 306 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) {
313 g_force_web_based_signin_flow = force; 307 g_force_web_based_signin_flow = force;
314 } 308 }
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