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

Side by Side Diff: chrome/browser/ui/exclusive_access/fullscreen_controller.cc

Issue 1488653002: Fix scroll restoration when exiting fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from avi@ Created 4 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 unified diff | Download patch
OLDNEW
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/exclusive_access/fullscreen_controller.h" 5 #include "chrome/browser/ui/exclusive_access/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/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 content::RenderWidgetHostView* const current_fs_view = 267 content::RenderWidgetHostView* const current_fs_view =
268 old_contents->GetFullscreenRenderWidgetHostView(); 268 old_contents->GetFullscreenRenderWidgetHostView();
269 if (current_fs_view) 269 if (current_fs_view)
270 current_fs_view->SetSize(old_contents->GetPreferredSize()); 270 current_fs_view->SetSize(old_contents->GetPreferredSize());
271 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); 271 ResizeWebContents(old_contents, old_contents->GetPreferredSize());
272 } 272 }
273 273
274 void FullscreenController::OnTabClosing(WebContents* web_contents) { 274 void FullscreenController::OnTabClosing(WebContents* web_contents) {
275 if (IsFullscreenForCapturedTab(web_contents)) { 275 if (IsFullscreenForCapturedTab(web_contents)) {
276 web_contents->ExitFullscreen(); 276 bool will_cause_resize = IsFullscreenCausedByTab();
277 web_contents->ExitFullscreen(will_cause_resize);
Peter Kasting 2016/01/05 20:34:26 Nit: Inline: web_contents->ExitFullscreen(IsF
bokan 2016/01/06 17:48:32 Using the local was actually suggested by scheib@
Peter Kasting 2016/01/06 20:00:28 Readers who don't already know what ExitFullscreen
scheib 2016/01/06 21:21:01 A compromise could be web_contents->ExitFulls
Peter Kasting 2016/01/06 21:26:04 All programmers should have an easy and near-insta
bokan 2016/01/06 21:40:57 I'm personally one such person who doesn't have th
Peter Kasting 2016/01/06 21:56:41 Why? You don't have Chromium codesearch bookmarke
scheib 2016/01/06 22:06:56 I don't think we should spend much time debating.
277 } else { 278 } else {
278 ExclusiveAccessControllerBase::OnTabClosing(web_contents); 279 ExclusiveAccessControllerBase::OnTabClosing(web_contents);
279 } 280 }
280 } 281 }
281 282
282 void FullscreenController::WindowFullscreenStateChanged() { 283 void FullscreenController::WindowFullscreenStateChanged() {
283 reentrant_window_state_change_call_check_ = true; 284 reentrant_window_state_change_call_check_ = true;
284 ExclusiveAccessContext* const exclusive_access_context = 285 ExclusiveAccessContext* const exclusive_access_context =
285 exclusive_access_manager()->context(); 286 exclusive_access_manager()->context();
286 bool exiting_fullscreen = !exclusive_access_context->IsFullscreen(); 287 bool exiting_fullscreen = !exclusive_access_context->IsFullscreen();
287 288
288 PostFullscreenChangeNotification(!exiting_fullscreen); 289 PostFullscreenChangeNotification(!exiting_fullscreen);
289 if (exiting_fullscreen) { 290 if (exiting_fullscreen) {
290 toggled_into_fullscreen_ = false; 291 toggled_into_fullscreen_ = false;
291 extension_caused_fullscreen_ = GURL(); 292 extension_caused_fullscreen_ = GURL();
292 NotifyTabExclusiveAccessLost(); 293 NotifyTabExclusiveAccessLost();
293 exclusive_access_context->UnhideDownloadShelf(); 294 exclusive_access_context->UnhideDownloadShelf();
294 } else { 295 } else {
295 exclusive_access_context->HideDownloadShelf(); 296 exclusive_access_context->HideDownloadShelf();
296 } 297 }
297 } 298 }
298 299
299 bool FullscreenController::HandleUserPressedEscape() { 300 bool FullscreenController::HandleUserPressedEscape() {
300 WebContents* const active_web_contents = 301 WebContents* const active_web_contents =
301 exclusive_access_manager()->context()->GetActiveWebContents(); 302 exclusive_access_manager()->context()->GetActiveWebContents();
302 if (IsFullscreenForCapturedTab(active_web_contents)) { 303 if (IsFullscreenForCapturedTab(active_web_contents)) {
303 active_web_contents->ExitFullscreen(); 304 bool will_cause_resize = IsFullscreenCausedByTab();
305 active_web_contents->ExitFullscreen(will_cause_resize);
Peter Kasting 2016/01/05 20:34:26 Nit: Inline as above.
304 return true; 306 return true;
305 } else if (IsWindowFullscreenForTabOrPending()) { 307 } else if (IsWindowFullscreenForTabOrPending()) {
Peter Kasting 2016/01/05 20:34:26 Nit: No "else" after "return". Can reverse this c
bokan 2016/01/06 17:48:32 Done.
306 ExitExclusiveAccessIfNecessary(); 308 ExitExclusiveAccessIfNecessary();
307 return true; 309 return true;
308 } 310 }
309 311
310 return false; 312 return false;
311 } 313 }
312 314
313 void FullscreenController::ExitExclusiveAccessToPreviousState() { 315 void FullscreenController::ExitExclusiveAccessToPreviousState() {
314 if (IsWindowFullscreenForTabOrPending()) 316 if (IsWindowFullscreenForTabOrPending())
315 ExitFullscreenModeForTab(exclusive_access_tab()); 317 ExitFullscreenModeForTab(exclusive_access_tab());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 404 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
403 content::Source<FullscreenController>(this), 405 content::Source<FullscreenController>(this),
404 content::Details<bool>(&is_fullscreen)); 406 content::Details<bool>(&is_fullscreen));
405 } 407 }
406 408
407 void FullscreenController::NotifyTabExclusiveAccessLost() { 409 void FullscreenController::NotifyTabExclusiveAccessLost() {
408 if (exclusive_access_tab()) { 410 if (exclusive_access_tab()) {
409 WebContents* web_contents = exclusive_access_tab(); 411 WebContents* web_contents = exclusive_access_tab();
410 SetTabWithExclusiveAccess(nullptr); 412 SetTabWithExclusiveAccess(nullptr);
411 fullscreened_origin_ = GURL(); 413 fullscreened_origin_ = GURL();
414 bool will_cause_resize = IsFullscreenCausedByTab();
412 state_prior_to_tab_fullscreen_ = STATE_INVALID; 415 state_prior_to_tab_fullscreen_ = STATE_INVALID;
413 tab_fullscreen_accepted_ = false; 416 tab_fullscreen_accepted_ = false;
414 web_contents->ExitFullscreen(); 417 web_contents->ExitFullscreen(will_cause_resize);
Peter Kasting 2016/01/05 20:34:26 Nit: Inline as above.
415 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); 418 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
416 } 419 }
417 } 420 }
418 421
419 void FullscreenController::ToggleFullscreenModeInternal( 422 void FullscreenController::ToggleFullscreenModeInternal(
420 FullscreenInternalOption option) { 423 FullscreenInternalOption option) {
421 #if defined(OS_WIN) 424 #if defined(OS_WIN)
422 // When in Metro snap mode, toggling in and out of fullscreen is prevented. 425 // When in Metro snap mode, toggling in and out of fullscreen is prevented.
423 if (IsInMetroSnapMode()) 426 if (IsInMetroSnapMode())
424 return; 427 return;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 return fullscreened_origin_; 600 return fullscreened_origin_;
598 601
599 return exclusive_access_tab()->GetLastCommittedURL(); 602 return exclusive_access_tab()->GetLastCommittedURL();
600 } 603 }
601 604
602 GURL FullscreenController::GetEmbeddingOrigin() const { 605 GURL FullscreenController::GetEmbeddingOrigin() const {
603 DCHECK(exclusive_access_tab()); 606 DCHECK(exclusive_access_tab());
604 607
605 return exclusive_access_tab()->GetLastCommittedURL(); 608 return exclusive_access_tab()->GetLastCommittedURL();
606 } 609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698