summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_command_controller_unittest.cc
diff options
context:
space:
mode:
authorsriramsr <sriramsr@chromium.org>2015-03-03 16:03:32 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-04 00:05:07 +0000
commit39b6b787e7c4cbcecf1c9be40e9f47b76cd3c14b (patch)
treea4364f260f85533d6bd0bbee8bf06229bb14d4b1 /chrome/browser/ui/browser_command_controller_unittest.cc
parent59e9a996f54bb238beb5a51dd864eb0febb8728c (diff)
downloadchromium_src-39b6b787e7c4cbcecf1c9be40e9f47b76cd3c14b.zip
chromium_src-39b6b787e7c4cbcecf1c9be40e9f47b76cd3c14b.tar.gz
chromium_src-39b6b787e7c4cbcecf1c9be40e9f47b76cd3c14b.tar.bz2
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}
Diffstat (limited to 'chrome/browser/ui/browser_command_controller_unittest.cc')
-rw-r--r--chrome/browser/ui/browser_command_controller_unittest.cc36
1 files changed, 33 insertions, 3 deletions
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.