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

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

Issue 16770002: Restart Chrome if per session flags have been specified on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace set_symmetric_difference with equals. Created 7 years, 6 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/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/chromeos/chromeos_version.h" 10 #include "base/chromeos/chromeos_version.h"
(...skipping 30 matching lines...) Expand all
41 #include "chrome/browser/chromeos/login/screen_locker.h" 41 #include "chrome/browser/chromeos/login/screen_locker.h"
42 #include "chrome/browser/chromeos/login/user_manager.h" 42 #include "chrome/browser/chromeos/login/user_manager.h"
43 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" 43 #include "chrome/browser/chromeos/net/connectivity_state_helper.h"
44 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" 44 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h"
45 #include "chrome/browser/chromeos/profiles/profile_helper.h" 45 #include "chrome/browser/chromeos/profiles/profile_helper.h"
46 #include "chrome/browser/chromeos/settings/cros_settings.h" 46 #include "chrome/browser/chromeos/settings/cros_settings.h"
47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
48 #include "chrome/browser/extensions/extension_service.h" 48 #include "chrome/browser/extensions/extension_service.h"
49 #include "chrome/browser/first_run/first_run.h" 49 #include "chrome/browser/first_run/first_run.h"
50 #include "chrome/browser/google/google_util_chromeos.h" 50 #include "chrome/browser/google/google_util_chromeos.h"
51 #include "chrome/browser/lifetime/application_lifetime.h"
51 #include "chrome/browser/managed_mode/managed_mode.h" 52 #include "chrome/browser/managed_mode/managed_mode.h"
52 #include "chrome/browser/net/chrome_url_request_context.h" 53 #include "chrome/browser/net/chrome_url_request_context.h"
53 #include "chrome/browser/net/preconnect.h" 54 #include "chrome/browser/net/preconnect.h"
54 #include "chrome/browser/profiles/profile.h" 55 #include "chrome/browser/profiles/profile.h"
55 #include "chrome/browser/profiles/profile_manager.h" 56 #include "chrome/browser/profiles/profile_manager.h"
56 #include "chrome/browser/rlz/rlz.h" 57 #include "chrome/browser/rlz/rlz.h"
57 #include "chrome/browser/signin/signin_manager.h" 58 #include "chrome/browser/signin/signin_manager.h"
58 #include "chrome/browser/signin/signin_manager_factory.h" 59 #include "chrome/browser/signin/signin_manager_factory.h"
59 #include "chrome/browser/signin/token_service.h" 60 #include "chrome/browser/signin/token_service.h"
60 #include "chrome/browser/signin/token_service_factory.h" 61 #include "chrome/browser/signin/token_service_factory.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 scoped_ptr<LoginUtils> ptr_; 274 scoped_ptr<LoginUtils> ptr_;
274 275
275 DISALLOW_COPY_AND_ASSIGN(LoginUtilsWrapper); 276 DISALLOW_COPY_AND_ASSIGN(LoginUtilsWrapper);
276 }; 277 };
277 278
278 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile, 279 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile,
279 LoginDisplayHost* login_host) { 280 LoginDisplayHost* login_host) {
280 if (browser_shutdown::IsTryingToQuit()) 281 if (browser_shutdown::IsTryingToQuit())
281 return; 282 return;
282 283
284 CommandLine user_flags(CommandLine::NO_PROGRAM);
285 about_flags::ConvertFlagsToSwitches(profile->GetPrefs(), &user_flags);
286 if (!about_flags::CompareSwitchesToCurrentCommandLine(
287 user_flags, *CommandLine::ForCurrentProcess())) {
288 CommandLine::StringVector flags;
289 // argv[0] is the program name |CommandLine::NO_PROGRAM|.
290 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
291 VLOG(1) << "Restarting to apply per-session flags...";
292 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
293 UserManager::Get()->GetActiveUser()->email(), flags);
294 chrome::ExitCleanly();
295 return;
296 }
297
283 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 298 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
284 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); 299 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
285 return; 300 return;
286 } 301 }
287 302
288 if (login_host) { 303 if (login_host) {
289 login_host->SetStatusAreaVisible(true); 304 login_host->SetStatusAreaVisible(true);
290 login_host->BeforeSessionStart(); 305 login_host->BeforeSessionStart();
291 } 306 }
292 307
293 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); 308 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false);
294 309
295 VLOG(1) << "Launching browser..."; 310 VLOG(1) << "Launching browser...";
296 StartupBrowserCreator browser_creator; 311 StartupBrowserCreator browser_creator;
297 int return_code; 312 int return_code;
298 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 313 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
299 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 314 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
300 315
301 // TODO(pastarmovj): Restart the browser and apply any flags set by the user.
302 // See: http://crosbug.com/39249
303
304 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(), 316 browser_creator.LaunchBrowser(*CommandLine::ForCurrentProcess(),
305 profile, 317 profile,
306 base::FilePath(), 318 base::FilePath(),
307 chrome::startup::IS_PROCESS_STARTUP, 319 chrome::startup::IS_PROCESS_STARTUP,
308 first_run, 320 first_run,
309 &return_code); 321 &return_code);
310 322
311 // Mark login host for deletion after browser starts. This 323 // Mark login host for deletion after browser starts. This
312 // guarantees that the message loop will be referenced by the 324 // guarantees that the message loop will be referenced by the
313 // browser before it is dereferenced by the login host. 325 // browser before it is dereferenced by the login host.
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 bool LoginUtils::IsWhitelisted(const std::string& username) { 930 bool LoginUtils::IsWhitelisted(const std::string& username) {
919 CrosSettings* cros_settings = CrosSettings::Get(); 931 CrosSettings* cros_settings = CrosSettings::Get();
920 bool allow_new_user = false; 932 bool allow_new_user = false;
921 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 933 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
922 if (allow_new_user) 934 if (allow_new_user)
923 return true; 935 return true;
924 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 936 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
925 } 937 }
926 938
927 } // namespace chromeos 939 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698