Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 DCHECK(web_contents->GetCapturerCount() == 0); | 89 DCHECK(web_contents->GetCapturerCount() == 0); |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 return IsFullscreenForCapturedTab(web_contents); | 92 return IsFullscreenForCapturedTab(web_contents); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool FullscreenController::IsFullscreenCausedByTab() const { | 95 bool FullscreenController::IsFullscreenCausedByTab() const { |
| 96 return state_prior_to_tab_fullscreen_ == STATE_NORMAL; | 96 return state_prior_to_tab_fullscreen_ == STATE_NORMAL; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, | 99 void FullscreenController::EnterFullscreenModeForTab(WebContents* web_contents, |
| 100 bool enter_fullscreen) { | 100 const GURL& origin) { |
| 101 if (MaybeToggleFullscreenForCapturedTab(web_contents, enter_fullscreen)) { | 101 DCHECK(web_contents); |
| 102 | |
| 103 if (MaybeToggleFullscreenForCapturedTab(web_contents, true)) { | |
| 102 // During tab capture of fullscreen-within-tab views, the browser window | 104 // During tab capture of fullscreen-within-tab views, the browser window |
| 103 // fullscreen state is unchanged, so return now. | 105 // fullscreen state is unchanged, so return now. |
| 104 return; | 106 return; |
| 105 } | 107 } |
| 106 if (fullscreened_tab_) { | 108 |
| 107 if (web_contents != fullscreened_tab_) | 109 if (web_contents != browser_->tab_strip_model()->GetActiveWebContents() || |
| 110 IsWindowFullscreenForTabOrPending()) { | |
| 108 return; | 111 return; |
| 109 } else if ( | |
| 110 web_contents != browser_->tab_strip_model()->GetActiveWebContents()) { | |
| 111 return; | |
| 112 } | 112 } |
| 113 if (IsWindowFullscreenForTabOrPending() == enter_fullscreen) | |
| 114 return; | |
| 115 | 113 |
| 116 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
| 117 // For now, avoid breaking when initiating full screen tab mode while in | 115 // For now, avoid breaking when initiating full screen tab mode while in |
| 116 // a metro snap. | |
| 117 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | |
| 118 // modes with metro snap. | |
| 119 if (IsInMetroSnapMode()) | |
| 120 return; | |
| 121 #endif | |
| 122 | |
| 123 SetFullscreenedTab(web_contents, origin); | |
| 124 | |
| 125 if (!window_->IsFullscreen()) { | |
| 126 // Normal -> Tab Fullscreen. | |
| 127 state_prior_to_tab_fullscreen_ = STATE_NORMAL; | |
| 128 ToggleFullscreenModeInternal(TAB); | |
| 129 return; | |
| 130 } | |
| 131 | |
| 132 if (window_->IsFullscreenWithToolbar()) { | |
| 133 // Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar). | |
| 134 window_->UpdateFullscreenWithToolbar(false); | |
| 135 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; | |
| 136 } else { | |
| 137 // Browser Fullscreen without Toolbar -> Tab Fullscreen. | |
| 138 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR; | |
| 139 } | |
| 140 | |
| 141 // We need to update the fullscreen exit bubble, e.g., going from browser | |
| 142 // fullscreen to tab fullscreen will need to show different content. | |
| 143 if (!tab_fullscreen_accepted_) { | |
| 144 tab_fullscreen_accepted_ = | |
| 145 GetFullscreenSetting() == CONTENT_SETTING_ALLOW; | |
| 146 } | |
| 147 UpdateFullscreenExitBubbleContent(); | |
| 148 | |
| 149 // This is only a change between Browser and Tab fullscreen. We generate | |
| 150 // a fullscreen notification now because there is no window change. | |
| 151 PostFullscreenChangeNotification(true); | |
| 152 } | |
| 153 | |
| 154 void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) { | |
| 155 if (MaybeToggleFullscreenForCapturedTab(web_contents, false)) { | |
| 156 // During tab capture of fullscreen-within-tab views, the browser window | |
| 157 // fullscreen state is unchanged, so return now. | |
| 158 return; | |
| 159 } | |
| 160 | |
| 161 if (web_contents != fullscreened_tab_ || | |
| 162 web_contents != browser_->tab_strip_model()->GetActiveWebContents() || | |
| 163 !IsWindowFullscreenForTabOrPending()) { | |
| 164 return; | |
| 165 } | |
| 166 | |
| 167 #if defined(OS_WIN) | |
| 168 // For now, avoid breaking when initiating full screen tab mode while in | |
| 118 // a metro snap. | 169 // a metro snap. |
| 119 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | 170 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen |
| 120 // modes with metro snap. | 171 // modes with metro snap. |
| 121 if (IsInMetroSnapMode()) | 172 if (IsInMetroSnapMode()) |
| 122 return; | 173 return; |
| 123 #endif | 174 #endif |
| 124 | 175 |
| 125 bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); | 176 if (!window_->IsFullscreen()) |
| 177 return; | |
| 126 | 178 |
| 127 if (enter_fullscreen) { | 179 if (IsFullscreenCausedByTab()) { |
| 128 SetFullscreenedTab(web_contents); | 180 // Tab Fullscreen -> Normal. |
| 129 if (!in_browser_or_tab_fullscreen_mode) { | 181 ToggleFullscreenModeInternal(TAB); |
| 130 // Normal -> Tab Fullscreen. | 182 return; |
| 131 state_prior_to_tab_fullscreen_ = STATE_NORMAL; | 183 } |
| 132 ToggleFullscreenModeInternal(TAB); | |
| 133 } else { | |
| 134 if (window_->IsFullscreenWithToolbar()) { | |
| 135 // Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar). | |
| 136 window_->UpdateFullscreenWithToolbar(false); | |
| 137 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; | |
| 138 } else { | |
| 139 // Browser Fullscreen without Toolbar -> Tab Fullscreen. | |
| 140 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR; | |
| 141 } | |
| 142 | 184 |
| 143 // We need to update the fullscreen exit bubble, e.g., going from browser | 185 // Tab Fullscreen -> Browser Fullscreen (with or without toolbar). |
| 144 // fullscreen to tab fullscreen will need to show different content. | 186 if (state_prior_to_tab_fullscreen_ == |
| 145 const GURL& url = web_contents->GetURL(); | 187 STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { |
| 146 if (!tab_fullscreen_accepted_) { | 188 // Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. |
| 147 tab_fullscreen_accepted_ = | 189 window_->UpdateFullscreenWithToolbar(true); |
| 148 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 190 } |
| 149 } | |
| 150 UpdateFullscreenExitBubbleContent(); | |
| 151 | |
| 152 // This is only a change between Browser and Tab fullscreen. We generate | |
| 153 // a fullscreen notification now because there is no window change. | |
| 154 PostFullscreenChangeNotification(true); | |
| 155 } | |
| 156 } else { | |
| 157 if (in_browser_or_tab_fullscreen_mode) { | |
| 158 if (IsFullscreenCausedByTab()) { | |
| 159 // Tab Fullscreen -> Normal. | |
| 160 ToggleFullscreenModeInternal(TAB); | |
| 161 } else { | |
| 162 // Tab Fullscreen -> Browser Fullscreen (with or without toolbar). | |
| 163 if (state_prior_to_tab_fullscreen_ == | |
| 164 STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { | |
| 165 // Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. | |
| 166 window_->UpdateFullscreenWithToolbar(true); | |
| 167 } | |
| 168 | 191 |
| 169 #if defined(OS_MACOSX) | 192 #if defined(OS_MACOSX) |
| 170 // Clear the bubble URL, which forces the Mac UI to redraw. | 193 // Clear the bubble URL, which forces the Mac UI to redraw. |
| 171 UpdateFullscreenExitBubbleContent(); | 194 UpdateFullscreenExitBubbleContent(); |
| 172 #endif // defined(OS_MACOSX) | 195 #endif // defined(OS_MACOSX) |
| 173 | 196 |
| 174 // If currently there is a tab in "tab fullscreen" mode and fullscreen | 197 // If currently there is a tab in "tab fullscreen" mode and fullscreen |
| 175 // was not caused by it (i.e., previously it was in "browser fullscreen" | 198 // was not caused by it (i.e., previously it was in "browser fullscreen" |
| 176 // mode), we need to switch back to "browser fullscreen" mode. In this | 199 // mode), we need to switch back to "browser fullscreen" mode. In this |
| 177 // case, all we have to do is notifying the tab that it has exited "tab | 200 // case, all we have to do is notifying the tab that it has exited "tab |
| 178 // fullscreen" mode. | 201 // fullscreen" mode. |
| 179 NotifyTabOfExitIfNecessary(); | 202 NotifyTabOfExitIfNecessary(); |
| 180 | 203 |
| 181 // This is only a change between Browser and Tab fullscreen. We generate | 204 // This is only a change between Browser and Tab fullscreen. We generate |
| 182 // a fullscreen notification now because there is no window change. | 205 // a fullscreen notification now because there is no window change. |
| 183 PostFullscreenChangeNotification(true); | 206 PostFullscreenChangeNotification(true); |
| 184 } | |
| 185 } | |
| 186 } | |
| 187 } | 207 } |
| 188 | 208 |
| 189 bool FullscreenController::IsInMetroSnapMode() { | 209 bool FullscreenController::IsInMetroSnapMode() { |
| 190 #if defined(OS_WIN) | 210 #if defined(OS_WIN) |
| 191 return window_->IsInMetroSnapMode(); | 211 return window_->IsInMetroSnapMode(); |
| 192 #else | 212 #else |
| 193 return false; | 213 return false; |
| 194 #endif | 214 #endif |
| 195 } | 215 } |
| 196 | 216 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 322 |
| 303 content::RenderWidgetHostView* const current_fs_view = | 323 content::RenderWidgetHostView* const current_fs_view = |
| 304 old_contents->GetFullscreenRenderWidgetHostView(); | 324 old_contents->GetFullscreenRenderWidgetHostView(); |
| 305 if (current_fs_view) | 325 if (current_fs_view) |
| 306 current_fs_view->SetSize(old_contents->GetPreferredSize()); | 326 current_fs_view->SetSize(old_contents->GetPreferredSize()); |
| 307 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); | 327 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); |
| 308 } | 328 } |
| 309 | 329 |
| 310 void FullscreenController::OnTabClosing(WebContents* web_contents) { | 330 void FullscreenController::OnTabClosing(WebContents* web_contents) { |
| 311 if (IsFullscreenForCapturedTab(web_contents)) { | 331 if (IsFullscreenForCapturedTab(web_contents)) { |
| 312 RenderViewHost* const rvh = web_contents->GetRenderViewHost(); | 332 web_contents->ExitFullscreen(); |
| 313 if (rvh) | |
| 314 rvh->ExitFullscreen(); | |
| 315 } else if (web_contents == fullscreened_tab_ || | 333 } else if (web_contents == fullscreened_tab_ || |
| 316 web_contents == mouse_lock_tab_) { | 334 web_contents == mouse_lock_tab_) { |
| 317 ExitTabFullscreenOrMouseLockIfNecessary(); | 335 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 318 // The call to exit fullscreen may result in asynchronous notification of | 336 // The call to exit fullscreen may result in asynchronous notification of |
| 319 // fullscreen state change (e.g., on Linux). We don't want to rely on it | 337 // fullscreen state change (e.g., on Linux). We don't want to rely on it |
| 320 // to call NotifyTabOfExitIfNecessary(), because at that point | 338 // to call NotifyTabOfExitIfNecessary(), because at that point |
| 321 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean | 339 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean |
| 322 // up tab fullscreen related state. | 340 // up tab fullscreen related state. |
| 323 NotifyTabOfExitIfNecessary(); | 341 NotifyTabOfExitIfNecessary(); |
| 324 } | 342 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 341 window_->GetDownloadShelf()->Hide(); | 359 window_->GetDownloadShelf()->Hide(); |
| 342 if (window_->GetStatusBubble()) | 360 if (window_->GetStatusBubble()) |
| 343 window_->GetStatusBubble()->Hide(); | 361 window_->GetStatusBubble()->Hide(); |
| 344 } | 362 } |
| 345 } | 363 } |
| 346 | 364 |
| 347 bool FullscreenController::HandleUserPressedEscape() { | 365 bool FullscreenController::HandleUserPressedEscape() { |
| 348 WebContents* const active_web_contents = | 366 WebContents* const active_web_contents = |
| 349 browser_->tab_strip_model()->GetActiveWebContents(); | 367 browser_->tab_strip_model()->GetActiveWebContents(); |
| 350 if (IsFullscreenForCapturedTab(active_web_contents)) { | 368 if (IsFullscreenForCapturedTab(active_web_contents)) { |
| 351 RenderViewHost* const rvh = active_web_contents->GetRenderViewHost(); | 369 active_web_contents->ExitFullscreen(); |
| 352 if (rvh) | |
| 353 rvh->ExitFullscreen(); | |
| 354 return true; | 370 return true; |
| 355 } else if (IsWindowFullscreenForTabOrPending() || | 371 } else if (IsWindowFullscreenForTabOrPending() || |
| 356 IsMouseLocked() || IsMouseLockRequested()) { | 372 IsMouseLocked() || IsMouseLockRequested()) { |
| 357 ExitTabFullscreenOrMouseLockIfNecessary(); | 373 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 358 return true; | 374 return true; |
| 359 } | 375 } |
| 360 | 376 |
| 361 return false; | 377 return false; |
| 362 } | 378 } |
| 363 | 379 |
| 364 void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() { | 380 void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() { |
| 365 if (IsWindowFullscreenForTabOrPending()) | 381 if (IsWindowFullscreenForTabOrPending()) |
| 366 ExitTabFullscreenOrMouseLockIfNecessary(); | 382 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 367 else if (IsFullscreenForBrowser()) | 383 else if (IsFullscreenForBrowser()) |
| 368 ExitFullscreenModeInternal(); | 384 ExitFullscreenModeInternal(); |
| 369 } | 385 } |
| 370 | 386 |
| 371 void FullscreenController::OnAcceptFullscreenPermission() { | 387 void FullscreenController::OnAcceptFullscreenPermission() { |
| 372 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 388 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
| 373 bool mouse_lock = false; | 389 bool mouse_lock = false; |
| 374 bool fullscreen = false; | 390 bool fullscreen = false; |
| 375 fullscreen_bubble::PermissionRequestedByType(bubble_type, &fullscreen, | 391 fullscreen_bubble::PermissionRequestedByType(bubble_type, &fullscreen, |
| 376 &mouse_lock); | 392 &mouse_lock); |
| 377 DCHECK(!(fullscreen && tab_fullscreen_accepted_)); | 393 DCHECK(!(fullscreen && tab_fullscreen_accepted_)); |
| 378 DCHECK(!(mouse_lock && IsMouseLocked())); | 394 DCHECK(!(mouse_lock && IsMouseLocked())); |
| 379 | 395 |
| 380 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 396 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
| 381 | 397 |
| 382 GURL url = GetFullscreenExitBubbleURL(); | |
| 383 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); | |
| 384 | |
| 385 if (mouse_lock && !IsMouseLocked()) { | 398 if (mouse_lock && !IsMouseLocked()) { |
| 386 DCHECK(IsMouseLockRequested()); | 399 DCHECK(IsMouseLockRequested()); |
| 400 | |
| 401 GURL url = GetFullscreenExitBubbleURL(); | |
| 402 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); | |
| 403 | |
| 387 // TODO(markusheintz): We should allow patterns for all possible URLs here. | 404 // TODO(markusheintz): We should allow patterns for all possible URLs here. |
| 388 if (pattern.IsValid()) { | 405 if (pattern.IsValid()) { |
| 389 settings_map->SetContentSetting( | 406 settings_map->SetContentSetting( |
| 390 pattern, ContentSettingsPattern::Wildcard(), | 407 pattern, ContentSettingsPattern::Wildcard(), |
| 391 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 408 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
| 392 CONTENT_SETTING_ALLOW); | 409 CONTENT_SETTING_ALLOW); |
| 393 } | 410 } |
| 394 | 411 |
| 395 if (mouse_lock_tab_ && | 412 if (mouse_lock_tab_ && |
| 396 mouse_lock_tab_->GotResponseToLockMouseRequest(true)) { | 413 mouse_lock_tab_->GotResponseToLockMouseRequest(true)) { |
| 397 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | 414 mouse_lock_state_ = MOUSELOCK_ACCEPTED; |
| 398 } else { | 415 } else { |
| 399 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 416 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| 400 SetMouseLockTab(NULL); | 417 SetMouseLockTab(NULL); |
| 401 } | 418 } |
| 402 NotifyMouseLockChange(); | 419 NotifyMouseLockChange(); |
| 403 } | 420 } |
| 404 | 421 |
| 405 if (fullscreen && !tab_fullscreen_accepted_) { | 422 if (fullscreen && !tab_fullscreen_accepted_) { |
| 406 DCHECK(fullscreened_tab_); | 423 DCHECK(fullscreened_tab_); |
| 407 if (pattern.IsValid()) { | 424 // We allow the requesting origin to use fullscreen when inside the |
| 408 settings_map->SetContentSetting( | 425 // embedding origin. That means that if the requesting origin is found |
| 409 pattern, ContentSettingsPattern::Wildcard(), | 426 // embedded in another origin, it will not be considered as allowed to use |
| 410 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), | 427 // fullscreen. However, if the permission is granted for a tuple with both |
| 411 CONTENT_SETTING_ALLOW); | 428 // origins being the same, the requesting origin will always be allowed to |
| 412 } | 429 // use fullscreen, regardless of the embedder. |
|
scheib
2014/12/11 17:56:56
This was still difficult for me to understand. Her
| |
| 430 settings_map->SetContentSetting( | |
| 431 ContentSettingsPattern::FromURLNoWildcard(GetRequestingOrigin()), | |
| 432 ContentSettingsPattern::FromURLNoWildcard(GetEmbeddingOrigin()), | |
| 433 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), | |
| 434 CONTENT_SETTING_ALLOW); | |
| 413 tab_fullscreen_accepted_ = true; | 435 tab_fullscreen_accepted_ = true; |
| 414 } | 436 } |
| 415 UpdateFullscreenExitBubbleContent(); | 437 UpdateFullscreenExitBubbleContent(); |
| 416 } | 438 } |
| 417 | 439 |
| 418 void FullscreenController::OnDenyFullscreenPermission() { | 440 void FullscreenController::OnDenyFullscreenPermission() { |
| 419 if (!fullscreened_tab_ && !mouse_lock_tab_) | 441 if (!fullscreened_tab_ && !mouse_lock_tab_) |
| 420 return; | 442 return; |
| 421 | 443 |
| 422 if (IsMouseLockRequested()) { | 444 if (IsMouseLockRequested()) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 448 const content::NotificationSource& source, | 470 const content::NotificationSource& source, |
| 449 const content::NotificationDetails& details) { | 471 const content::NotificationDetails& details) { |
| 450 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); | 472 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
| 451 if (content::Details<content::LoadCommittedDetails>(details)-> | 473 if (content::Details<content::LoadCommittedDetails>(details)-> |
| 452 is_navigation_to_different_page()) | 474 is_navigation_to_different_page()) |
| 453 ExitTabFullscreenOrMouseLockIfNecessary(); | 475 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 454 } | 476 } |
| 455 | 477 |
| 456 GURL FullscreenController::GetFullscreenExitBubbleURL() const { | 478 GURL FullscreenController::GetFullscreenExitBubbleURL() const { |
| 457 if (fullscreened_tab_) | 479 if (fullscreened_tab_) |
| 458 return fullscreened_tab_->GetURL(); | 480 return GetRequestingOrigin(); |
| 459 if (mouse_lock_tab_) | 481 if (mouse_lock_tab_) |
| 460 return mouse_lock_tab_->GetURL(); | 482 return mouse_lock_tab_->GetURL(); |
| 461 return extension_caused_fullscreen_; | 483 return extension_caused_fullscreen_; |
| 462 } | 484 } |
| 463 | 485 |
| 464 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() | 486 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() |
| 465 const { | 487 const { |
| 466 // In kiosk and exclusive app mode we always want to be fullscreen and do not | 488 // In kiosk and exclusive app mode we always want to be fullscreen and do not |
| 467 // want to show exit instructions for browser mode fullscreen. | 489 // want to show exit instructions for browser mode fullscreen. |
| 468 bool app_mode = false; | 490 bool app_mode = false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 547 |
| 526 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { | 548 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { |
| 527 content::NotificationService::current()->Notify( | 549 content::NotificationService::current()->Notify( |
| 528 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 550 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 529 content::Source<FullscreenController>(this), | 551 content::Source<FullscreenController>(this), |
| 530 content::Details<bool>(&is_fullscreen)); | 552 content::Details<bool>(&is_fullscreen)); |
| 531 } | 553 } |
| 532 | 554 |
| 533 void FullscreenController::NotifyTabOfExitIfNecessary() { | 555 void FullscreenController::NotifyTabOfExitIfNecessary() { |
| 534 if (fullscreened_tab_) { | 556 if (fullscreened_tab_) { |
| 535 RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost(); | 557 WebContents* web_contents = fullscreened_tab_; |
| 536 SetFullscreenedTab(NULL); | 558 // This call will set |fullscreened_tab_| to nullptr. |
| 559 SetFullscreenedTab(nullptr, GURL()); | |
| 537 state_prior_to_tab_fullscreen_ = STATE_INVALID; | 560 state_prior_to_tab_fullscreen_ = STATE_INVALID; |
| 538 tab_fullscreen_accepted_ = false; | 561 tab_fullscreen_accepted_ = false; |
| 539 if (rvh) | 562 web_contents->ExitFullscreen(); |
| 540 rvh->ExitFullscreen(); | |
| 541 } | 563 } |
| 542 | 564 |
| 543 if (mouse_lock_tab_) { | 565 if (mouse_lock_tab_) { |
| 544 if (IsMouseLockRequested()) { | 566 if (IsMouseLockRequested()) { |
| 545 mouse_lock_tab_->GotResponseToLockMouseRequest(false); | 567 mouse_lock_tab_->GotResponseToLockMouseRequest(false); |
| 546 NotifyMouseLockChange(); | 568 NotifyMouseLockChange(); |
| 547 } else { | 569 } else { |
| 548 UnlockMouse(); | 570 UnlockMouse(); |
| 549 } | 571 } |
| 550 SetMouseLockTab(NULL); | 572 SetMouseLockTab(NULL); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 EnterFullscreenModeInternal(option); | 625 EnterFullscreenModeInternal(option); |
| 604 else | 626 else |
| 605 ExitFullscreenModeInternal(); | 627 ExitFullscreenModeInternal(); |
| 606 } | 628 } |
| 607 | 629 |
| 608 void FullscreenController::EnterFullscreenModeInternal( | 630 void FullscreenController::EnterFullscreenModeInternal( |
| 609 FullscreenInternalOption option) { | 631 FullscreenInternalOption option) { |
| 610 toggled_into_fullscreen_ = true; | 632 toggled_into_fullscreen_ = true; |
| 611 GURL url; | 633 GURL url; |
| 612 if (option == TAB) { | 634 if (option == TAB) { |
| 613 url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL(); | 635 url = GetRequestingOrigin(); |
| 614 tab_fullscreen_accepted_ = | 636 tab_fullscreen_accepted_ = |
| 615 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 637 GetFullscreenSetting() == CONTENT_SETTING_ALLOW; |
| 616 } else { | 638 } else { |
| 617 if (!extension_caused_fullscreen_.is_empty()) | 639 if (!extension_caused_fullscreen_.is_empty()) |
| 618 url = extension_caused_fullscreen_; | 640 url = extension_caused_fullscreen_; |
| 619 } | 641 } |
| 620 | 642 |
| 621 if (option == BROWSER) | 643 if (option == BROWSER) |
| 622 content::RecordAction(UserMetricsAction("ToggleFullscreen")); | 644 content::RecordAction(UserMetricsAction("ToggleFullscreen")); |
| 623 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions | 645 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions |
| 624 // from tab fullscreen out to browser with toolbar. | 646 // from tab fullscreen out to browser with toolbar. |
| 625 | 647 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 642 // state_prior_to_tab_fullscreen_ to match them else other logic using | 664 // state_prior_to_tab_fullscreen_ to match them else other logic using |
| 643 // state_prior_to_tab_fullscreen_ will be incorrect. | 665 // state_prior_to_tab_fullscreen_ will be incorrect. |
| 644 NotifyTabOfExitIfNecessary(); | 666 NotifyTabOfExitIfNecessary(); |
| 645 #endif | 667 #endif |
| 646 window_->ExitFullscreen(); | 668 window_->ExitFullscreen(); |
| 647 extension_caused_fullscreen_ = GURL(); | 669 extension_caused_fullscreen_ = GURL(); |
| 648 | 670 |
| 649 UpdateFullscreenExitBubbleContent(); | 671 UpdateFullscreenExitBubbleContent(); |
| 650 } | 672 } |
| 651 | 673 |
| 652 void FullscreenController::SetFullscreenedTab(WebContents* tab) { | 674 void FullscreenController::SetFullscreenedTab(WebContents* tab, |
| 675 const GURL& origin) { | |
| 653 fullscreened_tab_ = tab; | 676 fullscreened_tab_ = tab; |
| 677 fullscreened_origin_ = origin; | |
| 654 UpdateNotificationRegistrations(); | 678 UpdateNotificationRegistrations(); |
| 655 } | 679 } |
| 656 | 680 |
| 657 void FullscreenController::SetMouseLockTab(WebContents* tab) { | 681 void FullscreenController::SetMouseLockTab(WebContents* tab) { |
| 658 mouse_lock_tab_ = tab; | 682 mouse_lock_tab_ = tab; |
| 659 UpdateNotificationRegistrations(); | 683 UpdateNotificationRegistrations(); |
| 660 } | 684 } |
| 661 | 685 |
| 662 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { | 686 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { |
| 663 if (IsWindowFullscreenForTabOrPending()) | 687 if (IsWindowFullscreenForTabOrPending()) |
| 664 ToggleFullscreenModeForTab(fullscreened_tab_, false); | 688 ExitFullscreenModeForTab(fullscreened_tab_); |
| 665 else | 689 else |
| 666 NotifyTabOfExitIfNecessary(); | 690 NotifyTabOfExitIfNecessary(); |
| 667 } | 691 } |
| 668 | 692 |
| 669 void FullscreenController::UpdateFullscreenExitBubbleContent() { | 693 void FullscreenController::UpdateFullscreenExitBubbleContent() { |
| 670 GURL url = GetFullscreenExitBubbleURL(); | 694 GURL url = GetFullscreenExitBubbleURL(); |
| 671 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 695 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
| 672 | 696 |
| 673 // If bubble displays buttons, unlock mouse to allow pressing them. | 697 // If bubble displays buttons, unlock mouse to allow pressing them. |
| 674 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && IsMouseLocked()) | 698 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && IsMouseLocked()) |
| 675 UnlockMouse(); | 699 UnlockMouse(); |
| 676 | 700 |
| 677 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); | 701 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); |
| 678 } | 702 } |
| 679 | 703 |
| 680 ContentSetting | 704 ContentSetting |
| 681 FullscreenController::GetFullscreenSetting(const GURL& url) const { | 705 FullscreenController::GetFullscreenSetting() const { |
| 706 DCHECK(fullscreened_tab_); | |
| 707 | |
| 708 GURL url = GetRequestingOrigin(); | |
| 709 | |
| 682 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) | 710 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) |
| 683 return CONTENT_SETTING_ALLOW; | 711 return CONTENT_SETTING_ALLOW; |
| 684 | 712 |
| 685 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url, | 713 // See the comment above the call to |SetContentSetting()| for how the |
| 686 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | 714 // requesting and embedding origins interact with each other wrt permissions. |
| 715 return profile_->GetHostContentSettingsMap()->GetContentSetting( | |
| 716 url, | |
| 717 GetEmbeddingOrigin(), | |
| 718 CONTENT_SETTINGS_TYPE_FULLSCREEN, | |
| 719 std::string()); | |
| 687 } | 720 } |
| 688 | 721 |
| 689 ContentSetting | 722 ContentSetting |
| 690 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 723 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
| 691 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) | 724 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) |
| 692 return CONTENT_SETTING_ALLOW; | 725 return CONTENT_SETTING_ALLOW; |
| 693 | 726 |
| 694 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 727 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
| 695 return settings_map->GetContentSetting(url, url, | 728 return settings_map->GetContentSetting(url, url, |
| 696 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 729 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? | 780 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? |
| 748 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; | 781 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; |
| 749 if (!mouse_lock_view) { | 782 if (!mouse_lock_view) { |
| 750 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); | 783 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); |
| 751 if (rvh) | 784 if (rvh) |
| 752 mouse_lock_view = rvh->GetView(); | 785 mouse_lock_view = rvh->GetView(); |
| 753 } | 786 } |
| 754 if (mouse_lock_view) | 787 if (mouse_lock_view) |
| 755 mouse_lock_view->UnlockMouse(); | 788 mouse_lock_view->UnlockMouse(); |
| 756 } | 789 } |
| 790 | |
| 791 GURL FullscreenController::GetRequestingOrigin() const { | |
| 792 DCHECK(fullscreened_tab_); | |
| 793 | |
| 794 if (!fullscreened_origin_.is_empty()) | |
| 795 return fullscreened_origin_; | |
| 796 | |
| 797 return fullscreened_tab_->GetLastCommittedURL(); | |
| 798 } | |
| 799 | |
| 800 GURL FullscreenController::GetEmbeddingOrigin() const { | |
| 801 DCHECK(fullscreened_tab_); | |
| 802 | |
| 803 return fullscreened_tab_->GetLastCommittedURL(); | |
| 804 } | |
| OLD | NEW |