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 "apps/ui/web_contents_sizer.h" | 7 #include "apps/ui/web_contents_sizer.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 bool FullscreenController::IsWindowFullscreenForTabOrPending() const { | 80 bool FullscreenController::IsWindowFullscreenForTabOrPending() const { |
81 return fullscreened_tab_ != NULL; | 81 return fullscreened_tab_ != NULL; |
82 } | 82 } |
83 | 83 |
84 bool FullscreenController::IsFullscreenForTabOrPending( | 84 bool FullscreenController::IsFullscreenForTabOrPending( |
85 const WebContents* web_contents) const { | 85 const WebContents* web_contents) const { |
86 if (web_contents == fullscreened_tab_) { | 86 if (web_contents == fullscreened_tab_) { |
87 DCHECK(web_contents == browser_->tab_strip_model()->GetActiveWebContents()); | 87 DCHECK(web_contents == browser_->tab_strip_model()->GetActiveWebContents()); |
88 DCHECK(!IsFullscreenWithinTabPossible() || | 88 DCHECK(web_contents->GetCapturerCount() == 0); |
89 web_contents->GetCapturerCount() == 0); | |
90 return true; | 89 return true; |
91 } | 90 } |
92 return IsFullscreenForCapturedTab(web_contents); | 91 return IsFullscreenForCapturedTab(web_contents); |
93 } | 92 } |
94 | 93 |
95 bool FullscreenController::IsFullscreenCausedByTab() const { | 94 bool FullscreenController::IsFullscreenCausedByTab() const { |
96 return state_prior_to_tab_fullscreen_ == STATE_NORMAL; | 95 return state_prior_to_tab_fullscreen_ == STATE_NORMAL; |
97 } | 96 } |
98 | 97 |
99 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, | 98 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 return CONTENT_SETTING_ALLOW; | 703 return CONTENT_SETTING_ALLOW; |
705 | 704 |
706 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 705 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
707 return settings_map->GetContentSetting(url, url, | 706 return settings_map->GetContentSetting(url, url, |
708 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 707 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
709 } | 708 } |
710 | 709 |
711 bool FullscreenController::IsPrivilegedFullscreenForTab() const { | 710 bool FullscreenController::IsPrivilegedFullscreenForTab() const { |
712 const bool embedded_widget_present = | 711 const bool embedded_widget_present = |
713 fullscreened_tab_ && | 712 fullscreened_tab_ && |
714 fullscreened_tab_->GetFullscreenRenderWidgetHostView() && | 713 fullscreened_tab_->GetFullscreenRenderWidgetHostView(); |
715 IsFullscreenWithinTabPossible(); | |
716 return embedded_widget_present || is_privileged_fullscreen_for_testing_; | 714 return embedded_widget_present || is_privileged_fullscreen_for_testing_; |
717 } | 715 } |
718 | 716 |
719 void FullscreenController::SetPrivilegedFullscreenForTesting( | 717 void FullscreenController::SetPrivilegedFullscreenForTesting( |
720 bool is_privileged) { | 718 bool is_privileged) { |
721 is_privileged_fullscreen_for_testing_ = is_privileged; | 719 is_privileged_fullscreen_for_testing_ = is_privileged; |
722 } | 720 } |
723 | 721 |
724 bool FullscreenController::IsFullscreenWithinTabPossible() const { | |
725 return implicit_cast<const content::WebContentsDelegate*>(browser_)-> | |
726 EmbedsFullscreenWidget(); | |
727 } | |
728 | |
729 bool FullscreenController::MaybeToggleFullscreenForCapturedTab( | 722 bool FullscreenController::MaybeToggleFullscreenForCapturedTab( |
730 WebContents* web_contents, bool enter_fullscreen) { | 723 WebContents* web_contents, bool enter_fullscreen) { |
731 if (!IsFullscreenWithinTabPossible()) | |
732 return false; | |
733 | |
734 if (enter_fullscreen) { | 724 if (enter_fullscreen) { |
735 if (web_contents->GetCapturerCount() > 0) { | 725 if (web_contents->GetCapturerCount() > 0) { |
736 FullscreenWithinTabHelper::CreateForWebContents(web_contents); | 726 FullscreenWithinTabHelper::CreateForWebContents(web_contents); |
737 FullscreenWithinTabHelper::FromWebContents(web_contents)-> | 727 FullscreenWithinTabHelper::FromWebContents(web_contents)-> |
738 SetIsFullscreenForCapturedTab(true); | 728 SetIsFullscreenForCapturedTab(true); |
739 return true; | 729 return true; |
740 } | 730 } |
741 } else { | 731 } else { |
742 if (IsFullscreenForCapturedTab(web_contents)) { | 732 if (IsFullscreenForCapturedTab(web_contents)) { |
743 FullscreenWithinTabHelper::RemoveForWebContents(web_contents); | 733 FullscreenWithinTabHelper::RemoveForWebContents(web_contents); |
744 return true; | 734 return true; |
745 } | 735 } |
746 } | 736 } |
747 | 737 |
748 return false; | 738 return false; |
749 } | 739 } |
750 | 740 |
751 bool FullscreenController::IsFullscreenForCapturedTab( | 741 bool FullscreenController::IsFullscreenForCapturedTab( |
752 const WebContents* web_contents) const { | 742 const WebContents* web_contents) const { |
753 // Note: On Mac, some of the OnTabXXX() methods get called with a NULL value | 743 // Note: On Mac, some of the OnTabXXX() methods get called with a NULL value |
754 // for web_contents. Check for that here. | 744 // for web_contents. Check for that here. |
755 const FullscreenWithinTabHelper* const helper = web_contents ? | 745 const FullscreenWithinTabHelper* const helper = web_contents ? |
756 FullscreenWithinTabHelper::FromWebContents(web_contents) : NULL; | 746 FullscreenWithinTabHelper::FromWebContents(web_contents) : NULL; |
757 if (helper && helper->is_fullscreen_for_captured_tab()) { | 747 if (helper && helper->is_fullscreen_for_captured_tab()) { |
758 DCHECK(IsFullscreenWithinTabPossible()); | |
759 DCHECK_NE(fullscreened_tab_, web_contents); | 748 DCHECK_NE(fullscreened_tab_, web_contents); |
760 return true; | 749 return true; |
761 } | 750 } |
762 return false; | 751 return false; |
763 } | 752 } |
764 | 753 |
765 void FullscreenController::UnlockMouse() { | 754 void FullscreenController::UnlockMouse() { |
766 if (!mouse_lock_tab_) | 755 if (!mouse_lock_tab_) |
767 return; | 756 return; |
768 content::RenderWidgetHostView* mouse_lock_view = | 757 content::RenderWidgetHostView* mouse_lock_view = |
769 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? | 758 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? |
770 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; | 759 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; |
771 if (!mouse_lock_view) { | 760 if (!mouse_lock_view) { |
772 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); | 761 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); |
773 if (rvh) | 762 if (rvh) |
774 mouse_lock_view = rvh->GetView(); | 763 mouse_lock_view = rvh->GetView(); |
775 } | 764 } |
776 if (mouse_lock_view) | 765 if (mouse_lock_view) |
777 mouse_lock_view->UnlockMouse(); | 766 mouse_lock_view->UnlockMouse(); |
778 } | 767 } |
OLD | NEW |