diff options
author | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 08:16:46 +0000 |
---|---|---|
committer | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 08:16:46 +0000 |
commit | bd817c27d77811c2d5012714dd8e79e3c1defd8d (patch) | |
tree | 1742edb7a64f76fe21659dfbf7ef9c9e256c714a /chrome | |
parent | 4623db131a42213e645f2bfa5238acc36dfa8e37 (diff) | |
download | chromium_src-bd817c27d77811c2d5012714dd8e79e3c1defd8d.zip chromium_src-bd817c27d77811c2d5012714dd8e79e3c1defd8d.tar.gz chromium_src-bd817c27d77811c2d5012714dd8e79e3c1defd8d.tar.bz2 |
Prevent non-Incognito windows in the Guest session.
BUG=chromium-os:10273
TEST=manual
Review URL: http://codereview.chromium.org/6272016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74263 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/login/login_utils.cc | 106 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/login_utils.h | 15 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/mock_authenticator.h | 7 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options/options_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.cc | 30 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator_browsertest.cc | 160 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator_browsertest.h | 45 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator_browsertest_chromeos.cc | 53 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 |
11 files changed, 324 insertions, 104 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 9465a43..d8169ab 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,53 +385,12 @@ 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); PrefService* local_state = g_browser_process->local_state(); std::string cur_locale = g_browser_process->GetApplicationLocale(); @@ -443,6 +408,55 @@ void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { } } +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(); diff --git a/chrome/browser/chromeos/login/login_utils.h b/chrome/browser/chromeos/login/login_utils.h index e04c52a..05a1a6c 100644 --- a/chrome/browser/chromeos/login/login_utils.h +++ b/chrome/browser/chromeos/login/login_utils.h @@ -10,10 +10,15 @@ #include "chrome/common/net/gaia/gaia_auth_consumer.h" +class CommandLine; class GURL; class Profile; class PrefService; +namespace { +class BrowserGuestSessionNavigatorTest; +} // namespace + namespace chromeos { class Authenticator; @@ -83,6 +88,16 @@ class LoginUtils { // Gets the current background view. virtual BackgroundView* GetBackgroundView() = 0; + + protected: + friend class ::BrowserGuestSessionNavigatorTest; + + // Returns command line string to be used for the OTR process. Also modifies + // given command line. + virtual std::string GetOffTheRecordCommandLine( + const GURL& start_url, + const CommandLine& base_command_line, + CommandLine* command_line) = 0; }; } // namespace chromeos diff --git a/chrome/browser/chromeos/login/mock_authenticator.h b/chrome/browser/chromeos/login/mock_authenticator.h index 7abed07..320ddcf 100644 --- a/chrome/browser/chromeos/login/mock_authenticator.h +++ b/chrome/browser/chromeos/login/mock_authenticator.h @@ -158,6 +158,13 @@ class MockLoginUtils : public LoginUtils { return background_view_; } + virtual std::string GetOffTheRecordCommandLine( + const GURL& start_url, + const CommandLine& base_command_line, + CommandLine* command_line) { + return std::string(); + } + private: std::string expected_username_; std::string expected_password_; diff --git a/chrome/browser/dom_ui/options/options_ui.cc b/chrome/browser/dom_ui/options/options_ui.cc index b45f95e..2ae3772 100644 --- a/chrome/browser/dom_ui/options/options_ui.cc +++ b/chrome/browser/dom_ui/options/options_ui.cc @@ -258,7 +258,7 @@ RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { } void OptionsUI::InitializeHandlers() { - DCHECK(!GetProfile()->IsOffTheRecord()); + DCHECK(!GetProfile()->IsOffTheRecord() || Profile::IsGuestSession()); // The reinitialize call from DidBecomeActiveForReusedRenderView end up being // delivered after a new web page DOM has been brought up in an existing diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index ac869eb..85c71ad 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -32,6 +32,7 @@ #include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/json_pref_store.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" @@ -126,6 +127,16 @@ URLRequestContextGetter* Profile::GetDefaultRequestContext() { return default_request_context_; } +bool Profile::IsGuestSession() { +#if defined(OS_CHROMEOS) + static bool is_guest_session = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); + return is_guest_session; +#else + return false; +#endif +} + bool Profile::IsSyncAccessible() { ProfileSyncService* syncService = GetProfileSyncService(); return syncService && !syncService->IsManaged(); @@ -711,6 +722,25 @@ class OffTheRecordProfileImpl : public Profile, DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); }; +#if defined(OS_CHROMEOS) +// Special case of the OffTheRecordProfileImpl which is used while Guest +// session in CrOS. +class GuestSessionProfile : public OffTheRecordProfileImpl { + public: + explicit GuestSessionProfile(Profile* real_profile) + : OffTheRecordProfileImpl(real_profile) { + } + + virtual PersonalDataManager* GetPersonalDataManager() { + return GetOriginalProfile()->GetPersonalDataManager(); + } +}; +#endif + Profile* Profile::CreateOffTheRecordProfile() { +#if defined(OS_CHROMEOS) + if (Profile::IsGuestSession()) + return new GuestSessionProfile(this); +#endif return new OffTheRecordProfileImpl(this); } diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 3391c6b..976eacd 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -530,6 +530,9 @@ class Profile { // profile. virtual PrerenderManager* GetPrerenderManager() = 0; + // Returns whether it is a guest session. + static bool IsGuestSession(); + #ifdef UNIT_TEST // Use with caution. GetDefaultRequestContext may be called on any thread! static void set_default_request_context(URLRequestContextGetter* c) { diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index f9dca07..bcd40cf 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -105,7 +105,8 @@ int GetIndexOfSingletonTab(browser::NavigateParams* params) { // Change some of the navigation parameters based on the particular URL. // Currently this applies to chrome://settings and the bookmark manager, -// which we always want to open in a normal (not incognito) window. +// which we always want to open in a normal (not incognito) window. Guest +// session is an exception. void AdjustNavigateParamsForURL(browser::NavigateParams* params) { if (!params->target_contents && params->url.scheme() == chrome::kChromeUIScheme && @@ -114,7 +115,7 @@ void AdjustNavigateParamsForURL(browser::NavigateParams* params) { Profile* profile = params->browser ? params->browser->profile() : params->profile; - if (profile->IsOffTheRecord()) { + if (profile->IsOffTheRecord() && !Profile::IsGuestSession()) { profile = profile->GetOriginalProfile(); params->disposition = SINGLETON_TAB; diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 3fdf22f..53f613c 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc @@ -2,81 +2,79 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/ui/browser_navigator_browsertest.h" + #include "base/command_line.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" -#include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "ipc/ipc_message.h" -namespace { +GURL BrowserNavigatorTest::GetGoogleURL() const { + return GURL("http://www.google.com/"); +} -class BrowserNavigatorTest : public InProcessBrowserTest, - public NotificationObserver { - protected: - GURL GetGoogleURL() const { - return GURL("http://www.google.com/"); - } +browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { + return MakeNavigateParams(browser()); +} - browser::NavigateParams MakeNavigateParams() const { - return MakeNavigateParams(browser()); - } - browser::NavigateParams MakeNavigateParams(Browser* browser) const { - browser::NavigateParams params(browser, GetGoogleURL(), - PageTransition::LINK); - params.show_window = true; - return params; - } +browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( + Browser* browser) const { + browser::NavigateParams params(browser, GetGoogleURL(), + PageTransition::LINK); + params.show_window = true; + return params; +} - Browser* CreateEmptyBrowserForType(Browser::Type type, Profile* profile) { - Browser* browser = Browser::CreateForType(type, profile); - browser->AddBlankTab(true); - return browser; - } +Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, + Profile* profile) { + Browser* browser = Browser::CreateForType(type, profile); + browser->AddBlankTab(true); + return browser; +} - TabContentsWrapper* CreateTabContents() { - return Browser::TabContentsFactory( - browser()->profile(), - NULL, - MSG_ROUTING_NONE, - browser()->GetSelectedTabContents(), - NULL); - } +TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() { + return Browser::TabContentsFactory( + browser()->profile(), + NULL, + MSG_ROUTING_NONE, + browser()->GetSelectedTabContents(), + NULL); +} - void RunSuppressTest(WindowOpenDisposition disposition) { - GURL old_url = browser()->GetSelectedTabContents()->GetURL(); - browser::NavigateParams p(MakeNavigateParams()); - p.disposition = disposition; - browser::Navigate(&p); +void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { + GURL old_url = browser()->GetSelectedTabContents()->GetURL(); + browser::NavigateParams p(MakeNavigateParams()); + p.disposition = disposition; + browser::Navigate(&p); - // Nothing should have happened as a result of Navigate(); - EXPECT_EQ(1, browser()->tab_count()); - EXPECT_EQ(1u, BrowserList::size()); - EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); - } + // Nothing should have happened as a result of Navigate(); + EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1u, BrowserList::size()); + EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); +} - void Observe(NotificationType type, const NotificationSource& source, - const NotificationDetails& details) { - switch (type.value) { - case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: { - ++this->created_tab_contents_count_; - break; - } - default: - break; +void BrowserNavigatorTest::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: { + ++this->created_tab_contents_count_; + break; } + default: + break; } +} - size_t created_tab_contents_count_; -}; +namespace { // This test verifies that when a navigation occurs within a tab, the tab count // of the Browser remains the same and the current tab bears the loaded URL. @@ -90,14 +88,14 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { EXPECT_EQ(1, browser()->tab_count()); } -// This test verifies that a singleton tab is refocused if one is already open +// This test verifies that a singleton tab is refocused if one is already opened // in another or an existing window, or added if it is not. IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { GURL url("http://www.google.com/"); GURL singleton_url1("http://maps.google.com/"); // Register for a notification if an additional tab_contents was instantiated. - // Opening a Singleton tab that is already open should not be opening a new + // Opening a Singleton tab that is already opened should not be opening a new // tab nor be creating a new TabContents object NotificationRegistrar registrar; @@ -135,7 +133,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, GURL url("http://www.google.com/"); GURL singleton_url1("http://maps.google.com/"); - // We should have one browser with 3 tabs, the 3rd selected. + // We should have one browser with 1 tab. EXPECT_EQ(1u, BrowserList::size()); EXPECT_EQ(0, browser()->selected_index()); @@ -681,4 +679,56 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, browser()->GetSelectedTabContents()->GetURL()); } +// This test verifies that the settings page isn't opened in the incognito +// window. +IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, + Disposition_Settings_UseNonIncognitoWindow) { + Browser* incognito_browser = CreateIncognitoBrowser(); + + EXPECT_EQ(2u, BrowserList::size()); + EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, incognito_browser->tab_count()); + + // Navigate to the settings page. + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); + p.disposition = SINGLETON_TAB; + p.url = GURL("chrome://settings"); + p.show_window = true; + p.ignore_path = true; + browser::Navigate(&p); + + // The settings page should be opened in browser() window. + EXPECT_NE(incognito_browser, p.browser); + EXPECT_EQ(browser(), p.browser); + EXPECT_EQ(2, browser()->tab_count()); + EXPECT_EQ(GURL("chrome://settings"), + browser()->GetSelectedTabContents()->GetURL()); +} + +// This test verifies that the bookmarks page isn't opened in the incognito +// window. +IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, + Disposition_Bookmarks_UseNonIncognitoWindow) { + Browser* incognito_browser = CreateIncognitoBrowser(); + + EXPECT_EQ(2u, BrowserList::size()); + EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, incognito_browser->tab_count()); + + // Navigate to the settings page. + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); + p.disposition = SINGLETON_TAB; + p.url = GURL("chrome://bookmarks"); + p.show_window = true; + p.ignore_path = true; + browser::Navigate(&p); + + // The bookmarks page should be opened in browser() window. + EXPECT_NE(incognito_browser, p.browser); + EXPECT_EQ(browser(), p.browser); + EXPECT_EQ(2, browser()->tab_count()); + EXPECT_EQ(GURL("chrome://bookmarks"), + browser()->GetSelectedTabContents()->GetURL()); +} + } // namespace diff --git a/chrome/browser/ui/browser_navigator_browsertest.h b/chrome/browser/ui/browser_navigator_browsertest.h new file mode 100644 index 0000000..0f18da5 --- /dev/null +++ b/chrome/browser/ui/browser_navigator_browsertest.h @@ -0,0 +1,45 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_BROWSER_NAVIGATOR_BROWSERTEST_H_ +#define CHROME_BROWSER_UI_BROWSER_NAVIGATOR_BROWSERTEST_H_ + +#include "chrome/browser/ui/browser.h" +#include "chrome/common/notification_type.h" +#include "chrome/test/in_process_browser_test.h" + +class GURL; +class NotificationDetails; +class NotificationSource; +class Profile; +class TabContentsWrapper; + +namespace browser { +struct NavigateParams; +} + +// Browsertest class for testing the browser navigation. It is also a base class +// for the |BrowserGuestModeNavigation| which tests navigation while in guest +// mode. +class BrowserNavigatorTest : public InProcessBrowserTest, + public NotificationObserver { + protected: + GURL GetGoogleURL() const; + + browser::NavigateParams MakeNavigateParams() const; + browser::NavigateParams MakeNavigateParams(Browser* browser) const; + + Browser* CreateEmptyBrowserForType(Browser::Type type, Profile* profile); + + TabContentsWrapper* CreateTabContents(); + + void RunSuppressTest(WindowOpenDisposition disposition); + + void Observe(NotificationType type, const NotificationSource& source, + const NotificationDetails& details); + + size_t created_tab_contents_count_; +}; + +#endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_BROWSERTEST_H_ diff --git a/chrome/browser/ui/browser_navigator_browsertest_chromeos.cc b/chrome/browser/ui/browser_navigator_browsertest_chromeos.cc new file mode 100644 index 0000000..960d244 --- /dev/null +++ b/chrome/browser/ui/browser_navigator_browsertest_chromeos.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/browser_navigator_browsertest.h" + +#include "base/command_line.h" +#include "chrome/browser/chromeos/login/login_utils.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_navigator.h" + +namespace { + +// Subclass that tests navigation while in the Guest session. +class BrowserGuestSessionNavigatorTest: public BrowserNavigatorTest { + protected: + virtual void SetUpCommandLine(CommandLine* command_line) { + CommandLine command_line_copy = *command_line; + chromeos::LoginUtils::Get()->GetOffTheRecordCommandLine(GetGoogleURL(), + command_line_copy, + command_line); + } +}; + +// This test verifies that the settings page is opened in the incognito window +// in Guest Session (as well as all other windows in Guest session). +IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest, + Disposition_Settings_UseIncognitoWindow) { + Browser* incognito_browser = CreateIncognitoBrowser(); + + EXPECT_EQ(2u, BrowserList::size()); + EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, incognito_browser->tab_count()); + + // Navigate to the settings page. + browser::NavigateParams p(MakeNavigateParams(incognito_browser)); + p.disposition = SINGLETON_TAB; + p.url = GURL("chrome://settings"); + p.show_window = true; + p.ignore_path = true; + browser::Navigate(&p); + + // Settings page should be opened in incognito window. + EXPECT_NE(browser(), p.browser); + EXPECT_EQ(incognito_browser, p.browser); + EXPECT_EQ(2, incognito_browser->tab_count()); + EXPECT_EQ(GURL("chrome://settings"), + incognito_browser->GetSelectedTabContents()->GetURL()); +} + +} // namespace diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 2208713..436b65b 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2195,6 +2195,8 @@ 'browser/task_manager/task_manager_browsertest.cc', 'browser/ui/browser_init_browsertest.cc', 'browser/ui/browser_navigator_browsertest.cc', + 'browser/ui/browser_navigator_browsertest.h', + 'browser/ui/browser_navigator_browsertest_chromeos.cc', 'browser/ui/cocoa/view_id_util_browsertest.mm', 'browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm', 'browser/ui/cocoa/applescript/window_applescript_test.mm', |