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

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: easy reading 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"
10 #include "base/file_path.h" 9 #include "base/file_path.h"
11 #include "base/file_util.h" 10 #include "base/file_util.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
14 #include "base/singleton.h" 13 #include "base/singleton.h"
15 #include "base/string_util.h" 14 #include "base/string_util.h"
16 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
17 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
18 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
19 #include "base/time.h" 18 #include "base/time.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 virtual void FetchTokens( 145 virtual void FetchTokens(
147 Profile* profile, 146 Profile* profile,
148 const GaiaAuthConsumer::ClientLoginResult& credentials); 147 const GaiaAuthConsumer::ClientLoginResult& credentials);
149 148
150 // Sets the current background view. 149 // Sets the current background view.
151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); 150 virtual void SetBackgroundView(chromeos::BackgroundView* background_view);
152 151
153 // Gets the current background view. 152 // Gets the current background view.
154 virtual chromeos::BackgroundView* GetBackgroundView(); 153 virtual chromeos::BackgroundView* GetBackgroundView();
155 154
155 protected:
156 virtual std::string GetOffTheRecordCommandLine(
157 const GURL& start_url,
158 const CommandLine& base_command_line,
159 CommandLine *command_line);
160
156 private: 161 private:
157 // Check user's profile for kApplicationLocale setting. 162 // Check user's profile for kApplicationLocale setting.
158 void RespectLocalePreference(Profile* pref); 163 void RespectLocalePreference(Profile* pref);
159 164
160 // Indicates if DoBrowserLaunch will actually launch the browser or not. 165 // Indicates if DoBrowserLaunch will actually launch the browser or not.
161 bool browser_launch_enabled_; 166 bool browser_launch_enabled_;
162 167
163 // The current background view. 168 // The current background view.
164 chromeos::BackgroundView* background_view_; 169 chromeos::BackgroundView* background_view_;
165 170
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 377 }
373 378
374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 379 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
375 VLOG(1) << "Completing off the record login"; 380 VLOG(1) << "Completing off the record login";
376 381
377 UserManager::Get()->OffTheRecordUserLoggedIn(); 382 UserManager::Get()->OffTheRecordUserLoggedIn();
378 383
379 if (CrosLibrary::Get()->EnsureLoaded()) { 384 if (CrosLibrary::Get()->EnsureLoaded()) {
380 // For guest session we ask session manager to restart Chrome with --bwsi 385 // For guest session we ask session manager to restart Chrome with --bwsi
381 // flag. We keep only some of the arguments of this process. 386 // flag. We keep only some of the arguments of this process.
382 static const char* kForwardSwitches[] = { 387 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()); 388 CommandLine command_line(browser_command_line.GetProgram());
398 command_line.CopySwitchesFrom(browser_command_line, 389 std::string cmd_line_str =
399 kForwardSwitches, 390 GetOffTheRecordCommandLine(start_url,
400 arraysize(kForwardSwitches)); 391 browser_command_line,
401 command_line.AppendSwitch(switches::kGuestSession); 392 &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
430 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str); 393 CrosLibrary::Get()->GetLoginLibrary()->RestartJob(getpid(), cmd_line_str);
431 } 394 }
432 } 395 }
433 396
397 std::string LoginUtilsImpl::GetOffTheRecordCommandLine(
398 const GURL& start_url,
399 const CommandLine& base_command_line,
400 CommandLine* command_line) {
401 static const char* kForwardSwitches[] = {
402 switches::kEnableLogging,
403 switches::kUserDataDir,
404 switches::kScrollPixels,
405 switches::kEnableGView,
406 switches::kNoFirstRun,
407 switches::kLoginProfile,
408 switches::kCompressSystemFeedback,
409 switches::kDisableSeccompSandbox,
410 #if defined(HAVE_XINPUT2)
411 switches::kTouchDevices,
412 #endif
413 };
414 command_line->CopySwitchesFrom(base_command_line,
415 kForwardSwitches,
416 arraysize(kForwardSwitches));
417 command_line->AppendSwitch(switches::kGuestSession);
418 command_line->AppendSwitch(switches::kIncognito);
419 command_line->AppendSwitchASCII(switches::kLoggingLevel,
420 kGuestModeLoggingLevel);
421
422 if (start_url.is_valid())
423 command_line->AppendArg(start_url.spec());
424
425 // Override the value of the homepage that is set in first run mode.
426 // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case.
427 command_line->AppendSwitchASCII(
428 switches::kHomePage,
429 GURL(chrome::kChromeUINewTabURL).spec());
430
431 std::string cmd_line_str = command_line->command_line_string();
432 // Special workaround for the arguments that should be quoted.
433 // Copying switches won't be needed when Guest mode won't need restart
434 // http://crosbug.com/6924
435 if (base_command_line.HasSwitch(switches::kRegisterPepperPlugins)) {
436 cmd_line_str += base::StringPrintf(
437 kSwitchFormatString,
438 switches::kRegisterPepperPlugins,
439 base_command_line.GetSwitchValueNative(
440 switches::kRegisterPepperPlugins).c_str());
441 }
442
443 return cmd_line_str;
444 }
445
434 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { 446 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) {
435 VLOG(1) << "Setting first login prefs"; 447 VLOG(1) << "Setting first login prefs";
436 BootTimesLoader* btl = BootTimesLoader::Get(); 448 BootTimesLoader* btl = BootTimesLoader::Get();
437 449
438 static const char kFallbackInputMethodLocale[] = "en-US"; 450 static const char kFallbackInputMethodLocale[] = "en-US";
439 std::string locale(g_browser_process->GetApplicationLocale()); 451 std::string locale(g_browser_process->GetApplicationLocale());
440 // Add input methods based on the application locale when the user first 452 // Add input methods based on the application locale when the user first
441 // logs in. For instance, if the user chooses Japanese as the UI 453 // logs in. For instance, if the user chooses Japanese as the UI
442 // language at the first login, we'll add input methods associated with 454 // language at the first login, we'll add input methods associated with
443 // Japanese, such as mozc. 455 // Japanese, such as mozc.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 BrowserInit browser_init; 566 BrowserInit browser_init;
555 int return_code; 567 int return_code;
556 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), 568 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(),
557 profile, 569 profile,
558 FilePath(), 570 FilePath(),
559 true, 571 true,
560 &return_code); 572 &return_code);
561 } 573 }
562 574
563 } // namespace chromeos 575 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698