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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 287083003: Multi-profile flag cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Created 6 years, 7 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
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/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; 148 OAuth2LoginManager::SessionRestoreState state) OVERRIDE;
149 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE; 149 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE;
150 150
151 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. 151 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides.
152 virtual void OnConnectionTypeChanged( 152 virtual void OnConnectionTypeChanged(
153 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 153 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
154 154
155 private: 155 private:
156 typedef std::set<std::string> SessionRestoreStateSet; 156 typedef std::set<std::string> SessionRestoreStateSet;
157 157
158 // Removes obsolete about://flags entries from user profile preferences.
159 void RemoveObsoleteFlags(PrefService* prefs);
160
158 // DoBrowserLaunch is split into two parts. 161 // DoBrowserLaunch is split into two parts.
159 // This one is called after anynchronous locale switch. 162 // This one is called after anynchronous locale switch.
160 void DoBrowserLaunchOnLocaleLoadedImpl(Profile* profile, 163 void DoBrowserLaunchOnLocaleLoadedImpl(Profile* profile,
161 LoginDisplayHost* login_host); 164 LoginDisplayHost* login_host);
162 165
163 // Callback for locale_util::SwitchLanguage(). 166 // Callback for locale_util::SwitchLanguage().
164 static void DoBrowserLaunchOnLocaleLoaded( 167 static void DoBrowserLaunchOnLocaleLoaded(
165 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> context, 168 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> context,
166 const std::string& locale, 169 const std::string& locale,
167 const std::string& loaded_locale, 170 const std::string& loaded_locale,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // static 293 // static
291 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoaded( 294 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoaded(
292 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> context, 295 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> context,
293 const std::string& /* locale */, 296 const std::string& /* locale */,
294 const std::string& /* loaded_locale */, 297 const std::string& /* loaded_locale */,
295 const bool /* success */) { 298 const bool /* success */) {
296 context->login_utils_impl->DoBrowserLaunchOnLocaleLoadedImpl( 299 context->login_utils_impl->DoBrowserLaunchOnLocaleLoadedImpl(
297 context->profile, context->display_host); 300 context->profile, context->display_host);
298 } 301 }
299 302
303 void LoginUtilsImpl::RemoveObsoleteFlags(PrefService* prefs) {
304 about_flags::PrefServiceFlagsStorage flags_storage(prefs);
305 std::set<std::string> flags = flags_storage.GetFlags();
306 bool removed_any = false;
307 // Entries from about://flags that we need to remove since they are obsolete.
308 const char* const kObsoleteSwitchesToRemove[] = {
309 ::switches::kMultiProfilesObsolete,
310 };
311 for (size_t i = 0; i < arraysize(kObsoleteSwitchesToRemove); ++i) {
312 std::set<std::string>::iterator iter =
313 flags.find(kObsoleteSwitchesToRemove[i]);
314 if (iter != flags.end()) {
315 flags.erase(iter);
316 removed_any = true;
317 }
318 }
319 if (removed_any)
320 flags_storage.SetFlags(flags);
321 }
322
300 // Called from DoBrowserLaunch() or from 323 // Called from DoBrowserLaunch() or from
301 // DoBrowserLaunchOnLocaleLoaded() depending on 324 // DoBrowserLaunchOnLocaleLoaded() depending on
302 // if locale switch was needed. 325 // if locale switch was needed.
303 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl( 326 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl(
304 Profile* profile, 327 Profile* profile,
305 LoginDisplayHost* login_host) { 328 LoginDisplayHost* login_host) {
306 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 329 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
307 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); 330 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
308 return; 331 return;
309 } 332 }
310 333
311 CommandLine user_flags(CommandLine::NO_PROGRAM); 334 CommandLine user_flags(CommandLine::NO_PROGRAM);
335 RemoveObsoleteFlags(profile->GetPrefs());
312 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); 336 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs());
313 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, 337 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags,
314 about_flags::kAddSentinels); 338 about_flags::kAddSentinels);
315 // Only restart if needed and if not going into managed mode. 339 // Only restart if needed and if not going into managed mode.
316 // Don't restart browser if it is not first profile in session. 340 // Don't restart browser if it is not first profile in session.
317 if (UserManager::Get()->GetLoggedInUsers().size() == 1 && 341 if (UserManager::Get()->GetLoggedInUsers().size() == 1 &&
318 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && 342 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() &&
319 !about_flags::AreSwitchesIdenticalToCurrentCommandLine( 343 !about_flags::AreSwitchesIdenticalToCurrentCommandLine(
320 user_flags, *CommandLine::ForCurrentProcess())) { 344 user_flags, *CommandLine::ForCurrentProcess())) {
321 CommandLine::StringVector flags; 345 CommandLine::StringVector flags;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 CrosSettings* cros_settings = CrosSettings::Get(); 974 CrosSettings* cros_settings = CrosSettings::Get();
951 bool allow_new_user = false; 975 bool allow_new_user = false;
952 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 976 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
953 if (allow_new_user) 977 if (allow_new_user)
954 return true; 978 return true;
955 return cros_settings->FindEmailInList( 979 return cros_settings->FindEmailInList(
956 kAccountsPrefUsers, username, wildcard_match); 980 kAccountsPrefUsers, username, wildcard_match);
957 } 981 }
958 982
959 } // namespace chromeos 983 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698