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 if (!tab_fullscreen_accepted_) { | |
| 142 tab_fullscreen_accepted_ = | |
| 143 GetFullscreenSetting() == CONTENT_SETTING_ALLOW; | |
| 144 } | |
| 145 UpdateFullscreenExitBubbleContent(); | |
| 146 | |
| 147 // This is only a change between Browser and Tab fullscreen. We generate | |
| 148 // a fullscreen notification now because there is no window change. | |
| 149 PostFullscreenChangeNotification(true); | |
| 150 } | |
| 151 | |
| 152 void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) { | |
| 153 if (MaybeToggleFullscreenForCapturedTab(web_contents, false)) { | |
| 154 // During tab capture of fullscreen-within-tab views, the browser window | |
| 155 // fullscreen state is unchanged, so return now. | |
| 156 return; | |
| 157 } | |
| 158 | |
| 159 if (web_contents != fullscreened_tab_ || | |
| 160 web_contents != browser_->tab_strip_model()->GetActiveWebContents() || | |
| 161 !IsWindowFullscreenForTabOrPending()) { | |
| 162 return; | |
| 163 } | |
| 164 | |
| 165 #if defined(OS_WIN) | |
| 166 // For now, avoid breaking when initiating full screen tab mode while in | |
| 118 // a metro snap. | 167 // a metro snap. |
| 119 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | 168 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen |
| 120 // modes with metro snap. | 169 // modes with metro snap. |
| 121 if (IsInMetroSnapMode()) | 170 if (IsInMetroSnapMode()) |
| 122 return; | 171 return; |
| 123 #endif | 172 #endif |
| 124 | 173 |
| 125 bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); | 174 if (!window_->IsFullscreen()) |
| 175 return; | |
| 126 | 176 |
| 127 if (enter_fullscreen) { | 177 if (IsFullscreenCausedByTab()) { |
| 128 SetFullscreenedTab(web_contents); | 178 // Tab Fullscreen -> Normal. |
| 129 if (!in_browser_or_tab_fullscreen_mode) { | 179 ToggleFullscreenModeInternal(TAB); |
| 130 // Normal -> Tab Fullscreen. | 180 return; |
| 131 state_prior_to_tab_fullscreen_ = STATE_NORMAL; | 181 } |
| 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 | 182 |
| 143 // We need to update the fullscreen exit bubble, e.g., going from browser | 183 // Tab Fullscreen -> Browser Fullscreen (with or without toolbar). |
|
Charlie Reis
2014/12/10 19:22:56
nit: Please preserve this comment.
mlamouri (slow - plz ping)
2014/12/11 16:03:19
Done.
| |
| 144 // fullscreen to tab fullscreen will need to show different content. | 184 if (state_prior_to_tab_fullscreen_ == |
| 145 const GURL& url = web_contents->GetURL(); | 185 STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { |
| 146 if (!tab_fullscreen_accepted_) { | 186 // Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. |
| 147 tab_fullscreen_accepted_ = | 187 window_->UpdateFullscreenWithToolbar(true); |
| 148 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 188 } |
| 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 | 189 |
| 169 #if defined(OS_MACOSX) | 190 #if defined(OS_MACOSX) |
| 170 // Clear the bubble URL, which forces the Mac UI to redraw. | 191 // Clear the bubble URL, which forces the Mac UI to redraw. |
| 171 UpdateFullscreenExitBubbleContent(); | 192 UpdateFullscreenExitBubbleContent(); |
| 172 #endif // defined(OS_MACOSX) | 193 #endif // defined(OS_MACOSX) |
| 173 | 194 |
| 174 // If currently there is a tab in "tab fullscreen" mode and fullscreen | 195 // 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" | 196 // 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 | 197 // 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 | 198 // case, all we have to do is notifying the tab that it has exited "tab |
| 178 // fullscreen" mode. | 199 // fullscreen" mode. |
| 179 NotifyTabOfExitIfNecessary(); | 200 NotifyTabOfExitIfNecessary(); |
| 180 | 201 |
| 181 // This is only a change between Browser and Tab fullscreen. We generate | 202 // This is only a change between Browser and Tab fullscreen. We generate |
| 182 // a fullscreen notification now because there is no window change. | 203 // a fullscreen notification now because there is no window change. |
| 183 PostFullscreenChangeNotification(true); | 204 PostFullscreenChangeNotification(true); |
| 184 } | |
| 185 } | |
| 186 } | |
| 187 } | 205 } |
| 188 | 206 |
| 189 bool FullscreenController::IsInMetroSnapMode() { | 207 bool FullscreenController::IsInMetroSnapMode() { |
| 190 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
| 191 return window_->IsInMetroSnapMode(); | 209 return window_->IsInMetroSnapMode(); |
| 192 #else | 210 #else |
| 193 return false; | 211 return false; |
| 194 #endif | 212 #endif |
| 195 } | 213 } |
| 196 | 214 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 320 |
| 303 content::RenderWidgetHostView* const current_fs_view = | 321 content::RenderWidgetHostView* const current_fs_view = |
| 304 old_contents->GetFullscreenRenderWidgetHostView(); | 322 old_contents->GetFullscreenRenderWidgetHostView(); |
| 305 if (current_fs_view) | 323 if (current_fs_view) |
| 306 current_fs_view->SetSize(old_contents->GetPreferredSize()); | 324 current_fs_view->SetSize(old_contents->GetPreferredSize()); |
| 307 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); | 325 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); |
| 308 } | 326 } |
| 309 | 327 |
| 310 void FullscreenController::OnTabClosing(WebContents* web_contents) { | 328 void FullscreenController::OnTabClosing(WebContents* web_contents) { |
| 311 if (IsFullscreenForCapturedTab(web_contents)) { | 329 if (IsFullscreenForCapturedTab(web_contents)) { |
| 312 RenderViewHost* const rvh = web_contents->GetRenderViewHost(); | 330 web_contents->ExitFullscreen(); |
| 313 if (rvh) | |
| 314 rvh->ExitFullscreen(); | |
| 315 } else if (web_contents == fullscreened_tab_ || | 331 } else if (web_contents == fullscreened_tab_ || |
| 316 web_contents == mouse_lock_tab_) { | 332 web_contents == mouse_lock_tab_) { |
| 317 ExitTabFullscreenOrMouseLockIfNecessary(); | 333 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 318 // The call to exit fullscreen may result in asynchronous notification of | 334 // 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 | 335 // fullscreen state change (e.g., on Linux). We don't want to rely on it |
| 320 // to call NotifyTabOfExitIfNecessary(), because at that point | 336 // to call NotifyTabOfExitIfNecessary(), because at that point |
| 321 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean | 337 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean |
| 322 // up tab fullscreen related state. | 338 // up tab fullscreen related state. |
| 323 NotifyTabOfExitIfNecessary(); | 339 NotifyTabOfExitIfNecessary(); |
| 324 } | 340 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 341 window_->GetDownloadShelf()->Hide(); | 357 window_->GetDownloadShelf()->Hide(); |
| 342 if (window_->GetStatusBubble()) | 358 if (window_->GetStatusBubble()) |
| 343 window_->GetStatusBubble()->Hide(); | 359 window_->GetStatusBubble()->Hide(); |
| 344 } | 360 } |
| 345 } | 361 } |
| 346 | 362 |
| 347 bool FullscreenController::HandleUserPressedEscape() { | 363 bool FullscreenController::HandleUserPressedEscape() { |
| 348 WebContents* const active_web_contents = | 364 WebContents* const active_web_contents = |
| 349 browser_->tab_strip_model()->GetActiveWebContents(); | 365 browser_->tab_strip_model()->GetActiveWebContents(); |
| 350 if (IsFullscreenForCapturedTab(active_web_contents)) { | 366 if (IsFullscreenForCapturedTab(active_web_contents)) { |
| 351 RenderViewHost* const rvh = active_web_contents->GetRenderViewHost(); | 367 active_web_contents->ExitFullscreen(); |
| 352 if (rvh) | |
| 353 rvh->ExitFullscreen(); | |
| 354 return true; | 368 return true; |
| 355 } else if (IsWindowFullscreenForTabOrPending() || | 369 } else if (IsWindowFullscreenForTabOrPending() || |
| 356 IsMouseLocked() || IsMouseLockRequested()) { | 370 IsMouseLocked() || IsMouseLockRequested()) { |
| 357 ExitTabFullscreenOrMouseLockIfNecessary(); | 371 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 358 return true; | 372 return true; |
| 359 } | 373 } |
| 360 | 374 |
| 361 return false; | 375 return false; |
| 362 } | 376 } |
| 363 | 377 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 } else { | 412 } else { |
| 399 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 413 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| 400 SetMouseLockTab(NULL); | 414 SetMouseLockTab(NULL); |
| 401 } | 415 } |
| 402 NotifyMouseLockChange(); | 416 NotifyMouseLockChange(); |
| 403 } | 417 } |
| 404 | 418 |
| 405 if (fullscreen && !tab_fullscreen_accepted_) { | 419 if (fullscreen && !tab_fullscreen_accepted_) { |
| 406 DCHECK(fullscreened_tab_); | 420 DCHECK(fullscreened_tab_); |
| 407 if (pattern.IsValid()) { | 421 if (pattern.IsValid()) { |
| 408 settings_map->SetContentSetting( | 422 settings_map->SetContentSetting( |
|
scheib
2014/12/10 21:36:30
Should be updated to match GetContentSetting?
mlamouri (slow - plz ping)
2014/12/11 16:03:19
Oh! Good catch. I really thought I updated that. I
| |
| 409 pattern, ContentSettingsPattern::Wildcard(), | 423 pattern, ContentSettingsPattern::Wildcard(), |
| 410 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), | 424 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), |
| 411 CONTENT_SETTING_ALLOW); | 425 CONTENT_SETTING_ALLOW); |
| 412 } | 426 } |
| 413 tab_fullscreen_accepted_ = true; | 427 tab_fullscreen_accepted_ = true; |
| 414 } | 428 } |
| 415 UpdateFullscreenExitBubbleContent(); | 429 UpdateFullscreenExitBubbleContent(); |
| 416 } | 430 } |
| 417 | 431 |
| 418 void FullscreenController::OnDenyFullscreenPermission() { | 432 void FullscreenController::OnDenyFullscreenPermission() { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 448 const content::NotificationSource& source, | 462 const content::NotificationSource& source, |
| 449 const content::NotificationDetails& details) { | 463 const content::NotificationDetails& details) { |
| 450 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); | 464 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
| 451 if (content::Details<content::LoadCommittedDetails>(details)-> | 465 if (content::Details<content::LoadCommittedDetails>(details)-> |
| 452 is_navigation_to_different_page()) | 466 is_navigation_to_different_page()) |
| 453 ExitTabFullscreenOrMouseLockIfNecessary(); | 467 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 454 } | 468 } |
| 455 | 469 |
| 456 GURL FullscreenController::GetFullscreenExitBubbleURL() const { | 470 GURL FullscreenController::GetFullscreenExitBubbleURL() const { |
| 457 if (fullscreened_tab_) | 471 if (fullscreened_tab_) |
| 458 return fullscreened_tab_->GetURL(); | 472 return GetRequestingOrigin(); |
| 459 if (mouse_lock_tab_) | 473 if (mouse_lock_tab_) |
| 460 return mouse_lock_tab_->GetURL(); | 474 return mouse_lock_tab_->GetURL(); |
| 461 return extension_caused_fullscreen_; | 475 return extension_caused_fullscreen_; |
| 462 } | 476 } |
| 463 | 477 |
| 464 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() | 478 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() |
| 465 const { | 479 const { |
| 466 // In kiosk and exclusive app mode we always want to be fullscreen and do not | 480 // 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. | 481 // want to show exit instructions for browser mode fullscreen. |
| 468 bool app_mode = false; | 482 bool app_mode = false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 539 |
| 526 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { | 540 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { |
| 527 content::NotificationService::current()->Notify( | 541 content::NotificationService::current()->Notify( |
| 528 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 542 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 529 content::Source<FullscreenController>(this), | 543 content::Source<FullscreenController>(this), |
| 530 content::Details<bool>(&is_fullscreen)); | 544 content::Details<bool>(&is_fullscreen)); |
| 531 } | 545 } |
| 532 | 546 |
| 533 void FullscreenController::NotifyTabOfExitIfNecessary() { | 547 void FullscreenController::NotifyTabOfExitIfNecessary() { |
| 534 if (fullscreened_tab_) { | 548 if (fullscreened_tab_) { |
| 535 RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost(); | 549 WebContents* web_contents = fullscreened_tab_; |
| 536 SetFullscreenedTab(NULL); | 550 // This call will set |fullscreened_tab_| to nullptr. |
| 551 SetFullscreenedTab(nullptr, GURL()); | |
| 537 state_prior_to_tab_fullscreen_ = STATE_INVALID; | 552 state_prior_to_tab_fullscreen_ = STATE_INVALID; |
| 538 tab_fullscreen_accepted_ = false; | 553 tab_fullscreen_accepted_ = false; |
| 539 if (rvh) | 554 web_contents->ExitFullscreen(); |
| 540 rvh->ExitFullscreen(); | |
| 541 } | 555 } |
| 542 | 556 |
| 543 if (mouse_lock_tab_) { | 557 if (mouse_lock_tab_) { |
| 544 if (IsMouseLockRequested()) { | 558 if (IsMouseLockRequested()) { |
| 545 mouse_lock_tab_->GotResponseToLockMouseRequest(false); | 559 mouse_lock_tab_->GotResponseToLockMouseRequest(false); |
| 546 NotifyMouseLockChange(); | 560 NotifyMouseLockChange(); |
| 547 } else { | 561 } else { |
| 548 UnlockMouse(); | 562 UnlockMouse(); |
| 549 } | 563 } |
| 550 SetMouseLockTab(NULL); | 564 SetMouseLockTab(NULL); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 EnterFullscreenModeInternal(option); | 617 EnterFullscreenModeInternal(option); |
| 604 else | 618 else |
| 605 ExitFullscreenModeInternal(); | 619 ExitFullscreenModeInternal(); |
| 606 } | 620 } |
| 607 | 621 |
| 608 void FullscreenController::EnterFullscreenModeInternal( | 622 void FullscreenController::EnterFullscreenModeInternal( |
| 609 FullscreenInternalOption option) { | 623 FullscreenInternalOption option) { |
| 610 toggled_into_fullscreen_ = true; | 624 toggled_into_fullscreen_ = true; |
| 611 GURL url; | 625 GURL url; |
| 612 if (option == TAB) { | 626 if (option == TAB) { |
| 613 url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL(); | 627 url = GetRequestingOrigin(); |
| 614 tab_fullscreen_accepted_ = | 628 tab_fullscreen_accepted_ = |
| 615 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 629 GetFullscreenSetting() == CONTENT_SETTING_ALLOW; |
| 616 } else { | 630 } else { |
| 617 if (!extension_caused_fullscreen_.is_empty()) | 631 if (!extension_caused_fullscreen_.is_empty()) |
| 618 url = extension_caused_fullscreen_; | 632 url = extension_caused_fullscreen_; |
| 619 } | 633 } |
| 620 | 634 |
| 621 if (option == BROWSER) | 635 if (option == BROWSER) |
| 622 content::RecordAction(UserMetricsAction("ToggleFullscreen")); | 636 content::RecordAction(UserMetricsAction("ToggleFullscreen")); |
| 623 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions | 637 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions |
| 624 // from tab fullscreen out to browser with toolbar. | 638 // from tab fullscreen out to browser with toolbar. |
| 625 | 639 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 642 // state_prior_to_tab_fullscreen_ to match them else other logic using | 656 // state_prior_to_tab_fullscreen_ to match them else other logic using |
| 643 // state_prior_to_tab_fullscreen_ will be incorrect. | 657 // state_prior_to_tab_fullscreen_ will be incorrect. |
| 644 NotifyTabOfExitIfNecessary(); | 658 NotifyTabOfExitIfNecessary(); |
| 645 #endif | 659 #endif |
| 646 window_->ExitFullscreen(); | 660 window_->ExitFullscreen(); |
| 647 extension_caused_fullscreen_ = GURL(); | 661 extension_caused_fullscreen_ = GURL(); |
| 648 | 662 |
| 649 UpdateFullscreenExitBubbleContent(); | 663 UpdateFullscreenExitBubbleContent(); |
| 650 } | 664 } |
| 651 | 665 |
| 652 void FullscreenController::SetFullscreenedTab(WebContents* tab) { | 666 void FullscreenController::SetFullscreenedTab(WebContents* tab, |
| 667 const GURL& origin) { | |
| 653 fullscreened_tab_ = tab; | 668 fullscreened_tab_ = tab; |
| 669 fullscreened_origin_ = origin; | |
| 654 UpdateNotificationRegistrations(); | 670 UpdateNotificationRegistrations(); |
| 655 } | 671 } |
| 656 | 672 |
| 657 void FullscreenController::SetMouseLockTab(WebContents* tab) { | 673 void FullscreenController::SetMouseLockTab(WebContents* tab) { |
| 658 mouse_lock_tab_ = tab; | 674 mouse_lock_tab_ = tab; |
| 659 UpdateNotificationRegistrations(); | 675 UpdateNotificationRegistrations(); |
| 660 } | 676 } |
| 661 | 677 |
| 662 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { | 678 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { |
| 663 if (IsWindowFullscreenForTabOrPending()) | 679 if (IsWindowFullscreenForTabOrPending()) |
| 664 ToggleFullscreenModeForTab(fullscreened_tab_, false); | 680 ExitFullscreenModeForTab(fullscreened_tab_); |
| 665 else | 681 else |
| 666 NotifyTabOfExitIfNecessary(); | 682 NotifyTabOfExitIfNecessary(); |
| 667 } | 683 } |
| 668 | 684 |
| 669 void FullscreenController::UpdateFullscreenExitBubbleContent() { | 685 void FullscreenController::UpdateFullscreenExitBubbleContent() { |
| 670 GURL url = GetFullscreenExitBubbleURL(); | 686 GURL url = GetFullscreenExitBubbleURL(); |
| 671 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 687 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
| 672 | 688 |
| 673 // If bubble displays buttons, unlock mouse to allow pressing them. | 689 // If bubble displays buttons, unlock mouse to allow pressing them. |
| 674 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && IsMouseLocked()) | 690 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && IsMouseLocked()) |
| 675 UnlockMouse(); | 691 UnlockMouse(); |
| 676 | 692 |
| 677 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); | 693 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); |
| 678 } | 694 } |
| 679 | 695 |
| 680 ContentSetting | 696 ContentSetting |
| 681 FullscreenController::GetFullscreenSetting(const GURL& url) const { | 697 FullscreenController::GetFullscreenSetting() const { |
| 698 DCHECK(fullscreened_tab_); | |
| 699 | |
| 700 GURL url = GetRequestingOrigin(); | |
| 701 | |
| 682 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) | 702 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) |
| 683 return CONTENT_SETTING_ALLOW; | 703 return CONTENT_SETTING_ALLOW; |
| 684 | 704 |
| 685 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url, | 705 return profile_->GetHostContentSettingsMap()->GetContentSetting( |
| 686 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | 706 url, |
| 707 GetEmbeddingOrigin(), | |
|
scheib
2014/12/10 21:36:30
GetContentSetting documentation could be clearer h
mlamouri (slow - plz ping)
2014/12/11 16:03:19
I'm using PermissionContextBase (chrome/browser/co
| |
| 708 CONTENT_SETTINGS_TYPE_FULLSCREEN, | |
| 709 std::string()); | |
| 687 } | 710 } |
| 688 | 711 |
| 689 ContentSetting | 712 ContentSetting |
| 690 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 713 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
| 691 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) | 714 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) |
| 692 return CONTENT_SETTING_ALLOW; | 715 return CONTENT_SETTING_ALLOW; |
| 693 | 716 |
| 694 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 717 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
| 695 return settings_map->GetContentSetting(url, url, | 718 return settings_map->GetContentSetting(url, url, |
| 696 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 719 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()) ? | 770 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? |
| 748 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; | 771 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; |
| 749 if (!mouse_lock_view) { | 772 if (!mouse_lock_view) { |
| 750 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); | 773 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); |
| 751 if (rvh) | 774 if (rvh) |
| 752 mouse_lock_view = rvh->GetView(); | 775 mouse_lock_view = rvh->GetView(); |
| 753 } | 776 } |
| 754 if (mouse_lock_view) | 777 if (mouse_lock_view) |
| 755 mouse_lock_view->UnlockMouse(); | 778 mouse_lock_view->UnlockMouse(); |
| 756 } | 779 } |
| 780 | |
| 781 GURL FullscreenController::GetRequestingOrigin() const { | |
| 782 DCHECK(fullscreened_tab_); | |
| 783 | |
| 784 if (!fullscreened_origin_.is_empty()) | |
| 785 return fullscreened_origin_; | |
| 786 | |
| 787 return fullscreened_tab_->GetLastCommittedURL(); | |
| 788 } | |
| 789 | |
| 790 GURL FullscreenController::GetEmbeddingOrigin() const { | |
| 791 DCHECK(fullscreened_tab_); | |
| 792 | |
| 793 return fullscreened_tab_->GetLastCommittedURL(); | |
| 794 } | |
| OLD | NEW |