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

Unified Diff: chrome/browser/ui/exclusive_access/fullscreen_controller.cc

Issue 836933005: Refactor fullscreen_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build break Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/exclusive_access/fullscreen_controller.cc
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
index 66554695eb72c1e0aeca33cddb3bf88a3a19321f..e07516781c7b29ecac0d4dcd083d0fcefab6a6f7 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
@@ -37,28 +37,22 @@ using base::UserMetricsAction;
using content::RenderViewHost;
using content::WebContents;
-FullscreenController::FullscreenController(Browser* browser)
- : browser_(browser),
- window_(browser->window()),
- profile_(browser->profile()),
- fullscreened_tab_(NULL),
+FullscreenController::FullscreenController(ExclusiveAccessManager* manager,
+ Browser* browser)
+ : ExclusiveAccessControllerBase(manager, browser),
state_prior_to_tab_fullscreen_(STATE_INVALID),
tab_fullscreen_accepted_(false),
toggled_into_fullscreen_(false),
- mouse_lock_tab_(NULL),
- mouse_lock_state_(MOUSELOCK_NOT_REQUESTED),
reentrant_window_state_change_call_check_(false),
is_privileged_fullscreen_for_testing_(false),
ptr_factory_(this) {
- DCHECK(window_);
- DCHECK(profile_);
}
FullscreenController::~FullscreenController() {
}
bool FullscreenController::IsFullscreenForBrowser() const {
- return window_->IsFullscreen() && !IsFullscreenCausedByTab();
+ return GetWindow()->IsFullscreen() && !IsFullscreenCausedByTab();
}
void FullscreenController::ToggleBrowserFullscreenMode() {
@@ -79,13 +73,26 @@ void FullscreenController::ToggleBrowserFullscreenModeWithExtension(
}
bool FullscreenController::IsWindowFullscreenForTabOrPending() const {
- return fullscreened_tab_ != NULL;
+ return GetExclusiveAccessTab() != nullptr;
+}
+
+bool FullscreenController::IsExtensionFullscreenOrPending() const {
+ return !extension_caused_fullscreen_.is_empty();
+}
+
+bool FullscreenController::IsControllerInitiatedFullscreen() const {
+ return toggled_into_fullscreen_;
+}
+
+bool FullscreenController::IsUserAcceptedFullscreen() const {
+ return tab_fullscreen_accepted_;
}
bool FullscreenController::IsFullscreenForTabOrPending(
const WebContents* web_contents) const {
- if (web_contents == fullscreened_tab_) {
- DCHECK(web_contents == browser_->tab_strip_model()->GetActiveWebContents());
+ if (web_contents == GetExclusiveAccessTab()) {
+ DCHECK(web_contents ==
+ GetBrowser()->tab_strip_model()->GetActiveWebContents());
DCHECK(web_contents->GetCapturerCount() == 0);
return true;
}
@@ -103,11 +110,11 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
// fullscreen state is unchanged, so return now.
return;
}
- if (fullscreened_tab_) {
- if (web_contents != fullscreened_tab_)
+ if (GetExclusiveAccessTab()) {
+ if (web_contents != GetExclusiveAccessTab())
return;
- } else if (
- web_contents != browser_->tab_strip_model()->GetActiveWebContents()) {
+ } else if (web_contents !=
+ GetBrowser()->tab_strip_model()->GetActiveWebContents()) {
return;
}
if (IsWindowFullscreenForTabOrPending() == enter_fullscreen)
@@ -122,18 +129,18 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
return;
#endif
- bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen();
+ bool in_browser_or_tab_fullscreen_mode = GetWindow()->IsFullscreen();
if (enter_fullscreen) {
- SetFullscreenedTab(web_contents);
+ SetTabWithExclusiveAccess(web_contents);
if (!in_browser_or_tab_fullscreen_mode) {
// Normal -> Tab Fullscreen.
state_prior_to_tab_fullscreen_ = STATE_NORMAL;
ToggleFullscreenModeInternal(TAB);
} else {
- if (window_->IsFullscreenWithToolbar()) {
+ if (GetWindow()->IsFullscreenWithToolbar()) {
// Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar).
- window_->UpdateFullscreenWithToolbar(false);
+ GetWindow()->UpdateFullscreenWithToolbar(false);
state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR;
} else {
// Browser Fullscreen without Toolbar -> Tab Fullscreen.
@@ -147,7 +154,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
tab_fullscreen_accepted_ =
GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
}
- UpdateFullscreenExitBubbleContent();
+ GetManager()->UpdateExclusiveAccessExitBubbleContent();
// This is only a change between Browser and Tab fullscreen. We generate
// a fullscreen notification now because there is no window change.
@@ -163,12 +170,12 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
if (state_prior_to_tab_fullscreen_ ==
STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) {
// Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar.
- window_->UpdateFullscreenWithToolbar(true);
+ GetWindow()->UpdateFullscreenWithToolbar(true);
}
#if defined(OS_MACOSX)
// Clear the bubble URL, which forces the Mac UI to redraw.
- UpdateFullscreenExitBubbleContent();
+ GetManager()->UpdateExclusiveAccessExitBubbleContent();
#endif // defined(OS_MACOSX)
// If currently there is a tab in "tab fullscreen" mode and fullscreen
@@ -176,7 +183,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
// mode), we need to switch back to "browser fullscreen" mode. In this
// case, all we have to do is notifying the tab that it has exited "tab
// fullscreen" mode.
- NotifyTabOfExitIfNecessary();
+ NotifyTabOfExclusiveAccessChange();
// This is only a change between Browser and Tab fullscreen. We generate
// a fullscreen notification now because there is no window change.
@@ -188,7 +195,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
bool FullscreenController::IsInMetroSnapMode() {
#if defined(OS_WIN)
- return window_->IsInMetroSnapMode();
+ return GetWindow()->IsInMetroSnapMode();
#else
return false;
#endif
@@ -199,7 +206,7 @@ void FullscreenController::SetMetroSnapMode(bool enable) {
reentrant_window_state_change_call_check_ = false;
toggled_into_fullscreen_ = false;
- window_->SetMetroSnapMode(enable);
+ GetWindow()->SetMetroSnapMode(enable);
// FullscreenController unit tests for metro snap assume that on Windows calls
// to WindowFullscreenStateChanged are reentrant. If that assumption is
@@ -208,73 +215,6 @@ void FullscreenController::SetMetroSnapMode(bool enable) {
}
#endif // defined(OS_WIN)
-bool FullscreenController::IsMouseLockRequested() const {
- return mouse_lock_state_ == MOUSELOCK_REQUESTED;
-}
-
-bool FullscreenController::IsMouseLocked() const {
- return mouse_lock_state_ == MOUSELOCK_ACCEPTED ||
- mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY;
-}
-
-void FullscreenController::RequestToLockMouse(WebContents* web_contents,
- bool user_gesture,
- bool last_unlocked_by_target) {
- DCHECK(!IsMouseLocked());
- NotifyMouseLockChange();
-
- // Must have a user gesture to prevent misbehaving sites from constantly
- // re-locking the mouse. Exceptions are when the page has unlocked
- // (i.e. not the user), or if we're in tab fullscreen (user gesture required
- // for that)
- if (!last_unlocked_by_target && !user_gesture &&
- !IsFullscreenForTabOrPending(web_contents)) {
- web_contents->GotResponseToLockMouseRequest(false);
- return;
- }
- SetMouseLockTab(web_contents);
- ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessBubbleType();
-
- switch (GetMouseLockSetting(web_contents->GetURL())) {
- case CONTENT_SETTING_ALLOW:
- // If bubble already displaying buttons we must not lock the mouse yet,
- // or it would prevent pressing those buttons. Instead, merge the request.
- if (!IsPrivilegedFullscreenForTab() &&
- exclusive_access_bubble::ShowButtonsForType(bubble_type)) {
- mouse_lock_state_ = MOUSELOCK_REQUESTED;
- } else {
- // Lock mouse.
- if (web_contents->GotResponseToLockMouseRequest(true)) {
- if (last_unlocked_by_target) {
- mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY;
- } else {
- mouse_lock_state_ = MOUSELOCK_ACCEPTED;
- }
- } else {
- SetMouseLockTab(NULL);
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- }
- }
- break;
- case CONTENT_SETTING_BLOCK:
- web_contents->GotResponseToLockMouseRequest(false);
- SetMouseLockTab(NULL);
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- break;
- case CONTENT_SETTING_ASK:
- mouse_lock_state_ = MOUSELOCK_REQUESTED;
- break;
- default:
- NOTREACHED();
- }
- UpdateFullscreenExitBubbleContent();
-}
-
-void FullscreenController::OnTabDeactivated(WebContents* web_contents) {
- if (web_contents == fullscreened_tab_ || web_contents == mouse_lock_tab_)
- ExitTabFullscreenOrMouseLockIfNecessary();
-}
-
void FullscreenController::OnTabDetachedFromView(WebContents* old_contents) {
if (!IsFullscreenForCapturedTab(old_contents))
return;
@@ -312,98 +252,71 @@ void FullscreenController::OnTabClosing(WebContents* web_contents) {
RenderViewHost* const rvh = web_contents->GetRenderViewHost();
if (rvh)
rvh->ExitFullscreen();
- } else if (web_contents == fullscreened_tab_ ||
- web_contents == mouse_lock_tab_) {
- ExitTabFullscreenOrMouseLockIfNecessary();
- // The call to exit fullscreen may result in asynchronous notification of
- // fullscreen state change (e.g., on Linux). We don't want to rely on it
- // to call NotifyTabOfExitIfNecessary(), because at that point
- // |fullscreened_tab_| may not be valid. Instead, we call it here to clean
- // up tab fullscreen related state.
- NotifyTabOfExitIfNecessary();
+ } else {
+ ExclusiveAccessControllerBase::OnTabClosing(web_contents);
}
}
void FullscreenController::WindowFullscreenStateChanged() {
reentrant_window_state_change_call_check_ = true;
- bool exiting_fullscreen = !window_->IsFullscreen();
+ bool exiting_fullscreen = !GetWindow()->IsFullscreen();
PostFullscreenChangeNotification(!exiting_fullscreen);
if (exiting_fullscreen) {
toggled_into_fullscreen_ = false;
extension_caused_fullscreen_ = GURL();
- NotifyTabOfExitIfNecessary();
+ NotifyTabOfExclusiveAccessChange();
}
if (exiting_fullscreen) {
- window_->GetDownloadShelf()->Unhide();
+ GetWindow()->GetDownloadShelf()->Unhide();
} else {
- window_->GetDownloadShelf()->Hide();
- if (window_->GetStatusBubble())
- window_->GetStatusBubble()->Hide();
+ GetWindow()->GetDownloadShelf()->Hide();
+ if (GetWindow()->GetStatusBubble())
+ GetWindow()->GetStatusBubble()->Hide();
}
}
bool FullscreenController::HandleUserPressedEscape() {
WebContents* const active_web_contents =
- browser_->tab_strip_model()->GetActiveWebContents();
+ GetBrowser()->tab_strip_model()->GetActiveWebContents();
if (IsFullscreenForCapturedTab(active_web_contents)) {
RenderViewHost* const rvh = active_web_contents->GetRenderViewHost();
if (rvh)
rvh->ExitFullscreen();
return true;
- } else if (IsWindowFullscreenForTabOrPending() ||
- IsMouseLocked() || IsMouseLockRequested()) {
- ExitTabFullscreenOrMouseLockIfNecessary();
+ } else if (IsWindowFullscreenForTabOrPending()) {
+ ExitExclusiveAccessIfNecessary();
return true;
}
return false;
}
-void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() {
+void FullscreenController::ExitExclusiveAccessToPreviousState() {
if (IsWindowFullscreenForTabOrPending())
- ExitTabFullscreenOrMouseLockIfNecessary();
+ ToggleFullscreenModeForTab(GetExclusiveAccessTab(), false);
else if (IsFullscreenForBrowser())
ExitFullscreenModeInternal();
}
-void FullscreenController::OnAcceptFullscreenPermission() {
- ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessBubbleType();
- bool mouse_lock = false;
+bool FullscreenController::OnAcceptExclusiveAccessPermission() {
+ ExclusiveAccessBubbleType bubble_type =
+ GetManager()->GetExclusiveAccessExitBubbleType();
bool fullscreen = false;
exclusive_access_bubble::PermissionRequestedByType(bubble_type, &fullscreen,
- &mouse_lock);
+ nullptr);
DCHECK(!(fullscreen && tab_fullscreen_accepted_));
- DCHECK(!(mouse_lock && IsMouseLocked()));
-
- HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
- GURL url = GetFullscreenExitBubbleURL();
- ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url);
+ if (fullscreen && !tab_fullscreen_accepted_) {
+ DCHECK(GetExclusiveAccessTab());
- if (mouse_lock && !IsMouseLocked()) {
- DCHECK(IsMouseLockRequested());
- // TODO(markusheintz): We should allow patterns for all possible URLs here.
- if (pattern.IsValid()) {
- settings_map->SetContentSetting(
- pattern, ContentSettingsPattern::Wildcard(),
- CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
- CONTENT_SETTING_ALLOW);
- }
+ HostContentSettingsMap* settings_map =
+ GetProfile()->GetHostContentSettingsMap();
- if (mouse_lock_tab_ &&
- mouse_lock_tab_->GotResponseToLockMouseRequest(true)) {
- mouse_lock_state_ = MOUSELOCK_ACCEPTED;
- } else {
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- SetMouseLockTab(NULL);
- }
- NotifyMouseLockChange();
- }
+ GURL url = GetExclusiveAccessBubbleURL();
+ ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url);
- if (fullscreen && !tab_fullscreen_accepted_) {
- DCHECK(fullscreened_tab_);
if (pattern.IsValid()) {
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
@@ -411,107 +324,32 @@ void FullscreenController::OnAcceptFullscreenPermission() {
CONTENT_SETTING_ALLOW);
}
tab_fullscreen_accepted_ = true;
- }
- UpdateFullscreenExitBubbleContent();
-}
-
-void FullscreenController::OnDenyFullscreenPermission() {
- if (!fullscreened_tab_ && !mouse_lock_tab_)
- return;
-
- if (IsMouseLockRequested()) {
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- if (mouse_lock_tab_)
- mouse_lock_tab_->GotResponseToLockMouseRequest(false);
- SetMouseLockTab(NULL);
- NotifyMouseLockChange();
-
- // UpdateFullscreenExitBubbleContent() must be called, but to avoid
- // duplicate calls we do so only if not adjusting the fullscreen state
- // below, which also calls UpdateFullscreenExitBubbleContent().
- if (!IsWindowFullscreenForTabOrPending())
- UpdateFullscreenExitBubbleContent();
+ return true;
}
- if (IsWindowFullscreenForTabOrPending())
- ExitTabFullscreenOrMouseLockIfNecessary();
+ return false;
}
-void FullscreenController::LostMouseLock() {
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- SetMouseLockTab(NULL);
- NotifyMouseLockChange();
- UpdateFullscreenExitBubbleContent();
-}
+bool FullscreenController::OnDenyExclusiveAccessPermission() {
+ if (IsWindowFullscreenForTabOrPending()) {
+ ExitExclusiveAccessIfNecessary();
+ return true;
+ }
-void FullscreenController::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
- if (content::Details<content::LoadCommittedDetails>(details)->
- is_navigation_to_different_page())
- ExitTabFullscreenOrMouseLockIfNecessary();
+ return false;
}
-GURL FullscreenController::GetFullscreenExitBubbleURL() const {
- if (fullscreened_tab_)
- return fullscreened_tab_->GetURL();
- if (mouse_lock_tab_)
- return mouse_lock_tab_->GetURL();
+GURL FullscreenController::GetURLForExclusiveAccessBubble() const {
+ if (GetExclusiveAccessTab())
+ return GetExclusiveAccessTab()->GetURL();
return extension_caused_fullscreen_;
}
-ExclusiveAccessBubbleType FullscreenController::GetExclusiveAccessBubbleType()
- const {
- // In kiosk and exclusive app mode we always want to be fullscreen and do not
- // want to show exit instructions for browser mode fullscreen.
- bool app_mode = false;
-#if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet.
- app_mode = chrome::IsRunningInAppMode();
-#endif
-
- if (mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY)
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
-
- if (!fullscreened_tab_) {
- if (IsMouseLocked())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION;
- if (IsMouseLockRequested())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
- if (!extension_caused_fullscreen_.is_empty())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION;
- if (toggled_into_fullscreen_ && !app_mode)
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
- }
-
- if (tab_fullscreen_accepted_) {
- if (IsPrivilegedFullscreenForTab())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
- if (IsMouseLocked())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
- if (IsMouseLockRequested())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION;
- }
-
- if (IsMouseLockRequested())
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS;
- return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS;
-}
-
-void FullscreenController::UpdateNotificationRegistrations() {
- if (fullscreened_tab_ && mouse_lock_tab_)
- DCHECK(fullscreened_tab_ == mouse_lock_tab_);
-
- WebContents* tab = fullscreened_tab_ ? fullscreened_tab_ : mouse_lock_tab_;
-
- if (tab && registrar_.IsEmpty()) {
- registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::Source<content::NavigationController>(&tab->GetController()));
- } else if (!tab && !registrar_.IsEmpty()) {
- registrar_.RemoveAll();
- }
+void FullscreenController::ExitExclusiveAccessIfNecessary() {
+ if (IsWindowFullscreenForTabOrPending())
+ ToggleFullscreenModeForTab(GetExclusiveAccessTab(), false);
+ else
+ NotifyTabOfExclusiveAccessChange();
}
void FullscreenController::PostFullscreenChangeNotification(
@@ -530,35 +368,16 @@ void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) {
content::Details<bool>(&is_fullscreen));
}
-void FullscreenController::NotifyTabOfExitIfNecessary() {
- if (fullscreened_tab_) {
- RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost();
- SetFullscreenedTab(NULL);
+void FullscreenController::NotifyTabOfExclusiveAccessChange() {
+ if (GetExclusiveAccessTab()) {
+ RenderViewHost* rvh = GetExclusiveAccessTab()->GetRenderViewHost();
+ SetTabWithExclusiveAccess(nullptr);
state_prior_to_tab_fullscreen_ = STATE_INVALID;
tab_fullscreen_accepted_ = false;
if (rvh)
rvh->ExitFullscreen();
+ GetManager()->UpdateExclusiveAccessExitBubbleContent();
}
-
- if (mouse_lock_tab_) {
- if (IsMouseLockRequested()) {
- mouse_lock_tab_->GotResponseToLockMouseRequest(false);
- NotifyMouseLockChange();
- } else {
- UnlockMouse();
- }
- SetMouseLockTab(NULL);
- mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
- }
-
- UpdateFullscreenExitBubbleContent();
-}
-
-void FullscreenController::NotifyMouseLockChange() {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
- content::Source<FullscreenController>(this),
- content::NotificationService::NoDetails());
}
void FullscreenController::ToggleFullscreenModeInternal(
@@ -569,24 +388,24 @@ void FullscreenController::ToggleFullscreenModeInternal(
return;
#endif
- bool enter_fullscreen = !window_->IsFullscreen();
+ bool enter_fullscreen = !GetWindow()->IsFullscreen();
// When a Mac user requests a toggle they may be toggling between
// FullscreenWithoutChrome and FullscreenWithToolbar.
- if (window_->IsFullscreen() &&
- !IsWindowFullscreenForTabOrPending() &&
- window_->SupportsFullscreenWithToolbar()) {
+ if (GetWindow()->IsFullscreen() && !IsWindowFullscreenForTabOrPending() &&
+ GetWindow()->SupportsFullscreenWithToolbar()) {
if (option == BROWSER_WITH_TOOLBAR) {
enter_fullscreen =
- enter_fullscreen || !window_->IsFullscreenWithToolbar();
+ enter_fullscreen || !GetWindow()->IsFullscreenWithToolbar();
} else {
- enter_fullscreen = enter_fullscreen || window_->IsFullscreenWithToolbar();
+ enter_fullscreen =
+ enter_fullscreen || GetWindow()->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() && GetWindow()->IsFullscreen())
return;
#if !defined(OS_MACOSX)
@@ -594,7 +413,7 @@ void FullscreenController::ToggleFullscreenModeInternal(
// from manually entering fullscreen mode and also disables kiosk mode on
// desktop platforms.
if (enter_fullscreen &&
- !profile_->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) {
+ !GetProfile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) {
return;
}
#endif
@@ -610,7 +429,7 @@ void FullscreenController::EnterFullscreenModeInternal(
toggled_into_fullscreen_ = true;
GURL url;
if (option == TAB) {
- url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
+ url = GetBrowser()->tab_strip_model()->GetActiveWebContents()->GetURL();
tab_fullscreen_accepted_ =
GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
} else {
@@ -623,10 +442,11 @@ void FullscreenController::EnterFullscreenModeInternal(
// TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions
// from tab fullscreen out to browser with toolbar.
- window_->EnterFullscreen(url, GetExclusiveAccessBubbleType(),
- option == BROWSER_WITH_TOOLBAR);
+ GetWindow()->EnterFullscreen(url,
+ GetManager()->GetExclusiveAccessExitBubbleType(),
+ option == BROWSER_WITH_TOOLBAR);
- UpdateFullscreenExitBubbleContent();
+ GetManager()->UpdateExclusiveAccessExitBubbleContent();
// Once the window has become fullscreen it'll call back to
// WindowFullscreenStateChanged(). We don't do this immediately as
@@ -640,41 +460,12 @@ void FullscreenController::ExitFullscreenModeInternal() {
// Mac windows report a state change instantly, and so we must also clear
// state_prior_to_tab_fullscreen_ to match them else other logic using
// state_prior_to_tab_fullscreen_ will be incorrect.
- NotifyTabOfExitIfNecessary();
+ NotifyTabOfExclusiveAccessChange();
#endif
- window_->ExitFullscreen();
+ GetWindow()->ExitFullscreen();
extension_caused_fullscreen_ = GURL();
- UpdateFullscreenExitBubbleContent();
-}
-
-void FullscreenController::SetFullscreenedTab(WebContents* tab) {
- fullscreened_tab_ = tab;
- UpdateNotificationRegistrations();
-}
-
-void FullscreenController::SetMouseLockTab(WebContents* tab) {
- mouse_lock_tab_ = tab;
- UpdateNotificationRegistrations();
-}
-
-void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() {
- if (IsWindowFullscreenForTabOrPending())
- ToggleFullscreenModeForTab(fullscreened_tab_, false);
- else
- NotifyTabOfExitIfNecessary();
-}
-
-void FullscreenController::UpdateFullscreenExitBubbleContent() {
- GURL url = GetFullscreenExitBubbleURL();
- ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessBubbleType();
-
- // If bubble displays buttons, unlock mouse to allow pressing them.
- if (exclusive_access_bubble::ShowButtonsForType(bubble_type) &&
- IsMouseLocked())
- UnlockMouse();
-
- window_->UpdateFullscreenExitBubbleContent(url, bubble_type);
+ GetManager()->UpdateExclusiveAccessExitBubbleContent();
}
ContentSetting
@@ -682,24 +473,14 @@ FullscreenController::GetFullscreenSetting(const GURL& url) const {
if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile())
return CONTENT_SETTING_ALLOW;
- return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url,
- CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
-}
-
-ContentSetting
-FullscreenController::GetMouseLockSetting(const GURL& url) const {
- if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile())
- return CONTENT_SETTING_ALLOW;
-
- HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
- return settings_map->GetContentSetting(url, url,
- CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string());
+ return GetProfile()->GetHostContentSettingsMap()->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
}
bool FullscreenController::IsPrivilegedFullscreenForTab() const {
const bool embedded_widget_present =
- fullscreened_tab_ &&
- fullscreened_tab_->GetFullscreenRenderWidgetHostView();
+ GetExclusiveAccessTab() &&
+ GetExclusiveAccessTab()->GetFullscreenRenderWidgetHostView();
return embedded_widget_present || is_privileged_fullscreen_for_testing_;
}
@@ -729,28 +510,16 @@ bool FullscreenController::MaybeToggleFullscreenForCapturedTab(
bool FullscreenController::IsFullscreenForCapturedTab(
const WebContents* web_contents) const {
- // Note: On Mac, some of the OnTabXXX() methods get called with a NULL value
+ // Note: On Mac, some of the OnTabXXX() methods get called with a nullptr
+ // value
// for web_contents. Check for that here.
- const FullscreenWithinTabHelper* const helper = web_contents ?
- FullscreenWithinTabHelper::FromWebContents(web_contents) : NULL;
+ const FullscreenWithinTabHelper* const helper =
+ web_contents ? FullscreenWithinTabHelper::FromWebContents(web_contents)
+ : nullptr;
if (helper && helper->is_fullscreen_for_captured_tab()) {
- DCHECK_NE(fullscreened_tab_, web_contents);
+ DCHECK_NE(GetExclusiveAccessTab(), web_contents);
return true;
}
return false;
}
-void FullscreenController::UnlockMouse() {
- if (!mouse_lock_tab_)
- return;
- content::RenderWidgetHostView* mouse_lock_view =
- (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ?
- mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL;
- if (!mouse_lock_view) {
- RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost();
- if (rvh)
- mouse_lock_view = rvh->GetView();
- }
- if (mouse_lock_view)
- mouse_lock_view->UnlockMouse();
-}

Powered by Google App Engine
This is Rietveld 408576698