diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 00:12:09 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 00:12:09 +0000 |
commit | 3493043c61392d48177275f90e29bdeede966308 (patch) | |
tree | e3ba4eca8ba36ad9f257d161daf534dd9b26e672 /chrome/browser | |
parent | 3367fc1dd134eeaf9ab6e62397f05ad3964319fe (diff) | |
download | chromium_src-3493043c61392d48177275f90e29bdeede966308.zip chromium_src-3493043c61392d48177275f90e29bdeede966308.tar.gz chromium_src-3493043c61392d48177275f90e29bdeede966308.tar.bz2 |
Kiosk Mode implementation.
Kiosk mode will just hide the status bar and initially set it as full screen. Added some tests to add --kiosk mode as a command switch that tests if its in fullscreen state and doesn't have a status bubble.
BUG=23145
TEST=Kiosk Mode functions and
Run the ./ui_tests --gtest_filter=KioskModeTest.*
Review URL: http://codereview.chromium.org/244003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 23 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 2 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 13 | ||||
-rw-r--r-- | chrome/browser/browser.h | 1 | ||||
-rw-r--r-- | chrome/browser/browser_init.cc | 6 | ||||
-rw-r--r-- | chrome/browser/browser_uitest.cc | 26 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 3 |
13 files changed, 102 insertions, 2 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 537cc6d..8df4ae4 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -321,6 +321,9 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreen, IsFullscreen) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreenBubbleVisible, + GetFullscreenBubbleVisibility) IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAccelerator, ApplyAccelerator) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, @@ -1110,6 +1113,26 @@ void AutomationProvider::SetShelfVisibility(int handle, bool visible) { } } +void AutomationProvider::IsFullscreen(int handle, bool* visible) { + *visible = false; + + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + if (browser) + *visible = browser->window()->IsFullscreen(); + } +} + +void AutomationProvider::GetFullscreenBubbleVisibility(int handle, + bool* visible) { + *visible = false; + + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + if (browser) + *visible = browser->window()->IsFullscreenBubbleVisible(); + } +} void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { *count = -1; // -1 is the error code diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 82a2d72..66e7de8 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -226,6 +226,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void SetFilteredInet(const IPC::Message& message, bool enabled); void GetFilteredInetHitCount(int* hit_count); void SetProxyConfig(const std::string& new_proxy_config); + void IsFullscreen(int handle, bool* is_fullscreen); + void GetFullscreenBubbleVisibility(int handle, bool* is_visible); #if defined(OS_WIN) void ScheduleMouseEvent(views::View* view, diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 30a7a01..27e1423 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -921,6 +921,14 @@ void Browser::ConvertPopupToTabbedBrowser() { } void Browser::ToggleFullscreenMode() { +#if !defined(OS_MACOSX) + // In kiosk mode, we always want to be fullscreen. When the browser first + // starts we're not yet fullscreen, so let the initial toggle go through. + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && + window_->IsFullscreen()) + return; +#endif + UserMetrics::RecordAction(L"ToggleFullscreen", profile_); window_->SetFullscreen(!window_->IsFullscreen()); // On Linux, setting fullscreen mode is an async call to the X server, which @@ -2644,6 +2652,11 @@ void Browser::RemoveScheduledUpdatesFor(TabContents* contents) { // Browser, Getters for UI (private): StatusBubble* Browser::GetStatusBubble() { +#if !defined(OS_MACOSX) + // In kiosk mode, we want to always hide the status bubble. + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) + return NULL; +#endif return window_ ? window_->GetStatusBubble() : NULL; } diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 19ee871..a587aff 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -347,6 +347,7 @@ class Browser : public TabStripModelDelegate, void RestoreTab(); void WriteCurrentURLToClipboard(); void ConvertPopupToTabbedBrowser(); + // In kiosk mode, the first toggle is valid, the rest is discarded. void ToggleFullscreenMode(); void Exit(); #if defined(TOOLKIT_VIEWS) diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index a0ee959..5a08089 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -559,6 +559,12 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( if (!browser || browser->type() != Browser::TYPE_NORMAL) browser = Browser::Create(profile_); +#if !defined(OS_MACOSX) + // In kiosk mode, we want to always be fullscreen, so switch to that now. + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) + browser->ToggleFullscreenMode(); +#endif + for (size_t i = 0; i < urls.size(); ++i) { // We skip URLs that we'd have to launch an external protocol handler for. // This avoids us getting into an infinite loop asking ourselves to open diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 0fd6352..27f3167 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -288,4 +288,30 @@ TEST_F(SecurityTest, DisallowFileUrlUniversalAccessTest) { ASSERT_STREQ("Disallowed", value.c_str()); } +#if !defined(OS_MACOSX) +class KioskModeTest : public UITest { + public: + KioskModeTest() { + launch_arguments_.AppendSwitch(switches::kKioskMode); + } +}; + +TEST_F(KioskModeTest, EnableKioskModeTest) { + // Load a dummy url. + FilePath test_file(test_data_directory_); + test_file = test_file.AppendASCII("title1.html"); + + // Verify that the window is present. + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + // Check if browser is in fullscreen mode. + bool is_visible; + ASSERT_TRUE(browser->IsFullscreen(&is_visible)); + EXPECT_TRUE(is_visible); + ASSERT_TRUE(browser->IsFullscreenBubbleVisible(&is_visible)); + EXPECT_FALSE(is_visible); +} +#endif + } // namespace diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index 2ba45da..de9823e 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -118,6 +118,9 @@ class BrowserWindow { virtual void SetFullscreen(bool fullscreen) = 0; virtual bool IsFullscreen() const = 0; + // Returns true if the fullscreen bubble is visible. + virtual bool IsFullscreenBubbleVisible() const = 0; + // Returns the location bar. virtual LocationBar* GetLocationBar() const = 0; diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 74220e5..b5ef31f 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -49,6 +49,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual bool IsMaximized() const; virtual void SetFullscreen(bool fullscreen); virtual bool IsFullscreen() const; + virtual bool IsFullscreenBubbleVisible() const; virtual LocationBar* GetLocationBar() const; virtual void SetFocusToLocationBar(); virtual void UpdateStopGoState(bool is_loading, bool force); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 10f206f..8e5b50b 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -165,6 +165,10 @@ bool BrowserWindowCocoa::IsFullscreen() const { return !![controller_ isFullscreen]; } +bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { + return false; +} + gfx::Rect BrowserWindowCocoa::GetRootWindowResizerRect() const { NSRect tabRect = [controller_ selectedTabGrowBoxRect]; return gfx::Rect(NSRectToCGRect(tabRect)); diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 63fe880..87bf9c2 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1018,6 +1018,11 @@ bool BrowserWindowGtk::IsFullscreen() const { return (state_ & GDK_WINDOW_STATE_FULLSCREEN); } +bool BrowserWindowGtk::IsFullscreenBubbleVisible() const { + // There is no fullscreen bubble for Linux. + return false; +} + LocationBar* BrowserWindowGtk::GetLocationBar() const { return toolbar_->GetLocationBar(); } diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index cb272ad..6d79a9a 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -78,6 +78,7 @@ class BrowserWindowGtk : public BrowserWindow, virtual bool IsMaximized() const; virtual void SetFullscreen(bool fullscreen); virtual bool IsFullscreen() const; + virtual bool IsFullscreenBubbleVisible() const; virtual LocationBar* GetLocationBar() const; virtual void SetFocusToLocationBar(); virtual void UpdateStopGoState(bool is_loading, bool force); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index ac22274..23d7bd3 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -893,8 +893,16 @@ void BrowserView::SetFullscreen(bool fullscreen) { frame_->GetWindow()->SetFullscreen(fullscreen); if (fullscreen) { - fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(), - browser_.get())); +#if !defined(OS_MACOSX) + bool is_kosk = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); +#else + bool is_kiosk = false; +#endif + if (!is_kosk) { + fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(), + browser_.get())); + } } else { #if defined(OS_WIN) // Show the edit again since we're no longer in fullscreen mode. @@ -916,6 +924,10 @@ bool BrowserView::IsFullscreen() const { return frame_->GetWindow()->IsFullscreen(); } +bool BrowserView::IsFullscreenBubbleVisible() const { + return fullscreen_bubble_.get() ? true : false; +} + LocationBar* BrowserView::GetLocationBar() const { return toolbar_->location_bar(); } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index d9baada..cf4ca78 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -204,6 +204,9 @@ class BrowserView : public BrowserWindow, // in the window caption area of the browser window. bool IsPositionInWindowCaption(const gfx::Point& point); + // Returns whether the fullscreen bubble is visible or not. + bool IsFullscreenBubbleVisible() const; + // Overridden from BrowserWindow: virtual void Show(); virtual void SetBounds(const gfx::Rect& bounds); |