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

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

Issue 98523003: Implement "presentation" feature for window.open() Base URL: https://github.com/drott/cameo.git@presentationWindowSquashed
Patch Set: Created 7 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 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/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 29 matching lines...) Expand all
40 40
41 FullscreenController::FullscreenController(Browser* browser) 41 FullscreenController::FullscreenController(Browser* browser)
42 : browser_(browser), 42 : browser_(browser),
43 window_(browser->window()), 43 window_(browser->window()),
44 profile_(browser->profile()), 44 profile_(browser->profile()),
45 fullscreened_tab_(NULL), 45 fullscreened_tab_(NULL),
46 state_prior_to_tab_fullscreen_(STATE_INVALID), 46 state_prior_to_tab_fullscreen_(STATE_INVALID),
47 tab_fullscreen_accepted_(false), 47 tab_fullscreen_accepted_(false),
48 toggled_into_fullscreen_(false), 48 toggled_into_fullscreen_(false),
49 mouse_lock_tab_(NULL), 49 mouse_lock_tab_(NULL),
50 is_presentation_browser_fullscreen(false),
50 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), 51 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED),
51 reentrant_window_state_change_call_check_(false), 52 reentrant_window_state_change_call_check_(false),
52 is_privileged_fullscreen_for_testing_(false), 53 is_privileged_fullscreen_for_testing_(false),
53 ptr_factory_(this) { 54 ptr_factory_(this) {
54 DCHECK(window_); 55 DCHECK(window_);
55 DCHECK(profile_); 56 DCHECK(profile_);
56 } 57 }
57 58
58 FullscreenController::~FullscreenController() { 59 FullscreenController::~FullscreenController() {
59 } 60 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 NotifyTabOfExitIfNecessary(); 161 NotifyTabOfExitIfNecessary();
161 162
162 // This is only a change between Browser and Tab fullscreen. We generate 163 // This is only a change between Browser and Tab fullscreen. We generate
163 // a fullscreen notification now because there is no window change. 164 // a fullscreen notification now because there is no window change.
164 PostFullscreenChangeNotification(true); 165 PostFullscreenChangeNotification(true);
165 } 166 }
166 } 167 }
167 } 168 }
168 } 169 }
169 170
171 void FullscreenController::TogglePresentationMode() {
172 extension_caused_fullscreen_ = GURL();
173 ToggleFullscreenModeInternal(PRESENTATION);
174 }
175
176 bool FullscreenController::IsPresentationFullscreen() {
177 return is_presentation_browser_fullscreen;
178 }
179
170 void FullscreenController::ToggleFullscreenModeWithExtension( 180 void FullscreenController::ToggleFullscreenModeWithExtension(
171 const GURL& extension_url) { 181 const GURL& extension_url) {
172 // |extension_caused_fullscreen_| will be reset if this causes fullscreen to 182 // |extension_caused_fullscreen_| will be reset if this causes fullscreen to
173 // exit. 183 // exit.
174 extension_caused_fullscreen_ = extension_url; 184 extension_caused_fullscreen_ = extension_url;
175 ToggleFullscreenModeInternal(BROWSER); 185 ToggleFullscreenModeInternal(BROWSER);
176 } 186 }
177 187
178 bool FullscreenController::IsInMetroSnapMode() { 188 bool FullscreenController::IsInMetroSnapMode() {
179 #if defined(OS_WIN) 189 #if defined(OS_WIN)
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 315 }
306 } 316 }
307 317
308 bool FullscreenController::HandleUserPressedEscape() { 318 bool FullscreenController::HandleUserPressedEscape() {
309 if (IsFullscreenForTabOrPending() || 319 if (IsFullscreenForTabOrPending() ||
310 IsMouseLocked() || IsMouseLockRequested()) { 320 IsMouseLocked() || IsMouseLockRequested()) {
311 ExitTabFullscreenOrMouseLockIfNecessary(); 321 ExitTabFullscreenOrMouseLockIfNecessary();
312 return true; 322 return true;
313 } 323 }
314 324
325 if (IsPresentationFullscreen()) {
326 ExitFullscreenModeInternal();
327 return true;
328 }
329
315 return false; 330 return false;
316 } 331 }
317 332
318 void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() { 333 void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() {
319 if (IsFullscreenForTabOrPending()) 334 if (IsFullscreenForTabOrPending())
320 ExitTabFullscreenOrMouseLockIfNecessary(); 335 ExitTabFullscreenOrMouseLockIfNecessary();
321 else if (IsFullscreenForBrowser()) 336 else if (IsFullscreenForBrowser())
322 ExitFullscreenModeInternal(); 337 ExitFullscreenModeInternal();
323 } 338 }
324 339
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 472 }
458 } 473 }
459 } else { // Not tab full screen. 474 } else { // Not tab full screen.
460 if (IsMouseLocked()) { 475 if (IsMouseLocked()) {
461 return FEB_TYPE_MOUSELOCK_EXIT_INSTRUCTION; 476 return FEB_TYPE_MOUSELOCK_EXIT_INSTRUCTION;
462 } else if (IsMouseLockRequested()) { 477 } else if (IsMouseLockRequested()) {
463 return FEB_TYPE_MOUSELOCK_BUTTONS; 478 return FEB_TYPE_MOUSELOCK_BUTTONS;
464 } else { 479 } else {
465 if (!extension_caused_fullscreen_.is_empty()) { 480 if (!extension_caused_fullscreen_.is_empty()) {
466 return FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION; 481 return FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION;
467 } else if (toggled_into_fullscreen_ && !app_mode) { 482 } else if (toggled_into_fullscreen_ && !app_mode &&
483 !is_presentation_browser_fullscreen) {
468 return FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; 484 return FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
485 } else if (is_presentation_browser_fullscreen) {
486 return FEB_TYPE_PRESENTATION_FULLSCREEN_EXIT_INSTRUCTION;
469 } else { 487 } else {
470 return FEB_TYPE_NONE; 488 return FEB_TYPE_NONE;
471 } 489 }
472 } 490 }
473 } 491 }
474 NOTREACHED(); 492 NOTREACHED();
475 return FEB_TYPE_NONE; 493 return FEB_TYPE_NONE;
476 } 494 }
477 495
478 void FullscreenController::UpdateNotificationRegistrations() { 496 void FullscreenController::UpdateNotificationRegistrations() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 GURL url; 601 GURL url;
584 if (option == TAB) { 602 if (option == TAB) {
585 url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL(); 603 url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
586 tab_fullscreen_accepted_ = 604 tab_fullscreen_accepted_ =
587 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; 605 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
588 } else { 606 } else {
589 if (!extension_caused_fullscreen_.is_empty()) 607 if (!extension_caused_fullscreen_.is_empty())
590 url = extension_caused_fullscreen_; 608 url = extension_caused_fullscreen_;
591 } 609 }
592 610
593 if (option == BROWSER) 611 if (option == BROWSER || option == PRESENTATION)
594 content::RecordAction(UserMetricsAction("ToggleFullscreen")); 612 content::RecordAction(UserMetricsAction("ToggleFullscreen"));
595 // TODO(scheib): Record metrics for WITH_CHROME, without counting transitions 613 // TODO(scheib): Record metrics for WITH_CHROME, without counting transitions
596 // from tab fullscreen out to browser with chrome. 614 // from tab fullscreen out to browser with chrome.
597 615
598 #if defined(OS_MACOSX) 616 #if defined(OS_MACOSX)
599 if (option == BROWSER_WITH_CHROME) { 617 if (option == BROWSER_WITH_CHROME) {
600 CHECK(chrome::mac::SupportsSystemFullscreen()); 618 CHECK(chrome::mac::SupportsSystemFullscreen());
601 window_->EnterFullscreenWithChrome(); 619 window_->EnterFullscreenWithChrome();
602 } else { 620 } else {
603 #else 621 #else
604 { 622 {
605 #endif 623 #endif
624
625 if (option == PRESENTATION)
626 is_presentation_browser_fullscreen = true;
627
606 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); 628 window_->EnterFullscreen(url, GetFullscreenExitBubbleType());
607 } 629 }
608 630
609 UpdateFullscreenExitBubbleContent(); 631 UpdateFullscreenExitBubbleContent();
610 632
611 // Once the window has become fullscreen it'll call back to 633 // Once the window has become fullscreen it'll call back to
612 // WindowFullscreenStateChanged(). We don't do this immediately as 634 // WindowFullscreenStateChanged(). We don't do this immediately as
613 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let 635 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let
614 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 636 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
615 } 637 }
616 638
617 void FullscreenController::ExitFullscreenModeInternal() { 639 void FullscreenController::ExitFullscreenModeInternal() {
618 toggled_into_fullscreen_ = false; 640 toggled_into_fullscreen_ = false;
619 #if defined(OS_MACOSX) 641 #if defined(OS_MACOSX)
620 // Mac windows report a state change instantly, and so we must also clear 642 // Mac windows report a state change instantly, and so we must also clear
621 // state_prior_to_tab_fullscreen_ to match them else other logic using 643 // state_prior_to_tab_fullscreen_ to match them else other logic using
622 // state_prior_to_tab_fullscreen_ will be incorrect. 644 // state_prior_to_tab_fullscreen_ will be incorrect.
623 NotifyTabOfExitIfNecessary(); 645 NotifyTabOfExitIfNecessary();
624 #endif 646 #endif
625 window_->ExitFullscreen(); 647 if (is_presentation_browser_fullscreen)
648 window_->Close();
649 else
650 window_->ExitFullscreen();
626 extension_caused_fullscreen_ = GURL(); 651 extension_caused_fullscreen_ = GURL();
652 is_presentation_browser_fullscreen = false;
627 653
628 UpdateFullscreenExitBubbleContent(); 654 UpdateFullscreenExitBubbleContent();
629 } 655 }
630 656
631 void FullscreenController::SetFullscreenedTab(WebContents* tab) { 657 void FullscreenController::SetFullscreenedTab(WebContents* tab) {
632 fullscreened_tab_ = tab; 658 fullscreened_tab_ = tab;
633 UpdateNotificationRegistrations(); 659 UpdateNotificationRegistrations();
634 } 660 }
635 661
636 void FullscreenController::SetMouseLockTab(WebContents* tab) { 662 void FullscreenController::SetMouseLockTab(WebContents* tab) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? 722 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ?
697 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; 723 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL;
698 if (!mouse_lock_view) { 724 if (!mouse_lock_view) {
699 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); 725 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost();
700 if (rvh) 726 if (rvh)
701 mouse_lock_view = rvh->GetView(); 727 mouse_lock_view = rvh->GetView();
702 } 728 }
703 if (mouse_lock_view) 729 if (mouse_lock_view)
704 mouse_lock_view->UnlockMouse(); 730 mouse_lock_view->UnlockMouse();
705 } 731 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/fullscreen/fullscreen_controller.h ('k') | chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698