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

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

Issue 23477051: Embed Flash Fullscreen widget within browser window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add caution comment to chrome_switches.cc. Created 7 years, 3 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 | Annotate | Revision Log
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 30 matching lines...) Expand all
41 : ptr_factory_(this), 41 : ptr_factory_(this),
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 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), 50 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED),
51 reentrant_window_state_change_call_check_(false) { 51 reentrant_window_state_change_call_check_(false),
52 is_privileged_fullscreen_for_testing_(false) {
52 DCHECK(window_); 53 DCHECK(window_);
53 DCHECK(profile_); 54 DCHECK(profile_);
54 } 55 }
55 56
56 FullscreenController::~FullscreenController() { 57 FullscreenController::~FullscreenController() {
57 } 58 }
58 59
59 bool FullscreenController::IsFullscreenForBrowser() const { 60 bool FullscreenController::IsFullscreenForBrowser() const {
60 return window_->IsFullscreen() && !IsFullscreenCausedByTab(); 61 return window_->IsFullscreen() && !IsFullscreenCausedByTab();
61 } 62 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 web_contents->GotResponseToLockMouseRequest(false); 229 web_contents->GotResponseToLockMouseRequest(false);
229 return; 230 return;
230 } 231 }
231 SetMouseLockTab(web_contents); 232 SetMouseLockTab(web_contents);
232 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); 233 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType();
233 234
234 switch (GetMouseLockSetting(web_contents->GetURL())) { 235 switch (GetMouseLockSetting(web_contents->GetURL())) {
235 case CONTENT_SETTING_ALLOW: 236 case CONTENT_SETTING_ALLOW:
236 // If bubble already displaying buttons we must not lock the mouse yet, 237 // If bubble already displaying buttons we must not lock the mouse yet,
237 // or it would prevent pressing those buttons. Instead, merge the request. 238 // or it would prevent pressing those buttons. Instead, merge the request.
238 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { 239 if (!IsPrivilegedFullscreenForTab() &&
240 fullscreen_bubble::ShowButtonsForType(bubble_type)) {
239 mouse_lock_state_ = MOUSELOCK_REQUESTED; 241 mouse_lock_state_ = MOUSELOCK_REQUESTED;
240 } else { 242 } else {
241 // Lock mouse. 243 // Lock mouse.
242 if (web_contents->GotResponseToLockMouseRequest(true)) { 244 if (web_contents->GotResponseToLockMouseRequest(true)) {
243 if (last_unlocked_by_target) { 245 if (last_unlocked_by_target) {
244 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY; 246 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY;
245 } else { 247 } else {
246 mouse_lock_state_ = MOUSELOCK_ACCEPTED; 248 mouse_lock_state_ = MOUSELOCK_ACCEPTED;
247 } 249 }
248 } else { 250 } else {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 state_prior_to_tab_fullscreen_ = STATE_INVALID; 506 state_prior_to_tab_fullscreen_ = STATE_INVALID;
505 tab_fullscreen_accepted_ = false; 507 tab_fullscreen_accepted_ = false;
506 if (rvh) 508 if (rvh)
507 rvh->ExitFullscreen(); 509 rvh->ExitFullscreen();
508 } 510 }
509 511
510 if (mouse_lock_tab_) { 512 if (mouse_lock_tab_) {
511 if (IsMouseLockRequested()) { 513 if (IsMouseLockRequested()) {
512 mouse_lock_tab_->GotResponseToLockMouseRequest(false); 514 mouse_lock_tab_->GotResponseToLockMouseRequest(false);
513 NotifyMouseLockChange(); 515 NotifyMouseLockChange();
514 } else if (mouse_lock_tab_->GetRenderViewHost() && 516 } else {
515 mouse_lock_tab_->GetRenderViewHost()->GetView()) { 517 UnlockMouse();
516 mouse_lock_tab_->GetRenderViewHost()->GetView()->UnlockMouse();
517 } 518 }
518 SetMouseLockTab(NULL); 519 SetMouseLockTab(NULL);
519 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; 520 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
520 } 521 }
521 522
522 UpdateFullscreenExitBubbleContent(); 523 UpdateFullscreenExitBubbleContent();
523 } 524 }
524 525
525 void FullscreenController::NotifyMouseLockChange() { 526 void FullscreenController::NotifyMouseLockChange() {
526 content::NotificationService::current()->Notify( 527 content::NotificationService::current()->Notify(
527 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, 528 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
528 content::Source<FullscreenController>(this), 529 content::Source<FullscreenController>(this),
529 content::NotificationService::NoDetails()); 530 content::NotificationService::NoDetails());
530 } 531 }
531 532
532 // TODO(koz): Change |for_tab| to an enum.
533 void FullscreenController::ToggleFullscreenModeInternal( 533 void FullscreenController::ToggleFullscreenModeInternal(
534 FullscreenInternalOption option) { 534 FullscreenInternalOption option) {
535 #if defined(OS_WIN) 535 #if defined(OS_WIN)
536 // When in Metro snap mode, toggling in and out of fullscreen is prevented. 536 // When in Metro snap mode, toggling in and out of fullscreen is prevented.
537 if (IsInMetroSnapMode()) 537 if (IsInMetroSnapMode())
538 return; 538 return;
539 #endif 539 #endif
540 540
541 bool enter_fullscreen = !window_->IsFullscreen(); 541 bool enter_fullscreen = !window_->IsFullscreen();
542 #if defined(OS_MACOSX) 542 #if defined(OS_MACOSX)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 ToggleFullscreenModeForTab(fullscreened_tab_, false); 637 ToggleFullscreenModeForTab(fullscreened_tab_, false);
638 else 638 else
639 NotifyTabOfExitIfNecessary(); 639 NotifyTabOfExitIfNecessary();
640 } 640 }
641 641
642 void FullscreenController::UpdateFullscreenExitBubbleContent() { 642 void FullscreenController::UpdateFullscreenExitBubbleContent() {
643 GURL url = GetFullscreenExitBubbleURL(); 643 GURL url = GetFullscreenExitBubbleURL();
644 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); 644 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType();
645 645
646 // If bubble displays buttons, unlock mouse to allow pressing them. 646 // If bubble displays buttons, unlock mouse to allow pressing them.
647 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && 647 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && IsMouseLocked())
648 IsMouseLocked() && 648 UnlockMouse();
649 mouse_lock_tab_ &&
650 mouse_lock_tab_->GetRenderViewHost() &&
651 mouse_lock_tab_->GetRenderViewHost()->GetView()) {
652 mouse_lock_tab_->GetRenderViewHost()->GetView()->UnlockMouse();
653 }
654 649
655 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); 650 window_->UpdateFullscreenExitBubbleContent(url, bubble_type);
656 } 651 }
657 652
658 ContentSetting 653 ContentSetting
659 FullscreenController::GetFullscreenSetting(const GURL& url) const { 654 FullscreenController::GetFullscreenSetting(const GURL& url) const {
660 if (url.SchemeIsFile()) 655 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile())
661 return CONTENT_SETTING_ALLOW; 656 return CONTENT_SETTING_ALLOW;
662 657
663 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url, 658 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url,
664 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); 659 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
665 } 660 }
666 661
667 ContentSetting 662 ContentSetting
668 FullscreenController::GetMouseLockSetting(const GURL& url) const { 663 FullscreenController::GetMouseLockSetting(const GURL& url) const {
669 if (url.SchemeIsFile()) 664 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile())
670 return CONTENT_SETTING_ALLOW; 665 return CONTENT_SETTING_ALLOW;
671 666
672 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); 667 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
673 return settings_map->GetContentSetting(url, url, 668 return settings_map->GetContentSetting(url, url,
674 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); 669 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string());
675 } 670 }
671
672 bool FullscreenController::IsPrivilegedFullscreenForTab() const {
673 const bool embedded_widget_present =
674 fullscreened_tab_ &&
675 fullscreened_tab_->GetFullscreenRenderWidgetHostView() &&
676 implicit_cast<const content::WebContentsDelegate*>(browser_)->
677 EmbedsFullscreenWidget();
678 return embedded_widget_present || is_privileged_fullscreen_for_testing_;
679 }
680
681 void FullscreenController::SetPrivilegedFullscreenForTesting(
682 bool is_privileged) {
683 is_privileged_fullscreen_for_testing_ = is_privileged;
684 }
685
686 void FullscreenController::UnlockMouse() {
687 if (!mouse_lock_tab_)
688 return;
689 content::RenderWidgetHostView* mouse_lock_view =
690 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ?
691 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL;
692 if (!mouse_lock_view) {
693 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost();
694 if (rvh)
695 mouse_lock_view = rvh->GetView();
696 }
697 if (mouse_lock_view)
698 mouse_lock_view->UnlockMouse();
699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698