summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authoravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-13 15:26:35 +0000
committeravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-13 15:26:35 +0000
commitaee5601c9327490bb91f9594517138d30b0c9d8d (patch)
tree4a0f9c163226fb466ad1abbacfec701d1e7cf926 /chrome/browser/chromeos
parent824ff72c82dd2a95b41c04ff6f26d1ff08823121 (diff)
downloadchromium_src-aee5601c9327490bb91f9594517138d30b0c9d8d.zip
chromium_src-aee5601c9327490bb91f9594517138d30b0c9d8d.tar.gz
chromium_src-aee5601c9327490bb91f9594517138d30b0c9d8d.tar.bz2
Hook new libcros function to Chrome: restart Chrome in BWSI mode with start url passed.
BUG=http://crosbug.com/5154 TEST=Test that going BWSI works and that clicking on "Can't access your account link" opens Chrome in BWSI mode with the correct start url. Review URL: http://codereview.chromium.org/3126009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/cros/login_library.cc5
-rw-r--r--chrome/browser/chromeos/cros/login_library.h3
-rw-r--r--chrome/browser/chromeos/cros/mock_login_library.h1
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc3
-rw-r--r--chrome/browser/chromeos/login/login_screen.cc3
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc38
-rw-r--r--chrome/browser/chromeos/login/login_utils.h6
-rw-r--r--chrome/browser/chromeos/login/mock_authenticator.h2
8 files changed, 45 insertions, 16 deletions
diff --git a/chrome/browser/chromeos/cros/login_library.cc b/chrome/browser/chromeos/cros/login_library.cc
index 341cf59..ab29a47 100644
--- a/chrome/browser/chromeos/cros/login_library.cc
+++ b/chrome/browser/chromeos/cros/login_library.cc
@@ -30,6 +30,10 @@ class LoginLibraryImpl : public LoginLibrary {
return chromeos::StopSession("");
}
+ bool RestartJob(int pid, const std::string& command_line) {
+ return chromeos::RestartJob(pid, command_line.c_str());
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(LoginLibraryImpl);
};
@@ -43,6 +47,7 @@ class LoginLibraryStubImpl : public LoginLibrary {
bool StartSession(const std::string& user_email,
const std::string& unique_id /* unused */) { return true; }
bool StopSession(const std::string& unique_id /* unused */) { return true; }
+ bool RestartJob(int pid, const std::string& command_line) { return true; }
private:
DISALLOW_COPY_AND_ASSIGN(LoginLibraryStubImpl);
diff --git a/chrome/browser/chromeos/cros/login_library.h b/chrome/browser/chromeos/cros/login_library.h
index 8c3b4a3..c6bd9e5 100644
--- a/chrome/browser/chromeos/cros/login_library.h
+++ b/chrome/browser/chromeos/cros/login_library.h
@@ -33,6 +33,9 @@ class LoginLibrary {
// indicated by |unique_id|.
virtual bool StopSession(const std::string& unique_id /* unused */) = 0;
+ // Restarts the job with specified command line string.
+ virtual bool RestartJob(int pid, const std::string& command_line) = 0;
+
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via CrosLibrary::Get().
static LoginLibrary* GetImpl(bool stub);
diff --git a/chrome/browser/chromeos/cros/mock_login_library.h b/chrome/browser/chromeos/cros/mock_login_library.h
index e7a9e86..574acef 100644
--- a/chrome/browser/chromeos/cros/mock_login_library.h
+++ b/chrome/browser/chromeos/cros/mock_login_library.h
@@ -21,6 +21,7 @@ class MockLoginLibrary : public LoginLibrary {
MOCK_METHOD2(StartSession, bool(const std::string&, const std::string&));
MOCK_METHOD1(StartSession, bool(const std::string&));
MOCK_METHOD1(StopSession, bool(const std::string&));
+ MOCK_METHOD2(RestartJob, bool(int, const std::string&));
};
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 9428607..2aa1ede 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -388,8 +388,7 @@ void ExistingUserController::OnLoginSuccess(const std::string& username,
}
void ExistingUserController::OnOffTheRecordLoginSuccess() {
- AppendStartUrlToCmdline();
- LoginUtils::Get()->CompleteOffTheRecordLogin();
+ LoginUtils::Get()->CompleteOffTheRecordLogin(start_url_);
}
void ExistingUserController::OnPasswordChangeDetected(
diff --git a/chrome/browser/chromeos/login/login_screen.cc b/chrome/browser/chromeos/login/login_screen.cc
index 9e1d886..ddd71df 100644
--- a/chrome/browser/chromeos/login/login_screen.cc
+++ b/chrome/browser/chromeos/login/login_screen.cc
@@ -100,8 +100,7 @@ void LoginScreen::OnLoginSuccess(const std::string& username,
void LoginScreen::OnOffTheRecordLoginSuccess() {
delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_GUEST_SELECTED);
- AppendStartUrlToCmdline();
- LoginUtils::Get()->CompleteOffTheRecordLogin();
+ LoginUtils::Get()->CompleteOffTheRecordLogin(start_url_);
}
void LoginScreen::AppendStartUrlToCmdline() {
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index c3ef2f3..b95d3dc 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -12,6 +12,7 @@
#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/singleton.h"
+#include "base/string_util.h"
#include "base/time.h"
#include "chrome/browser/browser_init.h"
#include "chrome/browser/browser_process.h"
@@ -70,7 +71,7 @@ class LoginUtilsImpl : public LoginUtils,
// Invoked after the tmpfs is successfully mounted.
// Launches a browser in the off the record (incognito) mode.
- virtual void CompleteOffTheRecordLogin();
+ virtual void CompleteOffTheRecordLogin(const GURL& start_url);
// Creates and returns the authenticator to use. The caller owns the returned
// Authenticator and must delete it when done.
@@ -174,21 +175,40 @@ void LoginUtilsImpl::CompleteLogin(const std::string& username,
auth_token_ = credentials.token;
}
-void LoginUtilsImpl::CompleteOffTheRecordLogin() {
+void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
LOG(INFO) << "Completing off the record login";
UserManager::Get()->OffTheRecordUserLoggedIn();
ConnectToPreferredNetwork();
if (CrosLibrary::Get()->EnsureLoaded()) {
- CrosLibrary::Get()->GetLoginLibrary()->StartSession(
- UserManager::Get()->logged_in_user().email(),
- "");
+ // For BWSI 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::kLoggingLevel,
+ switches::kEnableLogging,
+ switches::kUserDataDir,
+ switches::kScrollPixels,
+ switches::kEnableGView,
+ switches::kNoFirstRun,
+ switches::kLoginProfile
+ };
+ 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::kBWSI);
+ command_line.AppendSwitchASCII(
+ switches::kLoginUser,
+ UserManager::Get()->logged_in_user().email());
+ if (start_url.is_valid())
+ command_line.AppendLooseValue(UTF8ToWide(start_url.spec()));
+ CrosLibrary::Get()->GetLoginLibrary()->RestartJob(
+ getpid(),
+ command_line.command_line_string());
}
-
- // Session manager should restart Chrome in BWSI mode now if we exit
- // uncleanly.
- exit(1);
}
Authenticator* LoginUtilsImpl::CreateAuthenticator(
diff --git a/chrome/browser/chromeos/login/login_utils.h b/chrome/browser/chromeos/login/login_utils.h
index aab4a68..92bcd3e 100644
--- a/chrome/browser/chromeos/login/login_utils.h
+++ b/chrome/browser/chromeos/login/login_utils.h
@@ -11,6 +11,7 @@
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
+class GURL;
class Profile;
namespace chromeos {
@@ -46,8 +47,9 @@ class LoginUtils {
const GaiaAuthConsumer::ClientLoginResult& credentials) = 0;
// Invoked after the tmpfs is successfully mounted.
- // Launches a browser in the off the record (incognito) mode.
- virtual void CompleteOffTheRecordLogin() = 0;
+ // Asks session manager to restart Chrome in Browse Without Sign In mode.
+ // |start_url| is url for launched browser to open.
+ virtual void CompleteOffTheRecordLogin(const GURL& start_url) = 0;
// Creates and returns the authenticator to use. The caller owns the returned
// Authenticator and must delete it when done.
diff --git a/chrome/browser/chromeos/login/mock_authenticator.h b/chrome/browser/chromeos/login/mock_authenticator.h
index 5d90cb7..403af44 100644
--- a/chrome/browser/chromeos/login/mock_authenticator.h
+++ b/chrome/browser/chromeos/login/mock_authenticator.h
@@ -107,7 +107,7 @@ class MockLoginUtils : public LoginUtils {
EXPECT_EQ(expected_username_, username);
}
- virtual void CompleteOffTheRecordLogin() {
+ virtual void CompleteOffTheRecordLogin(const GURL& start_url) {
}
virtual Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer) {