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

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

Issue 789533002: Fullscreen: make fullscreen requests come from RenderFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/fullscreen/fullscreen_controller.cc
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.cc b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
index 18eb88e7af8ba017ac3580c0604b644469efab9b..a5ff0288b77c8106bf4f5c1651460d1f5078f99b 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
@@ -97,6 +97,7 @@ bool FullscreenController::IsFullscreenCausedByTab() const {
}
void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
+ const GURL& origin,
bool enter_fullscreen) {
if (MaybeToggleFullscreenForCapturedTab(web_contents, enter_fullscreen)) {
// During tab capture of fullscreen-within-tab views, the browser window
@@ -125,7 +126,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen();
if (enter_fullscreen) {
- SetFullscreenedTab(web_contents);
+ SetFullscreenedTab(web_contents, origin);
if (!in_browser_or_tab_fullscreen_mode) {
// Normal -> Tab Fullscreen.
state_prior_to_tab_fullscreen_ = STATE_NORMAL;
@@ -140,12 +141,9 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR;
}
- // We need to update the fullscreen exit bubble, e.g., going from browser
- // fullscreen to tab fullscreen will need to show different content.
- const GURL& url = web_contents->GetURL();
if (!tab_fullscreen_accepted_) {
tab_fullscreen_accepted_ =
- GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
+ GetFullscreenSetting() == CONTENT_SETTING_ALLOW;
}
UpdateFullscreenExitBubbleContent();
@@ -455,7 +453,7 @@ void FullscreenController::Observe(int type,
GURL FullscreenController::GetFullscreenExitBubbleURL() const {
if (fullscreened_tab_)
- return fullscreened_tab_->GetURL();
+ return GetRequestingOrigin();
if (mouse_lock_tab_)
return mouse_lock_tab_->GetURL();
return extension_caused_fullscreen_;
@@ -533,7 +531,7 @@ void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) {
void FullscreenController::NotifyTabOfExitIfNecessary() {
if (fullscreened_tab_) {
RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost();
- SetFullscreenedTab(NULL);
+ SetFullscreenedTab(nullptr, GURL());
state_prior_to_tab_fullscreen_ = STATE_INVALID;
tab_fullscreen_accepted_ = false;
if (rvh)
@@ -610,9 +608,9 @@ void FullscreenController::EnterFullscreenModeInternal(
toggled_into_fullscreen_ = true;
GURL url;
if (option == TAB) {
- url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
+ url = GetRequestingOrigin();
tab_fullscreen_accepted_ =
- GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
+ GetFullscreenSetting() == CONTENT_SETTING_ALLOW;
} else {
if (!extension_caused_fullscreen_.is_empty())
url = extension_caused_fullscreen_;
@@ -649,8 +647,10 @@ void FullscreenController::ExitFullscreenModeInternal() {
UpdateFullscreenExitBubbleContent();
}
-void FullscreenController::SetFullscreenedTab(WebContents* tab) {
+void FullscreenController::SetFullscreenedTab(WebContents* tab,
+ const GURL& origin) {
fullscreened_tab_ = tab;
+ fullscreened_origin_ = origin;
UpdateNotificationRegistrations();
}
@@ -661,7 +661,7 @@ void FullscreenController::SetMouseLockTab(WebContents* tab) {
void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() {
if (IsWindowFullscreenForTabOrPending())
- ToggleFullscreenModeForTab(fullscreened_tab_, false);
+ ToggleFullscreenModeForTab(fullscreened_tab_, GURL(), false);
else
NotifyTabOfExitIfNecessary();
}
@@ -678,12 +678,19 @@ void FullscreenController::UpdateFullscreenExitBubbleContent() {
}
ContentSetting
-FullscreenController::GetFullscreenSetting(const GURL& url) const {
+FullscreenController::GetFullscreenSetting() const {
+ DCHECK(fullscreened_tab_);
+
+ GURL url = GetRequestingOrigin();
+
if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile())
return CONTENT_SETTING_ALLOW;
- return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url,
- CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
+ return profile_->GetHostContentSettingsMap()->GetContentSetting(
+ url,
+ GetEmbeddingOrigin(),
+ CONTENT_SETTINGS_TYPE_FULLSCREEN,
+ std::string());
}
ContentSetting
@@ -754,3 +761,18 @@ void FullscreenController::UnlockMouse() {
if (mouse_lock_view)
mouse_lock_view->UnlockMouse();
}
+
+GURL FullscreenController::GetRequestingOrigin() const {
+ DCHECK(fullscreened_tab_);
+
+ if (!fullscreened_origin_.is_empty())
+ return fullscreened_origin_;
+
+ return fullscreened_tab_->GetLastCommittedURL();
+}
+
+GURL FullscreenController::GetEmbeddingOrigin() const {
+ DCHECK(fullscreened_tab_);
+
+ return fullscreened_tab_->GetLastCommittedURL();
+}

Powered by Google App Engine
This is Rietveld 408576698