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

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/profiles/profile.h" 6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/tab_contents/tab_contents.h" 7 #include "chrome/browser/tab_contents/tab_contents.h"
8 #include "chrome/browser/tab_contents/tab_contents_view.h" 8 #include "chrome/browser/tab_contents/tab_contents_view.h"
9 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h" 11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/browser_navigator.h" 12 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/in_process_browser_test.h" 16 #include "chrome/test/in_process_browser_test.h"
17 #include "chrome/test/ui_test_utils.h" 17 #include "chrome/test/ui_test_utils.h"
18 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
19 19
20 #if defined(OS_CHROMEOS)
21 #include "chrome/browser/chromeos/login/login_utils.h"
22 #endif
23
20 namespace { 24 namespace {
21 25
22 class BrowserNavigatorTest : public InProcessBrowserTest, 26 class BrowserNavigatorTest : public InProcessBrowserTest,
23 public NotificationObserver { 27 public NotificationObserver {
24 protected: 28 protected:
25 GURL GetGoogleURL() const { 29 GURL GetGoogleURL() const {
26 return GURL("http://www.google.com/"); 30 return GURL("http://www.google.com/");
27 } 31 }
28 32
29 browser::NavigateParams MakeNavigateParams() const { 33 browser::NavigateParams MakeNavigateParams() const {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // No tab contents should have been created 132 // No tab contents should have been created
129 EXPECT_EQ(previous_tab_contents_count, 133 EXPECT_EQ(previous_tab_contents_count,
130 created_tab_contents_count_); 134 created_tab_contents_count_);
131 } 135 }
132 136
133 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 137 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
134 Disposition_SingletonTabNoneExisting) { 138 Disposition_SingletonTabNoneExisting) {
135 GURL url("http://www.google.com/"); 139 GURL url("http://www.google.com/");
136 GURL singleton_url1("http://maps.google.com/"); 140 GURL singleton_url1("http://maps.google.com/");
137 141
138 // We should have one browser with 3 tabs, the 3rd selected. 142 // We should have one browser with 1 tab.
139 EXPECT_EQ(1u, BrowserList::size()); 143 EXPECT_EQ(1u, BrowserList::size());
140 EXPECT_EQ(0, browser()->selected_index()); 144 EXPECT_EQ(0, browser()->selected_index());
141 145
142 // Navigate to singleton_url1. 146 // Navigate to singleton_url1.
143 browser::NavigateParams p(MakeNavigateParams()); 147 browser::NavigateParams p(MakeNavigateParams());
144 p.disposition = SINGLETON_TAB; 148 p.disposition = SINGLETON_TAB;
145 p.url = singleton_url1; 149 p.url = singleton_url1;
146 browser::Navigate(&p); 150 browser::Navigate(&p);
147 151
148 // We should now have 2 tabs, the 2nd one selected. 152 // We should now have 2 tabs, the 2nd one selected.
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 browser::Navigate(&p); 678 browser::Navigate(&p);
675 679
676 // The second tab should still be selected, but navigated to the new path. 680 // The second tab should still be selected, but navigated to the new path.
677 EXPECT_EQ(browser(), p.browser); 681 EXPECT_EQ(browser(), p.browser);
678 EXPECT_EQ(2, browser()->tab_count()); 682 EXPECT_EQ(2, browser()->tab_count());
679 EXPECT_EQ(1, browser()->selected_index()); 683 EXPECT_EQ(1, browser()->selected_index());
680 EXPECT_EQ(singleton_url_target, 684 EXPECT_EQ(singleton_url_target,
681 browser()->GetSelectedTabContents()->GetURL()); 685 browser()->GetSelectedTabContents()->GetURL());
682 } 686 }
683 687
688 // This test verifies that the settings page isn't open in the incognito window.
689 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
690 Disposition_Settings_UseNonIncognitoWindow) {
691 Browser* incognito_browser = CreateIncognitoBrowser();
692
693 EXPECT_EQ(2u, BrowserList::size());
694 EXPECT_EQ(1, browser()->tab_count());
695 EXPECT_EQ(1, incognito_browser->tab_count());
696
697 // Navigate to the settings page.
698 browser::NavigateParams p(MakeNavigateParams(incognito_browser));
699 p.disposition = SINGLETON_TAB;
700 p.url = GURL("chrome://settings");
701 p.show_window = true;
702 p.ignore_path = true;
703 browser::Navigate(&p);
704
705 // The settings page should be opened in browser() window.
706 EXPECT_NE(incognito_browser, p.browser);
707 EXPECT_EQ(browser(), p.browser);
708 EXPECT_EQ(2, browser()->tab_count());
709 EXPECT_EQ(GURL("chrome://settings"),
710 browser()->GetSelectedTabContents()->GetURL());
711 }
712
713 // This test verifies that the bookmarks page isn't open in the incognito
Evan Stade 2011/01/31 21:06:22 s/open/opened (also in the other comments)
altimofeev 2011/02/01 12:42:15 Done.
714 // window.
715 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
716 Disposition_Bookmarks_UseNonIncognitoWindow) {
717 Browser* incognito_browser = CreateIncognitoBrowser();
718
719 EXPECT_EQ(2u, BrowserList::size());
720 EXPECT_EQ(1, browser()->tab_count());
721 EXPECT_EQ(1, incognito_browser->tab_count());
722
723 // Navigate to the settings page.
724 browser::NavigateParams p(MakeNavigateParams(incognito_browser));
725 p.disposition = SINGLETON_TAB;
726 p.url = GURL("chrome://bookmarks");
727 p.show_window = true;
728 p.ignore_path = true;
729 browser::Navigate(&p);
730
731 // The bookmarks page should be opened in browser() window.
732 EXPECT_NE(incognito_browser, p.browser);
733 EXPECT_EQ(browser(), p.browser);
734 EXPECT_EQ(2, browser()->tab_count());
735 EXPECT_EQ(GURL("chrome://bookmarks"),
736 browser()->GetSelectedTabContents()->GetURL());
737 }
738
739 #if defined(OS_CHROMEOS)
740 // Subclass that tests navigation while in the Guest session.
741 class BrowserGuestSessionNavigatorTest: public BrowserNavigatorTest {
742 protected:
743 virtual void SetUpCommandLine(CommandLine* command_line) {
744 CommandLine command_line_copy = *command_line;
745 chromeos::LoginUtils::Get()->GetOffTheRecordCommandLine(GetGoogleURL(),
746 command_line_copy,
747 command_line);
748 }
749 };
750
751 // This test verifies that the settings page is open in the incognito window in
752 // Guest Session (as well as all other windows in Guest session).
753 IN_PROC_BROWSER_TEST_F(BrowserGuestSessionNavigatorTest,
754 Disposition_Settings_UseIncognitoWindow) {
755 Browser* incognito_browser = CreateIncognitoBrowser();
756
757 EXPECT_EQ(2u, BrowserList::size());
758 EXPECT_EQ(1, browser()->tab_count());
759 EXPECT_EQ(1, incognito_browser->tab_count());
760
761 // Navigate to the settings page.
762 browser::NavigateParams p(MakeNavigateParams(incognito_browser));
763 p.disposition = SINGLETON_TAB;
764 p.url = GURL("chrome://settings");
765 p.show_window = true;
766 p.ignore_path = true;
767 browser::Navigate(&p);
768
769 // Settings page should be opened in incognito window.
770 EXPECT_NE(browser(), p.browser);
771 EXPECT_EQ(incognito_browser, p.browser);
772 EXPECT_EQ(2, incognito_browser->tab_count());
773 EXPECT_EQ(GURL("chrome://settings"),
774 incognito_browser->GetSelectedTabContents()->GetURL());
775 }
776 #endif
777
684 } // namespace 778 } // namespace
OLDNEW
« chrome/browser/chromeos/login/mock_authenticator.h ('K') | « chrome/browser/ui/browser_navigator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698