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

Unified 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: code review Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/login_utils.cc
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index e9032fb991078093758acc40c89c081516dccbeb..39963dcc6c54164a14a95f543d2bfff94ff6d2d2 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -153,6 +153,12 @@ class LoginUtilsImpl : public LoginUtils {
// Gets the current background view.
virtual chromeos::BackgroundView* GetBackgroundView();
+ protected:
+ virtual std::string GetOffTheRecordCommandLine(
+ const GURL& start_url,
+ const CommandLine& base_command_line,
+ CommandLine *command_line);
+
private:
// Check user's profile for kApplicationLocale setting.
void RespectLocalePreference(Profile* pref);
@@ -379,58 +385,65 @@ void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
if (CrosLibrary::Get()->EnsureLoaded()) {
// For guest session we ask session manager to restart Chrome with --bwsi
// flag. We keep only some of the arguments of this process.
- static const char* kForwardSwitches[] = {
- switches::kEnableLogging,
- switches::kUserDataDir,
- switches::kScrollPixels,
- switches::kEnableGView,
- switches::kNoFirstRun,
- switches::kLoginProfile,
- switches::kCompressSystemFeedback,
- switches::kDisableSeccompSandbox,
-#if defined(HAVE_XINPUT2)
- switches::kTouchDevices,
-#endif
- };
- const CommandLine& browser_command_line =
- *CommandLine::ForCurrentProcess();
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
CommandLine command_line(browser_command_line.GetProgram());
- command_line.CopySwitchesFrom(browser_command_line,
- kForwardSwitches,
- arraysize(kForwardSwitches));
- command_line.AppendSwitch(switches::kGuestSession);
- command_line.AppendSwitch(switches::kIncognito);
- command_line.AppendSwitchASCII(switches::kLoggingLevel,
- kGuestModeLoggingLevel);
- command_line.AppendSwitchASCII(
- switches::kLoginUser,
- UserManager::Get()->logged_in_user().email());
-
- if (start_url.is_valid())
- command_line.AppendArg(start_url.spec());
-
- // Override the value of the homepage that is set in first run mode.
- // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case.
- command_line.AppendSwitchASCII(
- switches::kHomePage,
- GURL(chrome::kChromeUINewTabURL).spec());
-
- std::string cmd_line_str = command_line.command_line_string();
- // Special workaround for the arguments that should be quoted.
- // Copying switches won't be needed when Guest mode won't need restart
- // http://crosbug.com/6924
- if (browser_command_line.HasSwitch(switches::kRegisterPepperPlugins)) {
- cmd_line_str += base::StringPrintf(
- kSwitchFormatString,
- switches::kRegisterPepperPlugins,
- browser_command_line.GetSwitchValueNative(
- switches::kRegisterPepperPlugins).c_str());
- }
-
+ std::string cmd_line_str =
+ GetOffTheRecordCommandLine(start_url,
+ browser_command_line,
+ &command_line);
CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str);
}
}
+std::string LoginUtilsImpl::GetOffTheRecordCommandLine(
+ const GURL& start_url,
+ const CommandLine& base_command_line,
+ CommandLine* command_line) {
+ static const char* kForwardSwitches[] = {
+ switches::kEnableLogging,
+ switches::kUserDataDir,
+ switches::kScrollPixels,
+ switches::kEnableGView,
+ switches::kNoFirstRun,
+ switches::kLoginProfile,
+ switches::kCompressSystemFeedback,
+ switches::kDisableSeccompSandbox,
+#if defined(HAVE_XINPUT2)
+ switches::kTouchDevices,
+#endif
+ };
+ command_line->CopySwitchesFrom(base_command_line,
+ kForwardSwitches,
+ arraysize(kForwardSwitches));
+ command_line->AppendSwitch(switches::kGuestSession);
+ command_line->AppendSwitch(switches::kIncognito);
+ command_line->AppendSwitchASCII(switches::kLoggingLevel,
+ kGuestModeLoggingLevel);
+
+ if (start_url.is_valid())
+ command_line->AppendArg(start_url.spec());
+
+ // Override the value of the homepage that is set in first run mode.
+ // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case.
+ command_line->AppendSwitchASCII(
+ switches::kHomePage,
+ GURL(chrome::kChromeUINewTabURL).spec());
+
+ std::string cmd_line_str = command_line->command_line_string();
+ // Special workaround for the arguments that should be quoted.
+ // Copying switches won't be needed when Guest mode won't need restart
+ // http://crosbug.com/6924
+ if (base_command_line.HasSwitch(switches::kRegisterPepperPlugins)) {
+ cmd_line_str += base::StringPrintf(
+ kSwitchFormatString,
+ switches::kRegisterPepperPlugins,
+ base_command_line.GetSwitchValueNative(
+ switches::kRegisterPepperPlugins).c_str());
+ }
+
+ return cmd_line_str;
+}
+
void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) {
VLOG(1) << "Setting first login prefs";
BootTimesLoader* btl = BootTimesLoader::Get();

Powered by Google App Engine
This is Rietveld 408576698