summaryrefslogtreecommitdiffstats
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
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}
-rw-r--r--chrome/browser/ui/browser.cc3
-rw-r--r--chrome/browser/ui/browser_command_controller_unittest.cc36
-rw-r--r--chrome/browser/ui/browser_window.h6
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h19
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm25
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm9
-rw-r--r--chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h18
-rw-r--r--chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm29
-rw-r--r--chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller_unittest.mm30
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc20
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_bubble.h10
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_context.cc33
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_context.h80
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc9
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h13
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_manager.cc18
-rw-r--r--chrome/browser/ui/exclusive_access/exclusive_access_manager.h10
-rw-r--r--chrome/browser/ui/exclusive_access/fullscreen_controller.cc110
-rw-r--r--chrome/browser/ui/exclusive_access/fullscreen_controller.h6
-rw-r--r--chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.cc3
-rw-r--r--chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc43
-rw-r--r--chrome/browser/ui/exclusive_access/mouse_lock_controller.cc18
-rw-r--r--chrome/browser/ui/exclusive_access/mouse_lock_controller.h2
-rw-r--r--chrome/browser/ui/views/exclusive_access_bubble_views.cc50
-rw-r--r--chrome/browser/ui/views/exclusive_access_bubble_views.h6
-rw-r--r--chrome/browser/ui/views/exclusive_access_bubble_views_context.h35
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc47
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h27
-rw-r--r--chrome/chrome_browser_ui.gypi3
-rw-r--r--chrome/test/base/test_browser_window.cc4
-rw-r--r--chrome/test/base/test_browser_window.h3
31 files changed, 536 insertions, 189 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 9a80747..28413b7 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -446,7 +446,8 @@ Browser::Browser(const CreateParams& params)
#endif // defined(OS_WIN)
}
- exclusive_access_manager_.reset(new ExclusiveAccessManager(this));
+ exclusive_access_manager_.reset(
+ new ExclusiveAccessManager(window_->GetExclusiveAccessContext()));
// Must be initialized after window_.
// Also: surprise! a modal dialog host is not necessary to host modal dialogs
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.
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 7f416fc..ea17ad5 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -22,6 +22,7 @@
class Browser;
class DownloadShelf;
+class ExclusiveAccessContext;
class FindBar;
class GlobalErrorBubbleViewBase;
class GURL;
@@ -131,7 +132,7 @@ class BrowserWindow : public ui::BaseWindow {
ExclusiveAccessBubbleType bubble_type,
bool with_toolbar) = 0;
virtual void ExitFullscreen() = 0;
- virtual void UpdateFullscreenExitBubbleContent(
+ virtual void UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) = 0;
@@ -395,6 +396,9 @@ class BrowserWindow : public ui::BaseWindow {
virtual void ExecuteExtensionCommand(const extensions::Extension* extension,
const extensions::Command& command) = 0;
+ // Returns object implementing ExclusiveAccessContext interface.
+ virtual ExclusiveAccessContext* GetExclusiveAccessContext() = 0;
+
protected:
friend class BrowserCloseManager;
friend class BrowserView;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index 018d88c..a1ae062 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -10,6 +10,7 @@
#include "chrome/browser/extensions/extension_keybinding_registry.h"
#include "chrome/browser/signin/signin_header_helper.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/search/search_model_observer.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "ui/base/ui_base_types.h"
@@ -31,10 +32,11 @@ class Extension;
// the Cocoa NSWindow. Cross-platform code will interact with this object when
// it needs to manipulate the window.
-class BrowserWindowCocoa :
- public BrowserWindow,
- public extensions::ExtensionKeybindingRegistry::Delegate,
- public SearchModelObserver {
+class BrowserWindowCocoa
+ : public BrowserWindow,
+ public ExclusiveAccessContext,
+ public extensions::ExtensionKeybindingRegistry::Delegate,
+ public SearchModelObserver {
public:
BrowserWindowCocoa(Browser* browser,
BrowserWindowController* controller);
@@ -78,7 +80,7 @@ class BrowserWindowCocoa :
ExclusiveAccessBubbleType type,
bool with_toolbar) override;
void ExitFullscreen() override;
- void UpdateFullscreenExitBubbleContent(
+ void UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) override;
bool ShouldHideUIForFullscreen() const override;
@@ -157,6 +159,13 @@ class BrowserWindowCocoa :
int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
void ExecuteExtensionCommand(const extensions::Extension* extension,
const extensions::Command& command) override;
+ ExclusiveAccessContext* GetExclusiveAccessContext() override;
+
+ // ExclusiveAccessContext interface
+ Profile* GetProfile() override;
+ content::WebContents* GetActiveWebContents() override;
+ void UnhideDownloadShelf() override;
+ void HideDownloadShelf() override;
// Overridden from ExtensionKeybindingRegistry::Delegate:
extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter()
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 96ea6f1..92fe33d 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -406,7 +406,7 @@ void BrowserWindowCocoa::ExitFullscreen() {
[controller_ exitAnyFullscreen];
}
-void BrowserWindowCocoa::UpdateFullscreenExitBubbleContent(
+void BrowserWindowCocoa::UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) {
[controller_ updateFullscreenExitBubbleURL:url bubbleType:bubble_type];
@@ -820,3 +820,26 @@ void BrowserWindowCocoa::ExecuteExtensionCommand(
const extensions::Command& command) {
[cocoa_controller() executeExtensionCommand:extension->id() command:command];
}
+
+ExclusiveAccessContext* BrowserWindowCocoa::GetExclusiveAccessContext() {
+ return this;
+}
+
+Profile* BrowserWindowCocoa::GetProfile() {
+ return browser_->profile();
+}
+
+WebContents* BrowserWindowCocoa::GetActiveWebContents() {
+ return browser_->tab_strip_model()->GetActiveWebContents();
+}
+
+void BrowserWindowCocoa::UnhideDownloadShelf() {
+ GetDownloadShelf()->Unhide();
+}
+
+void BrowserWindowCocoa::HideDownloadShelf() {
+ GetDownloadShelf()->Hide();
+ StatusBubble* statusBubble = GetStatusBubble();
+ if (statusBubble)
+ statusBubble->Hide();
+}
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index ba7f948..f3557a9 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -617,10 +617,11 @@ willPositionSheet:(NSWindow*)sheet
[exclusiveAccessBubbleWindowController_ closeImmediately];
exclusiveAccessBubbleWindowController_.reset(
[[ExclusiveAccessBubbleWindowController alloc]
- initWithOwner:self
- browser:browser_.get()
- url:fullscreenUrl_
- bubbleType:exclusiveAccessBubbleType_]);
+ initWithOwner:self
+ exclusive_access_manager:browser_.get()->exclusive_access_manager()
+ profile:browser_.get()->profile()
+ url:fullscreenUrl_
+ bubbleType:exclusiveAccessBubbleType_]);
[exclusiveAccessBubbleWindowController_ showWindow];
}
}
diff --git a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h
index d84330a..afb9706 100644
--- a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h
+++ b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h
@@ -8,8 +8,8 @@
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
#include "url/gurl.h"
-@class BrowserWindowController;
-class Browser;
+class ExclusiveAccessManager;
+class Profile;
@class GTMUILocalizerAndLayoutTweaker;
@class HyperlinkTextView;
@@ -20,8 +20,9 @@ class Browser;
@interface ExclusiveAccessBubbleWindowController
: NSWindowController<NSTextViewDelegate, NSAnimationDelegate> {
@private
- BrowserWindowController* owner_; // weak
- Browser* browser_; // weak
+ NSWindowController* owner_; // weak
+ ExclusiveAccessManager* exclusive_access_manager_; // weak
+ Profile* profile_; // weak
GURL url_;
ExclusiveAccessBubbleType bubbleType_;
@@ -43,10 +44,11 @@ class Browser;
};
// Initializes a new InfoBarController.
-- (id)initWithOwner:(BrowserWindowController*)owner
- browser:(Browser*)browser
- url:(const GURL&)url
- bubbleType:(ExclusiveAccessBubbleType)bubbleType;
+- (id)initWithOwner:(NSWindowController*)owner
+ exclusive_access_manager:(ExclusiveAccessManager*)exclusive_access_manager
+ profile:(Profile*)profile
+ url:(const GURL&)url
+ bubbleType:(ExclusiveAccessBubbleType)bubbleType;
- (void)allow:(id)sender;
- (void)deny:(id)sender;
diff --git a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm
index 06d8e85..eb5abc0 100644
--- a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm
+++ b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm
@@ -10,13 +10,13 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
-#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
+#import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/grit/generated_resources.h"
#include "extensions/browser/extension_registry.h"
@@ -65,15 +65,17 @@ const float kHideDuration = 0.7;
@implementation ExclusiveAccessBubbleWindowController
-- (id)initWithOwner:(BrowserWindowController*)owner
- browser:(Browser*)browser
- url:(const GURL&)url
- bubbleType:(ExclusiveAccessBubbleType)bubbleType {
+- (id)initWithOwner:(NSWindowController*)owner
+ exclusive_access_manager:(ExclusiveAccessManager*)exclusive_access_manager
+ profile:(Profile*)profile
+ url:(const GURL&)url
+ bubbleType:(ExclusiveAccessBubbleType)bubbleType {
NSString* nibPath =
[base::mac::FrameworkBundle() pathForResource:@"ExclusiveAccessBubble"
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibPath owner:self])) {
- browser_ = browser;
+ exclusive_access_manager_ = exclusive_access_manager;
+ profile_ = profile;
owner_ = owner;
url_ = url;
bubbleType_ = bubbleType;
@@ -97,12 +99,12 @@ const float kHideDuration = 0.7;
[[self window] setIgnoresMouseEvents:YES];
DCHECK(exclusive_access_bubble::ShowButtonsForType(bubbleType_));
- browser_->exclusive_access_manager()->OnAcceptExclusiveAccessPermission();
+ exclusive_access_manager_->OnAcceptExclusiveAccessPermission();
}
- (void)deny:(id)sender {
DCHECK(exclusive_access_bubble::ShowButtonsForType(bubbleType_));
- browser_->exclusive_access_manager()->OnDenyExclusiveAccessPermission();
+ exclusive_access_manager_->OnDenyExclusiveAccessPermission();
}
- (void)showButtons:(BOOL)show {
@@ -126,7 +128,9 @@ const float kHideDuration = 0.7;
}
[tweaker_ tweakUI:info_bubble];
[[owner_ window] addChildWindow:info_bubble ordered:NSWindowAbove];
- [owner_ layoutSubviews];
+
+ if ([owner_ respondsToSelector:@selector(layoutSubviews)])
+ [(id)owner_ layoutSubviews];
[info_bubble orderFront:self];
}
@@ -151,8 +155,7 @@ const float kHideDuration = 0.7;
- (BOOL)textView:(NSTextView*)textView
clickedOnLink:(id)link
atIndex:(NSUInteger)charIndex {
- browser_->exclusive_access_manager()
- ->fullscreen_controller()
+ exclusive_access_manager_->fullscreen_controller()
->ExitExclusiveAccessToPreviousState();
return YES;
}
@@ -281,7 +284,7 @@ const float kHideDuration = 0.7;
if (bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE)
return @"";
extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser_->profile());
+ extensions::ExtensionRegistry::Get(profile_);
return SysUTF16ToNSString(exclusive_access_bubble::GetLabelTextForType(
bubbleType_, url_, registry));
}
diff --git a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller_unittest.mm b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller_unittest.mm
index d860106..b352004 100644
--- a/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller_unittest.mm
@@ -61,11 +61,12 @@ class ExclusiveAccessBubbleWindowControllerTest : public CocoaProfileTest {
site_instance_ = SiteInstance::Create(profile());
controller_.reset([[ExclusiveAccessBubbleWindowController alloc]
- initWithOwner:nil
- browser:browser()
- url:GURL()
- bubbleType:
- EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION]);
+ initWithOwner:nil
+ exclusive_access_manager:browser()->exclusive_access_manager()
+ profile:browser()->profile()
+ url:GURL()
+ bubbleType:
+ EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION]);
EXPECT_TRUE([controller_ window]);
}
@@ -143,20 +144,23 @@ TEST_F(ExclusiveAccessBubbleWindowControllerTest, ShortcutText) {
// http://crbug.com/139944
TEST_F(ExclusiveAccessBubbleWindowControllerTest, DenyButtonText) {
controller_.reset([[ExclusiveAccessBubbleWindowController alloc]
- initWithOwner:nil
- browser:browser()
- url:GURL()
- bubbleType:EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS]);
+ initWithOwner:nil
+ exclusive_access_manager:browser()->exclusive_access_manager()
+ profile:browser()->profile()
+ url:GURL()
+ bubbleType:EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS]);
[controller_ initializeLabelAndButton];
NSString* mouselock_deny_button_text = [controller_ denyButtonText];
EXPECT_NSEQ(l10n_util::GetNSString(IDS_FULLSCREEN_DENY),
mouselock_deny_button_text);
controller_.reset([[ExclusiveAccessBubbleWindowController alloc]
- initWithOwner:nil
- browser:browser()
- url:GURL()
- bubbleType:EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS]);
+ initWithOwner:nil
+ exclusive_access_manager:browser()->exclusive_access_manager()
+ profile:browser()->profile()
+ url:GURL()
+ bubbleType:
+ EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS]);
[controller_ initializeLabelAndButton];
NSString* fullscreen_mouselock_deny_button_text =
[controller_ denyButtonText];
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc
index b960ce1..5d9f554 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc
@@ -7,8 +7,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/grit/generated_resources.h"
#include "extensions/browser/extension_registry.h"
@@ -32,10 +32,10 @@ const int ExclusiveAccessBubble::kSlideOutDurationMs = 700;
const int ExclusiveAccessBubble::kPopupTopPx = 15;
ExclusiveAccessBubble::ExclusiveAccessBubble(
- Browser* browser,
+ ExclusiveAccessManager* manager,
const GURL& url,
ExclusiveAccessBubbleType bubble_type)
- : browser_(browser), url_(url), bubble_type_(bubble_type) {
+ : manager_(manager), url_(url), bubble_type_(bubble_type) {
DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_);
}
@@ -114,24 +114,22 @@ void ExclusiveAccessBubble::CheckMousePosition() {
}
}
-void ExclusiveAccessBubble::ToggleFullscreen() {
- browser_->exclusive_access_manager()
- ->fullscreen_controller()
- ->ExitExclusiveAccessToPreviousState();
+void ExclusiveAccessBubble::ExitExclusiveAccess() {
+ manager_->ExitExclusiveAccess();
}
void ExclusiveAccessBubble::Accept() {
- browser_->exclusive_access_manager()->OnAcceptExclusiveAccessPermission();
+ manager_->OnAcceptExclusiveAccessPermission();
}
void ExclusiveAccessBubble::Cancel() {
- browser_->exclusive_access_manager()->OnDenyExclusiveAccessPermission();
+ manager_->OnDenyExclusiveAccessPermission();
}
base::string16 ExclusiveAccessBubble::GetCurrentMessageText() const {
return exclusive_access_bubble::GetLabelTextForType(
bubble_type_, url_,
- extensions::ExtensionRegistry::Get(browser_->profile()));
+ extensions::ExtensionRegistry::Get(manager_->context()->GetProfile()));
}
base::string16 ExclusiveAccessBubble::GetCurrentDenyButtonText() const {
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h
index d7654ab..57f55c0 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h
@@ -11,7 +11,7 @@
#include "ui/gfx/geometry/point.h"
#include "url/gurl.h"
-class Browser;
+class ExclusiveAccessManager;
namespace gfx {
class Rect;
@@ -22,7 +22,7 @@ class Rect;
// state, namely fullscreen and mouse lock.
class ExclusiveAccessBubble : public gfx::AnimationDelegate {
public:
- explicit ExclusiveAccessBubble(Browser* browser,
+ explicit ExclusiveAccessBubble(ExclusiveAccessManager* manager,
const GURL& url,
ExclusiveAccessBubbleType bubble_type);
~ExclusiveAccessBubble() override;
@@ -71,7 +71,7 @@ class ExclusiveAccessBubble : public gfx::AnimationDelegate {
// on or off the screen as appropriate.
void CheckMousePosition();
- void ToggleFullscreen();
+ void ExitExclusiveAccess();
// Accepts the request. Can cause FullscreenExitBubble to be deleted.
void Accept();
// Denys the request. Can cause FullscreenExitBubble to be deleted.
@@ -85,8 +85,8 @@ class ExclusiveAccessBubble : public gfx::AnimationDelegate {
// The following strings never change.
base::string16 GetInstructionText() const;
- // The browser this bubble is in.
- Browser* browser_;
+ // The Manager associated with this bubble.
+ ExclusiveAccessManager* const manager_;
// The host the bubble is for, can be empty.
GURL url_;
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_context.cc b/chrome/browser/ui/exclusive_access/exclusive_access_context.cc
new file mode 100644
index 0000000..f85582c
--- /dev/null
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_context.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2015 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/exclusive_access/exclusive_access_context.h"
+
+#include "base/logging.h"
+
+bool ExclusiveAccessContext::SupportsFullscreenWithToolbar() const {
+ return false;
+}
+
+void ExclusiveAccessContext::UpdateFullscreenWithToolbar(bool with_toolbar) {
+ NOTIMPLEMENTED();
+}
+
+#if defined(OS_WIN)
+void ExclusiveAccessContext::SetMetroSnapMode(bool enable) {
+ NOTIMPLEMENTED();
+}
+
+bool ExclusiveAccessContext::IsInMetroSnapMode() const {
+ return false;
+}
+#endif // defined(OS_WIN)
+
+void ExclusiveAccessContext::UnhideDownloadShelf() {
+ // NOOP implementation.
+}
+
+void ExclusiveAccessContext::HideDownloadShelf() {
+ // NOOP implementation.
+}
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_context.h b/chrome/browser/ui/exclusive_access/exclusive_access_context.h
new file mode 100644
index 0000000..36fc41b
--- /dev/null
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_context.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2015 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_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTEXT_H_
+#define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTEXT_H_
+
+#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
+
+class GURL;
+class Profile;
+
+namespace content {
+class WebContents;
+}
+
+// Context in which exclusive access operation is being performed. This
+// interface is implemented once in Browser context and in Platform Application
+// context.
+class ExclusiveAccessContext {
+ public:
+ virtual ~ExclusiveAccessContext() {}
+
+ // Returns the current profile associated with the window.
+ virtual Profile* GetProfile() = 0;
+
+ // Returns true if the window hosting the exclusive access bubble is
+ // fullscreen.
+ virtual bool IsFullscreen() const = 0;
+
+ // Returns true if fullscreen with toolbar is supported.
+ virtual bool SupportsFullscreenWithToolbar() const;
+
+ // Shows or hides the tab strip, toolbar and bookmark bar with in browser
+ // fullscreen.
+ // Currently only supported on Mac.
+ virtual void UpdateFullscreenWithToolbar(bool with_toolbar);
+
+ // Returns true if the window is fullscreen with additional UI elements. See
+ // EnterFullscreen |with_toolbar|.
+ virtual bool IsFullscreenWithToolbar() const = 0;
+
+ // Enters fullscreen and update exit bubble.
+ // On Mac, the tab strip and toolbar will be shown if |with_toolbar| is true,
+ // |with_toolbar| is ignored on other platforms.
+ virtual void EnterFullscreen(const GURL& url,
+ ExclusiveAccessBubbleType bubble_type,
+ bool with_toolbar) = 0;
+
+ // Exits fullscreen and update exit bubble.
+ virtual void ExitFullscreen() = 0;
+
+ // Updates the content of exclusive access exit bubble content.
+ virtual void UpdateExclusiveAccessExitBubbleContent(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type) = 0;
+
+#if defined(OS_WIN)
+ // Sets state for entering or exiting Win8 Metro snap mode.
+ virtual void SetMetroSnapMode(bool enable);
+
+ // Returns whether the window is currently in Win8 Metro snap mode.
+ virtual bool IsInMetroSnapMode() const;
+#endif // defined(OS_WIN)
+
+ // Returns the currently active WebContents, or nullptr if there is none.
+ virtual content::WebContents* GetActiveWebContents() = 0;
+
+ // TODO(sriramsr): This is abstraction violation as the following two function
+ // does not apply to a platform app window. Ideally, the BrowserView should
+ // hide/unhide its download shelf widget when it is instructed to enter/exit
+ // fullscreen mode.
+ // Displays the download shelf associated with currently active window.
+ virtual void UnhideDownloadShelf();
+
+ // Hides download shelf associated with currently active window.
+ virtual void HideDownloadShelf();
+};
+
+#endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTEXT_H_
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc
index db8a243..bbc7545 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc
@@ -16,13 +16,8 @@
using content::WebContents;
ExclusiveAccessControllerBase::ExclusiveAccessControllerBase(
- ExclusiveAccessManager* manager,
- Browser* browser)
- : manager_(manager),
- browser_(browser),
- profile_(browser->profile()),
- tab_with_exclusive_access_(nullptr) {
- DCHECK(profile_);
+ ExclusiveAccessManager* manager)
+ : manager_(manager), tab_with_exclusive_access_(nullptr) {
}
ExclusiveAccessControllerBase::~ExclusiveAccessControllerBase() {
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h
index 99c5614..1d127c4 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h
@@ -6,13 +6,11 @@
#define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_
#include "base/basictypes.h"
-#include "base/memory/weak_ptr.h"
+#include "base/memory/ref_counted.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-class Browser;
-class BrowserWindow;
class ExclusiveAccessManager;
class GURL;
class Profile;
@@ -26,8 +24,7 @@ class WebContents;
// which the resource (screen/mouse) is held exclusively.
class ExclusiveAccessControllerBase : public content::NotificationObserver {
public:
- explicit ExclusiveAccessControllerBase(ExclusiveAccessManager* manager,
- Browser* browser);
+ explicit ExclusiveAccessControllerBase(ExclusiveAccessManager* manager);
~ExclusiveAccessControllerBase() override;
GURL GetExclusiveAccessBubbleURL() const;
@@ -73,10 +70,6 @@ class ExclusiveAccessControllerBase : public content::NotificationObserver {
ExclusiveAccessManager* exclusive_access_manager() const { return manager_; }
- Browser* browser() const { return browser_; }
-
- Profile* profile() const { return profile_; }
-
// Exits exclusive access mode for the tab if currently exclusive.
virtual void ExitExclusiveAccessIfNecessary() = 0;
@@ -88,8 +81,6 @@ class ExclusiveAccessControllerBase : public content::NotificationObserver {
void UpdateNotificationRegistrations();
ExclusiveAccessManager* const manager_;
- Browser* const browser_;
- Profile* const profile_;
content::NotificationRegistrar registrar_;
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
index 56a8cc6..e252a39 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
@@ -7,15 +7,17 @@
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
using content::WebContents;
-ExclusiveAccessManager::ExclusiveAccessManager(Browser* browser)
- : browser_(browser),
- fullscreen_controller_(this, browser),
- mouse_lock_controller_(this, browser) {
+ExclusiveAccessManager::ExclusiveAccessManager(
+ ExclusiveAccessContext* exclusive_access_context)
+ : exclusive_access_context_(exclusive_access_context),
+ fullscreen_controller_(this),
+ mouse_lock_controller_(this) {
}
ExclusiveAccessManager::~ExclusiveAccessManager() {
@@ -71,7 +73,8 @@ void ExclusiveAccessManager::UpdateExclusiveAccessExitBubbleContent() {
mouse_lock_controller_.IsMouseLocked())
mouse_lock_controller_.UnlockMouse();
- browser_->window()->UpdateFullscreenExitBubbleContent(url, bubble_type);
+ exclusive_access_context_->UpdateExclusiveAccessExitBubbleContent(
+ url, bubble_type);
}
GURL ExclusiveAccessManager::GetExclusiveAccessBubbleURL() const {
@@ -117,3 +120,8 @@ void ExclusiveAccessManager::OnDenyExclusiveAccessPermission() {
if (updateBubble)
UpdateExclusiveAccessExitBubbleContent();
}
+
+void ExclusiveAccessManager::ExitExclusiveAccess() {
+ fullscreen_controller_.ExitExclusiveAccessToPreviousState();
+ mouse_lock_controller_.LostMouseLock();
+}
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_manager.h b/chrome/browser/ui/exclusive_access/exclusive_access_manager.h
index 0c10fe5..539958c 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_manager.h
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_manager.h
@@ -10,7 +10,7 @@
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
-class Browser;
+class ExclusiveAccessContext;
class FullscreenController;
class GURL;
class MouseLockController;
@@ -24,7 +24,8 @@ class WebContents;
// the exit bubble to reflect the combined state.
class ExclusiveAccessManager {
public:
- explicit ExclusiveAccessManager(Browser* browser);
+ explicit ExclusiveAccessManager(
+ ExclusiveAccessContext* exclusive_access_context);
~ExclusiveAccessManager();
FullscreenController* fullscreen_controller() {
@@ -35,6 +36,8 @@ class ExclusiveAccessManager {
return &mouse_lock_controller_;
}
+ ExclusiveAccessContext* context() const { return exclusive_access_context_; }
+
ExclusiveAccessBubbleType GetExclusiveAccessExitBubbleType() const;
void UpdateExclusiveAccessExitBubbleContent();
@@ -57,9 +60,10 @@ class ExclusiveAccessManager {
// Called by platform ExclusiveAccessExitBubble.
void OnAcceptExclusiveAccessPermission();
void OnDenyExclusiveAccessPermission();
+ void ExitExclusiveAccess();
private:
- Browser* const browser_;
+ ExclusiveAccessContext* const exclusive_access_context_;
FullscreenController fullscreen_controller_;
MouseLockController mouse_lock_controller_;
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
index 0209cfc..8f0f7fc 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
@@ -9,10 +9,9 @@
#include "base/message_loop/message_loop.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h"
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -37,9 +36,8 @@ using base::UserMetricsAction;
using content::RenderViewHost;
using content::WebContents;
-FullscreenController::FullscreenController(ExclusiveAccessManager* manager,
- Browser* browser)
- : ExclusiveAccessControllerBase(manager, browser),
+FullscreenController::FullscreenController(ExclusiveAccessManager* manager)
+ : ExclusiveAccessControllerBase(manager),
state_prior_to_tab_fullscreen_(STATE_INVALID),
tab_fullscreen_accepted_(false),
toggled_into_fullscreen_(false),
@@ -52,7 +50,8 @@ FullscreenController::~FullscreenController() {
}
bool FullscreenController::IsFullscreenForBrowser() const {
- return browser()->window()->IsFullscreen() && !IsFullscreenCausedByTab();
+ return exclusive_access_manager()->context()->IsFullscreen() &&
+ !IsFullscreenCausedByTab();
}
void FullscreenController::ToggleBrowserFullscreenMode() {
@@ -92,7 +91,7 @@ bool FullscreenController::IsFullscreenForTabOrPending(
const WebContents* web_contents) const {
if (web_contents == exclusive_access_tab()) {
DCHECK(web_contents ==
- browser()->tab_strip_model()->GetActiveWebContents());
+ exclusive_access_manager()->context()->GetActiveWebContents());
DCHECK(web_contents->GetCapturerCount() == 0);
return true;
}
@@ -113,7 +112,8 @@ void FullscreenController::EnterFullscreenModeForTab(WebContents* web_contents,
return;
}
- if (web_contents != browser()->tab_strip_model()->GetActiveWebContents() ||
+ if (web_contents !=
+ exclusive_access_manager()->context()->GetActiveWebContents() ||
IsWindowFullscreenForTabOrPending()) {
return;
}
@@ -130,18 +130,19 @@ void FullscreenController::EnterFullscreenModeForTab(WebContents* web_contents,
SetTabWithExclusiveAccess(web_contents);
fullscreened_origin_ = origin;
- BrowserWindow* window = browser()->window();
+ ExclusiveAccessContext* exclusive_access_context =
+ exclusive_access_manager()->context();
- if (!window->IsFullscreen()) {
+ if (!exclusive_access_context->IsFullscreen()) {
// Normal -> Tab Fullscreen.
state_prior_to_tab_fullscreen_ = STATE_NORMAL;
ToggleFullscreenModeInternal(TAB);
return;
}
- if (window->IsFullscreenWithToolbar()) {
+ if (exclusive_access_context->IsFullscreenWithToolbar()) {
// Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar).
- window->UpdateFullscreenWithToolbar(false);
+ exclusive_access_context->UpdateFullscreenWithToolbar(false);
state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR;
} else {
// Browser Fullscreen without Toolbar -> Tab Fullscreen.
@@ -181,8 +182,10 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
return;
#endif
- BrowserWindow* window = browser()->window();
- if (!window->IsFullscreen())
+ ExclusiveAccessContext* exclusive_access_context =
+ exclusive_access_manager()->context();
+
+ if (!exclusive_access_context->IsFullscreen())
return;
if (IsFullscreenCausedByTab()) {
@@ -194,7 +197,7 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
// Tab Fullscreen -> Browser Fullscreen (with or without toolbar).
if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) {
// Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar.
- window->UpdateFullscreenWithToolbar(true);
+ exclusive_access_context->UpdateFullscreenWithToolbar(true);
}
#if defined(OS_MACOSX)
@@ -214,20 +217,16 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
PostFullscreenChangeNotification(true);
}
-bool FullscreenController::IsInMetroSnapMode() {
#if defined(OS_WIN)
- return browser()->window()->IsInMetroSnapMode();
-#else
- return false;
-#endif
+bool FullscreenController::IsInMetroSnapMode() {
+ return exclusive_access_manager()->context()->IsInMetroSnapMode();
}
-#if defined(OS_WIN)
void FullscreenController::SetMetroSnapMode(bool enable) {
reentrant_window_state_change_call_check_ = false;
toggled_into_fullscreen_ = false;
- browser()->window()->SetMetroSnapMode(enable);
+ exclusive_access_manager()->context()->SetMetroSnapMode(enable);
// FullscreenController unit tests for metro snap assume that on Windows calls
// to WindowFullscreenStateChanged are reentrant. If that assumption is
@@ -278,28 +277,24 @@ void FullscreenController::OnTabClosing(WebContents* web_contents) {
void FullscreenController::WindowFullscreenStateChanged() {
reentrant_window_state_change_call_check_ = true;
-
- BrowserWindow* const window = browser()->window();
- bool exiting_fullscreen = !window->IsFullscreen();
+ ExclusiveAccessContext* const exclusive_access_context =
+ exclusive_access_manager()->context();
+ bool exiting_fullscreen = !exclusive_access_context->IsFullscreen();
PostFullscreenChangeNotification(!exiting_fullscreen);
if (exiting_fullscreen) {
toggled_into_fullscreen_ = false;
extension_caused_fullscreen_ = GURL();
NotifyTabExclusiveAccessLost();
- }
- if (exiting_fullscreen) {
- window->GetDownloadShelf()->Unhide();
+ exclusive_access_context->UnhideDownloadShelf();
} else {
- window->GetDownloadShelf()->Hide();
- if (window->GetStatusBubble())
- window->GetStatusBubble()->Hide();
+ exclusive_access_context->HideDownloadShelf();
}
}
bool FullscreenController::HandleUserPressedEscape() {
WebContents* const active_web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
+ exclusive_access_manager()->context()->GetActiveWebContents();
if (IsFullscreenForCapturedTab(active_web_contents)) {
active_web_contents->ExitFullscreen();
return true;
@@ -355,8 +350,10 @@ bool FullscreenController::OnAcceptExclusiveAccessPermission() {
// TODO(estark): Revisit this when crbug.com/455882 is fixed.
if (!requester.SchemeIsFile() && !embedder.SchemeIsFile() &&
primary_pattern.IsValid() && secondary_pattern.IsValid()) {
- HostContentSettingsMap* settings_map =
- profile()->GetHostContentSettingsMap();
+ HostContentSettingsMap* settings_map = exclusive_access_manager()
+ ->context()
+ ->GetProfile()
+ ->GetHostContentSettingsMap();
settings_map->SetContentSetting(
primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_FULLSCREEN,
std::string(), CONTENT_SETTING_ALLOW);
@@ -426,23 +423,27 @@ void FullscreenController::ToggleFullscreenModeInternal(
return;
#endif
- BrowserWindow* const window = browser()->window();
- bool enter_fullscreen = !window->IsFullscreen();
+ ExclusiveAccessContext* const exclusive_access_context =
+ exclusive_access_manager()->context();
+ bool enter_fullscreen = !exclusive_access_context->IsFullscreen();
// When a Mac user requests a toggle they may be toggling between
// FullscreenWithoutChrome and FullscreenWithToolbar.
- if (window->IsFullscreen() && !IsWindowFullscreenForTabOrPending() &&
- window->SupportsFullscreenWithToolbar()) {
+ if (exclusive_access_context->IsFullscreen() &&
+ !IsWindowFullscreenForTabOrPending() &&
+ exclusive_access_context->SupportsFullscreenWithToolbar()) {
if (option == BROWSER_WITH_TOOLBAR) {
- enter_fullscreen = enter_fullscreen || !window->IsFullscreenWithToolbar();
+ enter_fullscreen = enter_fullscreen ||
+ !exclusive_access_context->IsFullscreenWithToolbar();
} else {
- enter_fullscreen = enter_fullscreen || window->IsFullscreenWithToolbar();
+ enter_fullscreen = enter_fullscreen ||
+ exclusive_access_context->IsFullscreenWithToolbar();
}
}
// 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 (chrome::IsRunningInAppMode() && window->IsFullscreen())
+ if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen())
return;
#if !defined(OS_MACOSX)
@@ -450,7 +451,8 @@ void FullscreenController::ToggleFullscreenModeInternal(
// from manually entering fullscreen mode and also disables kiosk mode on
// desktop platforms.
if (enter_fullscreen &&
- !profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) {
+ !exclusive_access_context->GetProfile()->GetPrefs()->GetBoolean(
+ prefs::kFullscreenAllowed)) {
return;
}
#endif
@@ -478,7 +480,7 @@ void FullscreenController::EnterFullscreenModeInternal(
// TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions
// from tab fullscreen out to browser with toolbar.
- browser()->window()->EnterFullscreen(
+ exclusive_access_manager()->context()->EnterFullscreen(
url, exclusive_access_manager()->GetExclusiveAccessExitBubbleType(),
option == BROWSER_WITH_TOOLBAR);
@@ -498,7 +500,7 @@ void FullscreenController::ExitFullscreenModeInternal() {
// state_prior_to_tab_fullscreen_ will be incorrect.
NotifyTabExclusiveAccessLost();
#endif
- browser()->window()->ExitFullscreen();
+ exclusive_access_manager()->context()->ExitFullscreen();
extension_caused_fullscreen_ = GURL();
exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
@@ -520,17 +522,23 @@ ContentSetting FullscreenController::GetFullscreenSetting() const {
// If the permission was granted to the website with no embedder, it should
// always be allowed, even if embedded.
- if (profile()->GetHostContentSettingsMap()->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()) ==
- CONTENT_SETTING_ALLOW) {
+ if (exclusive_access_manager()
+ ->context()
+ ->GetProfile()
+ ->GetHostContentSettingsMap()
+ ->GetContentSetting(url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN,
+ std::string()) == CONTENT_SETTING_ALLOW) {
return CONTENT_SETTING_ALLOW;
}
// See the comment above the call to |SetContentSetting()| for how the
// requesting and embedding origins interact with each other wrt permissions.
- return profile()->GetHostContentSettingsMap()->GetContentSetting(
- url, GetEmbeddingOrigin(), CONTENT_SETTINGS_TYPE_FULLSCREEN,
- std::string());
+ return exclusive_access_manager()
+ ->context()
+ ->GetProfile()
+ ->GetHostContentSettingsMap()
+ ->GetContentSetting(url, GetEmbeddingOrigin(),
+ CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
}
bool FullscreenController::IsPrivilegedFullscreenForTab() const {
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.h b/chrome/browser/ui/exclusive_access/fullscreen_controller.h
index 763591f..64202e3 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.h
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.h
@@ -49,7 +49,7 @@ class WebContents;
// This class implements fullscreen behaviour.
class FullscreenController : public ExclusiveAccessControllerBase {
public:
- FullscreenController(ExclusiveAccessManager* manager, Browser* browser);
+ explicit FullscreenController(ExclusiveAccessManager* manager);
~FullscreenController() override;
// Browser/User Fullscreen ///////////////////////////////////////////////////
@@ -116,14 +116,14 @@ class FullscreenController : public ExclusiveAccessControllerBase {
// Platform Fullscreen ///////////////////////////////////////////////////////
+#if defined(OS_WIN)
// Returns whether we are currently in a Metro snap view.
bool IsInMetroSnapMode();
-#if defined(OS_WIN)
// API that puts the window into a mode suitable for rendering when Chrome
// is rendered in a 20% screen-width Metro snap view on Windows 8.
void SetMetroSnapMode(bool enable);
-#endif
+#endif // OS_WIN
// Overrde from ExclusiveAccessControllerBase.
void OnTabDetachedFromView(content::WebContents* web_contents) override;
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.cc
index 0a6fbc5..a8af8b3 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.cc
@@ -753,10 +753,13 @@ void FullscreenControllerStateTest::VerifyWindowStateExpectations(
EXPECT_EQ(GetFullscreenController()->IsWindowFullscreenForTabOrPending(),
!!fullscreen_for_tab) << GetAndClearDebugLog();
}
+
+#if defined(OS_WIN)
if (in_metro_snap != IN_METRO_SNAP_NO_EXPECTATION) {
EXPECT_EQ(GetFullscreenController()->IsInMetroSnapMode(),
!!in_metro_snap) << GetAndClearDebugLog();
}
+#endif // OS_WIN
}
FullscreenController* FullscreenControllerStateTest::GetFullscreenController() {
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc
index 31ef252..28e7c27 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc
@@ -6,6 +6,7 @@
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -23,7 +24,8 @@
// A BrowserWindow used for testing FullscreenController. The behavior of this
// mock is verfied manually by running FullscreenControllerStateInteractiveTest.
-class FullscreenControllerTestWindow : public TestBrowserWindow {
+class FullscreenControllerTestWindow : public TestBrowserWindow,
+ ExclusiveAccessContext {
public:
// Simulate the window state with an enumeration.
enum WindowState {
@@ -55,6 +57,16 @@ class FullscreenControllerTestWindow : public TestBrowserWindow {
static const char* GetWindowStateString(WindowState state);
WindowState state() const { return state_; }
void set_browser(Browser* browser) { browser_ = browser; }
+ ExclusiveAccessContext* GetExclusiveAccessContext() override;
+
+ // ExclusiveAccessContext Interface:
+ Profile* GetProfile() override;
+ content::WebContents* GetActiveWebContents() override;
+ void HideDownloadShelf() override;
+ void UnhideDownloadShelf() override;
+ void UpdateExclusiveAccessExitBubbleContent(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type) override;
// Simulates the window changing state.
void ChangeWindowFullscreenState();
@@ -205,6 +217,32 @@ bool FullscreenControllerTestWindow::IsTransitionReentrant(
mac_with_toolbar_mode_changed;
}
+ExclusiveAccessContext*
+FullscreenControllerTestWindow::GetExclusiveAccessContext() {
+ return this;
+}
+
+Profile* FullscreenControllerTestWindow::GetProfile() {
+ return browser_->profile();
+}
+
+content::WebContents* FullscreenControllerTestWindow::GetActiveWebContents() {
+ return browser_->tab_strip_model()->GetActiveWebContents();
+}
+
+void FullscreenControllerTestWindow::UnhideDownloadShelf() {
+ GetDownloadShelf()->Unhide();
+}
+
+void FullscreenControllerTestWindow::HideDownloadShelf() {
+ GetDownloadShelf()->Hide();
+}
+
+void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type) {
+ TestBrowserWindow::UpdateExclusiveAccessExitBubbleContent(url, bubble_type);
+}
// FullscreenControllerStateUnitTest -------------------------------------------
@@ -229,7 +267,7 @@ class FullscreenControllerStateUnitTest : public BrowserWithTestWindowTest,
FullscreenControllerTestWindow* window_;
};
-FullscreenControllerStateUnitTest::FullscreenControllerStateUnitTest ()
+FullscreenControllerStateUnitTest::FullscreenControllerStateUnitTest()
: window_(NULL) {
}
@@ -316,7 +354,6 @@ Browser* FullscreenControllerStateUnitTest::GetBrowser() {
return BrowserWithTestWindowTest::browser();
}
-
// Soak tests ------------------------------------------------------------------
// Tests all states with all permutations of multiple events to detect lingering
diff --git a/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc b/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc
index 01a986b..8e3afb9 100644
--- a/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc
+++ b/chrome/browser/ui/exclusive_access/mouse_lock_controller.cc
@@ -7,6 +7,8 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/notification_service.h"
@@ -17,9 +19,8 @@
using content::RenderViewHost;
using content::WebContents;
-MouseLockController::MouseLockController(ExclusiveAccessManager* manager,
- Browser* browser)
- : ExclusiveAccessControllerBase(manager, browser),
+MouseLockController::MouseLockController(ExclusiveAccessManager* manager)
+ : ExclusiveAccessControllerBase(manager),
mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) {
}
@@ -136,8 +137,10 @@ bool MouseLockController::OnAcceptExclusiveAccessPermission() {
if (mouse_lock && !IsMouseLocked()) {
DCHECK(IsMouseLockRequested());
- HostContentSettingsMap* settings_map =
- profile()->GetHostContentSettingsMap();
+ HostContentSettingsMap* settings_map = exclusive_access_manager()
+ ->context()
+ ->GetProfile()
+ ->GetHostContentSettingsMap();
GURL url = GetExclusiveAccessBubbleURL();
ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url);
@@ -237,7 +240,10 @@ ContentSetting MouseLockController::GetMouseLockSetting(const GURL& url) const {
->IsPrivilegedFullscreenForTab())
return CONTENT_SETTING_ALLOW;
- HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
+ HostContentSettingsMap* settings_map = exclusive_access_manager()
+ ->context()
+ ->GetProfile()
+ ->GetHostContentSettingsMap();
return settings_map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string());
}
diff --git a/chrome/browser/ui/exclusive_access/mouse_lock_controller.h b/chrome/browser/ui/exclusive_access/mouse_lock_controller.h
index 27cede2..43c89f2 100644
--- a/chrome/browser/ui/exclusive_access/mouse_lock_controller.h
+++ b/chrome/browser/ui/exclusive_access/mouse_lock_controller.h
@@ -11,7 +11,7 @@
// This class implements mouselock behavior.
class MouseLockController : public ExclusiveAccessControllerBase {
public:
- MouseLockController(ExclusiveAccessManager* manager, Browser* browser);
+ explicit MouseLockController(ExclusiveAccessManager* manager);
~MouseLockController() override;
bool IsMouseLocked() const;
diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/chrome/browser/ui/views/exclusive_access_bubble_views.cc
index 88035ff..0a0e4d8 100644
--- a/chrome/browser/ui/views/exclusive_access_bubble_views.cc
+++ b/chrome/browser/ui/views/exclusive_access_bubble_views.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/grit/generated_resources.h"
@@ -57,7 +57,6 @@ class ButtonView : public views::View {
private:
views::LabelButton* accept_button_;
views::LabelButton* deny_button_;
-
DISALLOW_COPY_AND_ASSIGN(ButtonView);
};
@@ -208,7 +207,7 @@ void ExclusiveAccessBubbleViews::ExclusiveAccessView::ButtonPressed(
void ExclusiveAccessBubbleViews::ExclusiveAccessView::LinkClicked(
views::Link* link,
int event_flags) {
- bubble_->ToggleFullscreen();
+ bubble_->ExitExclusiveAccess();
}
void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent(
@@ -257,11 +256,13 @@ void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent(
// ExclusiveAccessBubbleViews --------------------------------------------------
ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
- BrowserView* browser_view,
+ ExclusiveAccessBubbleViewsContext* context,
const GURL& url,
ExclusiveAccessBubbleType bubble_type)
- : ExclusiveAccessBubble(browser_view->browser(), url, bubble_type),
- browser_view_(browser_view),
+ : ExclusiveAccessBubble(context->GetExclusiveAccessManager(),
+ url,
+ bubble_type),
+ bubble_view_context_(context),
popup_(NULL),
animation_(new gfx::SlideAnimation(this)),
animated_attribute_(ANIMATED_ATTRIBUTE_BOUNDS) {
@@ -270,7 +271,8 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
// Create the contents view.
ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE);
bool got_accelerator =
- browser_view_->GetWidget()->GetAccelerator(IDC_FULLSCREEN, &accelerator);
+ bubble_view_context_->GetBubbleAssociatedWidget()->GetAccelerator(
+ IDC_FULLSCREEN, &accelerator);
DCHECK(got_accelerator);
view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(), url,
bubble_type_);
@@ -283,7 +285,8 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.parent = browser_view_->GetWidget()->GetNativeView();
+ params.parent =
+ bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView();
params.bounds = GetPopupRect(false);
popup_->Init(params);
gfx::Size size = GetPopupRect(true).size();
@@ -298,11 +301,10 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
popup_->AddObserver(this);
- registrar_.Add(
- this, chrome::NOTIFICATION_FULLSCREEN_CHANGED,
- content::Source<FullscreenController>(browser_view_->browser()
- ->exclusive_access_manager()
- ->fullscreen_controller()));
+ registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::Source<FullscreenController>(
+ bubble_view_context_->GetExclusiveAccessManager()
+ ->fullscreen_controller()));
UpdateForImmersiveState();
}
@@ -371,7 +373,7 @@ void ExclusiveAccessBubbleViews::UpdateMouseWatcher() {
void ExclusiveAccessBubbleViews::UpdateForImmersiveState() {
AnimatedAttribute expected_animated_attribute =
- browser_view_->immersive_mode_controller()->IsEnabled()
+ bubble_view_context_->IsImmersiveModeEnabled()
? ANIMATED_ATTRIBUTE_OPACITY
: ANIMATED_ATTRIBUTE_BOUNDS;
if (animated_attribute_ != expected_animated_attribute) {
@@ -403,7 +405,7 @@ void ExclusiveAccessBubbleViews::UpdateBounds() {
}
views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const {
- return browser_view_->GetWidget()->GetRootView();
+ return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView();
}
void ExclusiveAccessBubbleViews::AnimationProgressed(
@@ -436,15 +438,16 @@ gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect(
gfx::Size size(view_->GetPreferredSize());
// NOTE: don't use the bounds of the root_view_. On linux GTK changing window
// size is async. Instead we use the size of the screen.
- gfx::Screen* screen =
- gfx::Screen::GetScreenFor(browser_view_->GetWidget()->GetNativeView());
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(
+ bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView());
gfx::Rect screen_bounds =
screen->GetDisplayNearestWindow(
- browser_view_->GetWidget()->GetNativeView()).bounds();
+ bubble_view_context_->GetBubbleAssociatedWidget()
+ ->GetNativeView()).bounds();
int x = screen_bounds.x() + (screen_bounds.width() - size.width()) / 2;
int top_container_bottom = screen_bounds.y();
- if (browser_view_->immersive_mode_controller()->IsEnabled()) {
+ if (bubble_view_context_->IsImmersiveModeEnabled()) {
// Skip querying the top container height in non-immersive fullscreen
// because:
// - The top container height is always zero in non-immersive fullscreen.
@@ -455,7 +458,7 @@ gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect(
// revealed. When revealed, the top container has the same height as before
// entering fullscreen.
top_container_bottom =
- browser_view_->top_container()->GetBoundsInScreen().bottom();
+ bubble_view_context_->GetTopContainerBoundsInScreen().bottom();
}
int y = top_container_bottom + kPopupTopPx;
@@ -472,7 +475,8 @@ gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect(
gfx::Point ExclusiveAccessBubbleViews::GetCursorScreenPoint() {
gfx::Point cursor_pos =
- gfx::Screen::GetScreenFor(browser_view_->GetWidget()->GetNativeView())
+ gfx::Screen::GetScreenFor(
+ bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView())
->GetCursorScreenPoint();
views::View::ConvertPointFromScreen(GetBrowserRootView(), &cursor_pos);
return cursor_pos;
@@ -483,7 +487,7 @@ bool ExclusiveAccessBubbleViews::WindowContainsPoint(gfx::Point pos) {
}
bool ExclusiveAccessBubbleViews::IsWindowActive() {
- return browser_view_->GetWidget()->IsActive();
+ return bubble_view_context_->GetBubbleAssociatedWidget()->IsActive();
}
void ExclusiveAccessBubbleViews::Hide() {
@@ -501,7 +505,7 @@ bool ExclusiveAccessBubbleViews::IsAnimating() {
}
bool ExclusiveAccessBubbleViews::CanMouseTriggerSlideIn() const {
- return !browser_view_->immersive_mode_controller()->IsEnabled();
+ return !bubble_view_context_->IsImmersiveModeEnabled();
}
void ExclusiveAccessBubbleViews::Observe(
diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.h b/chrome/browser/ui/views/exclusive_access_bubble_views.h
index 5b187bd..9014616 100644
--- a/chrome/browser/ui/views/exclusive_access_bubble_views.h
+++ b/chrome/browser/ui/views/exclusive_access_bubble_views.h
@@ -12,7 +12,7 @@
#include "content/public/browser/notification_registrar.h"
#include "ui/views/widget/widget_observer.h"
-class BrowserView;
+class ExclusiveAccessBubbleViewsContext;
class GURL;
namespace gfx {
class SlideAnimation;
@@ -30,7 +30,7 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble,
public content::NotificationObserver,
public views::WidgetObserver {
public:
- ExclusiveAccessBubbleViews(BrowserView* browser,
+ ExclusiveAccessBubbleViews(ExclusiveAccessBubbleViewsContext* context,
const GURL& url,
ExclusiveAccessBubbleType bubble_type);
~ExclusiveAccessBubbleViews() override;
@@ -82,7 +82,7 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble,
// views::WidgetObserver override:
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
- BrowserView* browser_view_;
+ ExclusiveAccessBubbleViewsContext* const bubble_view_context_;
views::Widget* popup_;
diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views_context.h b/chrome/browser/ui/views/exclusive_access_bubble_views_context.h
new file mode 100644
index 0000000..5d0f3d4
--- /dev/null
+++ b/chrome/browser/ui/views/exclusive_access_bubble_views_context.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2015 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_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_CONTEXT_H_
+#define CHROME_BROWSER_UI_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_CONTEXT_H_
+
+#include "ui/gfx/geometry/rect.h"
+
+class ExclusiveAccessManager;
+
+namespace views {
+class Widget;
+}
+
+// Context in which the exclusive access bubble view is initiated.
+class ExclusiveAccessBubbleViewsContext {
+ public:
+ virtual ~ExclusiveAccessBubbleViewsContext() {}
+
+ // Returns ExclusiveAccessManager controlling exclusive access for the given
+ // webview.
+ virtual ExclusiveAccessManager* GetExclusiveAccessManager() = 0;
+
+ // Returns the Widget that hosts the view containing the exclusive access
+ // bubble.
+ virtual views::Widget* GetBubbleAssociatedWidget() = 0;
+
+ // Returns true if immersive mode is enabled.
+ virtual bool IsImmersiveModeEnabled() = 0;
+
+ // Returns the bounds of the top level View in screen coordinate system.
+ virtual gfx::Rect GetTopContainerBoundsInScreen() = 0;
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_CONTEXT_H_
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 33ee5a1..b86f397 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -946,7 +946,7 @@ void BrowserView::ExitFullscreen() {
EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE);
}
-void BrowserView::UpdateFullscreenExitBubbleContent(
+void BrowserView::UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) {
// Immersive mode has no exit bubble because it has a visible strip at the
@@ -2280,7 +2280,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
if (fullscreen && !chrome::IsRunningInAppMode() &&
mode != METRO_SNAP_FULLSCREEN) {
- UpdateFullscreenExitBubbleContent(url, bubble_type);
+ UpdateExclusiveAccessExitBubbleContent(url, bubble_type);
}
// Undo our anti-jankiness hacks and force a re-layout. We also need to
@@ -2502,6 +2502,10 @@ void BrowserView::ExecuteExtensionCommand(
toolbar_->ExecuteExtensionCommand(extension, command);
}
+ExclusiveAccessContext* BrowserView::GetExclusiveAccessContext() {
+ return this;
+}
+
void BrowserView::DoCutCopyPaste(void (WebContents::*method)(),
int command_id) {
WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
@@ -2568,3 +2572,42 @@ int BrowserView::GetMaxTopInfoBarArrowHeight() {
}
return top_arrow_height;
}
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserView, ExclusiveAccessContext overrides
+Profile* BrowserView::GetProfile() {
+ return browser_->profile();
+}
+
+WebContents* BrowserView::GetActiveWebContents() {
+ return browser_->tab_strip_model()->GetActiveWebContents();
+}
+
+void BrowserView::UnhideDownloadShelf() {
+ GetDownloadShelf()->Unhide();
+}
+
+void BrowserView::HideDownloadShelf() {
+ GetDownloadShelf()->Hide();
+ StatusBubble* statusBubble = GetStatusBubble();
+ if (statusBubble)
+ statusBubble->Hide();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserView, ExclusiveAccessBubbleViewsContext overrides
+ExclusiveAccessManager* BrowserView::GetExclusiveAccessManager() {
+ return browser_->exclusive_access_manager();
+}
+
+bool BrowserView::IsImmersiveModeEnabled() {
+ return immersive_mode_controller()->IsEnabled();
+}
+
+views::Widget* BrowserView::GetBubbleAssociatedWidget() {
+ return GetWidget();
+}
+
+gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
+ return top_container_->GetBoundsInScreen();
+}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index a85e479..de510a0 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -17,9 +17,11 @@
#include "chrome/browser/signin/signin_header_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/infobar_container_delegate.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/contents_web_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
@@ -85,7 +87,9 @@ class BrowserView : public BrowserWindow,
public views::ClientView,
public InfoBarContainerDelegate,
public LoadCompleteListener::Delegate,
- public OmniboxPopupModelObserver {
+ public OmniboxPopupModelObserver,
+ public ExclusiveAccessContext,
+ public ExclusiveAccessBubbleViewsContext {
public:
// The browser view's class name.
static const char kViewClassName[];
@@ -275,7 +279,7 @@ class BrowserView : public BrowserWindow,
ExclusiveAccessBubbleType bubble_type,
bool with_toolbar) override;
void ExitFullscreen() override;
- void UpdateFullscreenExitBubbleContent(
+ void UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) override;
bool ShouldHideUIForFullscreen() const override;
@@ -285,9 +289,9 @@ class BrowserView : public BrowserWindow,
void UpdateFullscreenWithToolbar(bool with_toolbar) override;
bool IsFullscreenWithToolbar() const override;
#if defined(OS_WIN)
- virtual void SetMetroSnapMode(bool enable) override;
- virtual bool IsInMetroSnapMode() const override;
-#endif
+ void SetMetroSnapMode(bool enable) override;
+ bool IsInMetroSnapMode() const override;
+#endif // defined(OS_WIN)
LocationBar* GetLocationBar() const override;
void SetFocusToLocationBar(bool select_all) override;
void UpdateReloadStopState(bool is_loading, bool force) override;
@@ -361,6 +365,7 @@ class BrowserView : public BrowserWindow,
int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
void ExecuteExtensionCommand(const extensions::Extension* extension,
const extensions::Command& command) override;
+ ExclusiveAccessContext* GetExclusiveAccessContext() override;
BookmarkBarView* GetBookmarkBarView() const;
LocationBarView* GetLocationBarView() const;
@@ -438,6 +443,18 @@ class BrowserView : public BrowserWindow,
// OmniboxPopupModelObserver overrides
void OnOmniboxPopupShownOrHidden() override;
+ // ExclusiveAccessContext overrides
+ Profile* GetProfile() override;
+ content::WebContents* GetActiveWebContents() override;
+ void HideDownloadShelf() override;
+ void UnhideDownloadShelf() override;
+
+ // ExclusiveAccessBubbleViewsContext overrides
+ ExclusiveAccessManager* GetExclusiveAccessManager() override;
+ bool IsImmersiveModeEnabled() override;
+ views::Widget* GetBubbleAssociatedWidget() override;
+ gfx::Rect GetTopContainerBoundsInScreen() override;
+
// Testing interface:
views::View* GetContentsContainerForTest() { return contents_container_; }
views::WebView* GetContentsWebViewForTest() { return contents_web_view_; }
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 5bb7f3a..4a67535 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1446,6 +1446,8 @@
'browser/ui/exclusive_access/exclusive_access_bubble.h',
'browser/ui/exclusive_access/exclusive_access_bubble_type.cc',
'browser/ui/exclusive_access/exclusive_access_bubble_type.h',
+ 'browser/ui/exclusive_access/exclusive_access_context.cc',
+ 'browser/ui/exclusive_access/exclusive_access_context.h',
'browser/ui/exclusive_access/exclusive_access_controller_base.cc',
'browser/ui/exclusive_access/exclusive_access_controller_base.h',
'browser/ui/exclusive_access/exclusive_access_manager.cc',
@@ -2067,6 +2069,7 @@
'browser/ui/views/elevation_icon_setter.h',
'browser/ui/views/exclusive_access_bubble_views.cc',
'browser/ui/views/exclusive_access_bubble_views.h',
+ 'browser/ui/views/exclusive_access_bubble_views_context.h',
'browser/ui/views/extensions/bookmark_app_bubble_view.cc',
'browser/ui/views/extensions/bookmark_app_bubble_view.h',
'browser/ui/views/extensions/browser_action_drag_data.cc',
diff --git a/chrome/test/base/test_browser_window.cc b/chrome/test/base/test_browser_window.cc
index f04e7ae..62f9183 100644
--- a/chrome/test/base/test_browser_window.cc
+++ b/chrome/test/base/test_browser_window.cc
@@ -231,3 +231,7 @@ TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
void TestBrowserWindow::ExecuteExtensionCommand(
const extensions::Extension* extension,
const extensions::Command& command) {}
+
+ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
+ return nullptr;
+}
diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h
index ab05492..6ee00f2 100644
--- a/chrome/test/base/test_browser_window.h
+++ b/chrome/test/base/test_browser_window.h
@@ -66,7 +66,7 @@ class TestBrowserWindow : public BrowserWindow {
ExclusiveAccessBubbleType type,
bool with_toolbar) override {}
void ExitFullscreen() override {}
- void UpdateFullscreenExitBubbleContent(
+ void UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) override {}
bool ShouldHideUIForFullscreen() const override;
@@ -150,6 +150,7 @@ class TestBrowserWindow : public BrowserWindow {
int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
void ExecuteExtensionCommand(const extensions::Extension* extension,
const extensions::Command& command) override;
+ ExclusiveAccessContext* GetExclusiveAccessContext() override;
protected:
void DestroyBrowser() override {}