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

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

Issue 6272016: Prevent non-Incognito windows in the Guest session. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser
Patch Set: fixed win warning + indent Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 virtual void FetchTokens( 146 virtual void FetchTokens(
147 Profile* profile, 147 Profile* profile,
148 const GaiaAuthConsumer::ClientLoginResult& credentials); 148 const GaiaAuthConsumer::ClientLoginResult& credentials);
149 149
150 // Sets the current background view. 150 // Sets the current background view.
151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); 151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view);
152 152
153 // Gets the current background view. 153 // Gets the current background view.
154 virtual chromeos::BackgroundView* GetBackgroundView(); 154 virtual chromeos::BackgroundView* GetBackgroundView();
155 155
156 protected:
157 virtual std::string GetOffTheRecordCommandLine(
158 const GURL& start_url,
159 const CommandLine& base_command_line,
160 CommandLine *command_line);
161
156 private: 162 private:
157 // Check user's profile for kApplicationLocale setting. 163 // Check user's profile for kApplicationLocale setting.
158 void RespectLocalePreference(Profile* pref); 164 void RespectLocalePreference(Profile* pref);
159 165
160 // Indicates if DoBrowserLaunch will actually launch the browser or not. 166 // Indicates if DoBrowserLaunch will actually launch the browser or not.
161 bool browser_launch_enabled_; 167 bool browser_launch_enabled_;
162 168
163 // The current background view. 169 // The current background view.
164 chromeos::BackgroundView* background_view_; 170 chromeos::BackgroundView* background_view_;
165 171
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 378 }
373 379
374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 380 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
375 VLOG(1) << "Completing off the record login"; 381 VLOG(1) << "Completing off the record login";
376 382
377 UserManager::Get()->OffTheRecordUserLoggedIn(); 383 UserManager::Get()->OffTheRecordUserLoggedIn();
378 384
379 if (CrosLibrary::Get()->EnsureLoaded()) { 385 if (CrosLibrary::Get()->EnsureLoaded()) {
380 // For guest session we ask session manager to restart Chrome with --bwsi 386 // For guest session we ask session manager to restart Chrome with --bwsi
381 // flag. We keep only some of the arguments of this process. 387 // flag. We keep only some of the arguments of this process.
382 static const char* kForwardSwitches[] = { 388 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
383 switches::kEnableLogging,
384 switches::kUserDataDir,
385 switches::kScrollPixels,
386 switches::kEnableGView,
387 switches::kNoFirstRun,
388 switches::kLoginProfile,
389 switches::kCompressSystemFeedback,
390 switches::kDisableSeccompSandbox,
391 #if defined(HAVE_XINPUT2)
392 switches::kTouchDevices,
393 #endif
394 };
395 const CommandLine& browser_command_line =
396 *CommandLine::ForCurrentProcess();
397 CommandLine command_line(browser_command_line.GetProgram()); 389 CommandLine command_line(browser_command_line.GetProgram());
398 command_line.CopySwitchesFrom(browser_command_line, 390 std::string cmd_line_str =
399 kForwardSwitches, 391 GetOffTheRecordCommandLine(start_url,
400 arraysize(kForwardSwitches)); 392 browser_command_line,
401 command_line.AppendSwitch(switches::kGuestSession); 393 &command_line);
402 command_line.AppendSwitch(switches::kIncognito);
403 command_line.AppendSwitchASCII(switches::kLoggingLevel,
404 kGuestModeLoggingLevel);
405 command_line.AppendSwitchASCII(
406 switches::kLoginUser,
407 UserManager::Get()->logged_in_user().email());
408
409 if (start_url.is_valid())
410 command_line.AppendArg(start_url.spec());
411
412 // Override the value of the homepage that is set in first run mode.
413 // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case.
414 command_line.AppendSwitchASCII(
415 switches::kHomePage,
416 GURL(chrome::kChromeUINewTabURL).spec());
417
418 std::string cmd_line_str = command_line.command_line_string();
419 // Special workaround for the arguments that should be quoted.
420 // Copying switches won't be needed when Guest mode won't need restart
421 // http://crosbug.com/6924
422 if (browser_command_line.HasSwitch(switches::kRegisterPepperPlugins)) {
423 cmd_line_str += base::StringPrintf(
424 kSwitchFormatString,
425 switches::kRegisterPepperPlugins,
426 browser_command_line.GetSwitchValueNative(
427 switches::kRegisterPepperPlugins).c_str());
428 }
429 394
430 PrefService* local_state = g_browser_process->local_state(); 395 PrefService* local_state = g_browser_process->local_state();
431 std::string cur_locale = g_browser_process->GetApplicationLocale(); 396 std::string cur_locale = g_browser_process->GetApplicationLocale();
432 // Guest session is starting in a new process so we need to communicate 397 // Guest session is starting in a new process so we need to communicate
433 // current locale to it. Current locale may differ from value of 398 // current locale to it. Current locale may differ from value of
434 // kApplicationLocale because switching language on new user pod does not 399 // kApplicationLocale because switching language on new user pod does not
435 // change kApplicationLocale after ownership has been taken. 400 // change kApplicationLocale after ownership has been taken.
436 // We will restore kApplicationLocale back to kOwnerValue on next startup. 401 // We will restore kApplicationLocale back to kOwnerValue on next startup.
437 if (local_state->GetString(prefs::kApplicationLocale) != cur_locale) { 402 if (local_state->GetString(prefs::kApplicationLocale) != cur_locale) {
438 local_state->SetString(prefs::kApplicationLocale, cur_locale); 403 local_state->SetString(prefs::kApplicationLocale, cur_locale);
439 local_state->SavePersistentPrefs(); 404 local_state->SavePersistentPrefs();
440 } 405 }
441 406
442 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str); 407 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str);
443 } 408 }
444 } 409 }
445 410
411 std::string LoginUtilsImpl::GetOffTheRecordCommandLine(
412 const GURL& start_url,
413 const CommandLine& base_command_line,
414 CommandLine* command_line) {
415 static const char* kForwardSwitches[] = {
416 switches::kEnableLogging,
417 switches::kUserDataDir,
418 switches::kScrollPixels,
419 switches::kEnableGView,
420 switches::kNoFirstRun,
421 switches::kLoginProfile,
422 switches::kCompressSystemFeedback,
423 switches::kDisableSeccompSandbox,
424 #if defined(HAVE_XINPUT2)
425 switches::kTouchDevices,
426 #endif
427 };
428 command_line->CopySwitchesFrom(base_command_line,
429 kForwardSwitches,
430 arraysize(kForwardSwitches));
431 command_line->AppendSwitch(switches::kGuestSession);
432 command_line->AppendSwitch(switches::kIncognito);
433 command_line->AppendSwitchASCII(switches::kLoggingLevel,
434 kGuestModeLoggingLevel);
435
436 if (start_url.is_valid())
437 command_line->AppendArg(start_url.spec());
438
439 // Override the value of the homepage that is set in first run mode.
440 // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case.
441 command_line->AppendSwitchASCII(
442 switches::kHomePage,
443 GURL(chrome::kChromeUINewTabURL).spec());
444
445 std::string cmd_line_str = command_line->command_line_string();
446 // Special workaround for the arguments that should be quoted.
447 // Copying switches won't be needed when Guest mode won't need restart
448 // http://crosbug.com/6924
449 if (base_command_line.HasSwitch(switches::kRegisterPepperPlugins)) {
450 cmd_line_str += base::StringPrintf(
451 kSwitchFormatString,
452 switches::kRegisterPepperPlugins,
453 base_command_line.GetSwitchValueNative(
454 switches::kRegisterPepperPlugins).c_str());
455 }
456
457 return cmd_line_str;
458 }
459
446 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { 460 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) {
447 VLOG(1) << "Setting first login prefs"; 461 VLOG(1) << "Setting first login prefs";
448 BootTimesLoader* btl = BootTimesLoader::Get(); 462 BootTimesLoader* btl = BootTimesLoader::Get();
449 463
450 static const char kFallbackInputMethodLocale[] = "en-US"; 464 static const char kFallbackInputMethodLocale[] = "en-US";
451 std::string locale(g_browser_process->GetApplicationLocale()); 465 std::string locale(g_browser_process->GetApplicationLocale());
452 // Add input methods based on the application locale when the user first 466 // Add input methods based on the application locale when the user first
453 // logs in. For instance, if the user chooses Japanese as the UI 467 // logs in. For instance, if the user chooses Japanese as the UI
454 // language at the first login, we'll add input methods associated with 468 // language at the first login, we'll add input methods associated with
455 // Japanese, such as mozc. 469 // Japanese, such as mozc.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 BrowserInit browser_init; 580 BrowserInit browser_init;
567 int return_code; 581 int return_code;
568 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), 582 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(),
569 profile, 583 profile,
570 FilePath(), 584 FilePath(),
571 true, 585 true,
572 &return_code); 586 &return_code);
573 } 587 }
574 588
575 } // namespace chromeos 589 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.h ('k') | chrome/browser/chromeos/login/mock_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698