From 39b6b787e7c4cbcecf1c9be40e9f47b76cd3c14b Mon Sep 17 00:00:00 2001 From: sriramsr Date: Tue, 3 Mar 2015 16:03:32 -0800 Subject: Refactor away the Browser* dependency in exclusive_access This change is needed to support the use of the exclusive access bubble from extensions. There are two scenarios under which the bubble will be used to: - Display the bubble when keyboard lock is in effect. - Display the fullscreen/mouse lock UI from Hosted app (not hooked up in this CL). Exclusive access controllers such as fullscreen and mouse lock are updated to no longer access Browser* object directly, but instead use new ExclusiveAccessContext and ExclusiveAccessBubbleViewsContext interfaces. These are implemented by BrowserView and will in the future be implemented by NativeAppWindow. Review URL: https://codereview.chromium.org/877413004 Cr-Commit-Position: refs/heads/master@{#318965} --- .../ui/browser_command_controller_unittest.cc | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'chrome/browser/ui/browser_command_controller_unittest.cc') diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc index 0242a0a..a80c758 100644 --- a/chrome/browser/ui/browser_command_controller_unittest.cc +++ b/chrome/browser/ui/browser_command_controller_unittest.cc @@ -14,6 +14,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_window_state.h" +#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/browser_with_test_window_test.h" @@ -267,11 +269,16 @@ TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { } ////////////////////////////////////////////////////////////////////////////// +class BrowserCommandControllerFullscreenTest; // A test browser window that can toggle fullscreen state. -class FullscreenTestBrowserWindow : public TestBrowserWindow { +class FullscreenTestBrowserWindow : public TestBrowserWindow, + ExclusiveAccessContext { public: - FullscreenTestBrowserWindow() : fullscreen_(false) {} + FullscreenTestBrowserWindow( + BrowserCommandControllerFullscreenTest* test_browser) + : fullscreen_(false), test_browser_(test_browser) {} + ~FullscreenTestBrowserWindow() override {} // TestBrowserWindow overrides: @@ -284,8 +291,21 @@ class FullscreenTestBrowserWindow : public TestBrowserWindow { } void ExitFullscreen() override { fullscreen_ = false; } + ExclusiveAccessContext* GetExclusiveAccessContext() override { return this; } + + // Exclusive access interface: + Profile* GetProfile() override; + content::WebContents* GetActiveWebContents() override; + void HideDownloadShelf() override {} + void UnhideDownloadShelf() override {} + void UpdateExclusiveAccessExitBubbleContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type) override {} + bool IsFullscreenWithToolbar() const override { return IsFullscreen(); } + private: bool fullscreen_; + BrowserCommandControllerFullscreenTest* test_browser_; DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); }; @@ -297,15 +317,25 @@ class BrowserCommandControllerFullscreenTest BrowserCommandControllerFullscreenTest() {} ~BrowserCommandControllerFullscreenTest() override {} + Browser* GetBrowser() { return BrowserWithTestWindowTest::browser(); } + // BrowserWithTestWindowTest overrides: BrowserWindow* CreateBrowserWindow() override { - return new FullscreenTestBrowserWindow; + return new FullscreenTestBrowserWindow(this); } private: DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerFullscreenTest); }; +Profile* FullscreenTestBrowserWindow::GetProfile() { + return test_browser_->GetBrowser()->profile(); +} + +content::WebContents* FullscreenTestBrowserWindow::GetActiveWebContents() { + return test_browser_->GetBrowser()->tab_strip_model()->GetActiveWebContents(); +} + TEST_F(BrowserCommandControllerFullscreenTest, UpdateCommandsForFullscreenMode) { // Defaults for a tabbed browser. -- cgit v1.1