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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 delegate_->ExitFullscreenModeForTab(this); | 1700 delegate_->ExitFullscreenModeForTab(this); |
1701 FOR_EACH_OBSERVER(WebContentsObserver, | 1701 FOR_EACH_OBSERVER(WebContentsObserver, |
1702 observers_, | 1702 observers_, |
1703 DidDestroyFullscreenWidget()); | 1703 DidDestroyFullscreenWidget()); |
1704 fullscreen_widget_process_id_ = ChildProcessHost::kInvalidUniqueID; | 1704 fullscreen_widget_process_id_ = ChildProcessHost::kInvalidUniqueID; |
1705 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; | 1705 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; |
1706 if (fullscreen_widget_had_focus_at_shutdown_) | 1706 if (fullscreen_widget_had_focus_at_shutdown_) |
1707 view_->RestoreFocus(); | 1707 view_->RestoreFocus(); |
1708 } | 1708 } |
1709 | 1709 |
1710 if (mouse_lock_widget_ == render_widget_host) | 1710 CHECK(mouse_lock_widget_ != render_widget_host); |
1711 mouse_lock_widget_ = nullptr; | |
1712 } | 1711 } |
1713 | 1712 |
1714 void WebContentsImpl::RenderWidgetGotFocus( | 1713 void WebContentsImpl::RenderWidgetGotFocus( |
1715 RenderWidgetHostImpl* render_widget_host) { | 1714 RenderWidgetHostImpl* render_widget_host) { |
1716 // Notify the observers if an embedded fullscreen widget was focused. | 1715 // Notify the observers if an embedded fullscreen widget was focused. |
1717 if (delegate_ && render_widget_host && delegate_->EmbedsFullscreenWidget() && | 1716 if (delegate_ && render_widget_host && delegate_->EmbedsFullscreenWidget() && |
1718 render_widget_host->GetView() == GetFullscreenRenderWidgetHostView()) { | 1717 render_widget_host->GetView() == GetFullscreenRenderWidgetHostView()) { |
1719 NotifyWebContentsFocused(); | 1718 NotifyWebContentsFocused(); |
1720 } | 1719 } |
1721 } | 1720 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 if (!RenderViewHostImpl::From(render_widget_host)) | 1889 if (!RenderViewHostImpl::From(render_widget_host)) |
1891 return blink::WebDisplayModeBrowser; | 1890 return blink::WebDisplayModeBrowser; |
1892 | 1891 |
1893 return delegate_ ? delegate_->GetDisplayMode(this) | 1892 return delegate_ ? delegate_->GetDisplayMode(this) |
1894 : blink::WebDisplayModeBrowser; | 1893 : blink::WebDisplayModeBrowser; |
1895 } | 1894 } |
1896 | 1895 |
1897 void WebContentsImpl::RequestToLockMouse( | 1896 void WebContentsImpl::RequestToLockMouse( |
1898 RenderWidgetHostImpl* render_widget_host, | 1897 RenderWidgetHostImpl* render_widget_host, |
1899 bool user_gesture, | 1898 bool user_gesture, |
1900 bool last_unlocked_by_target) { | 1899 bool last_unlocked_by_target, |
| 1900 bool privileged) { |
1901 if (mouse_lock_widget_) { | 1901 if (mouse_lock_widget_) { |
1902 render_widget_host->GotResponseToLockMouseRequest(false); | 1902 render_widget_host->GotResponseToLockMouseRequest(false); |
1903 return; | 1903 return; |
1904 } | 1904 } |
1905 | 1905 |
| 1906 if (privileged) { |
| 1907 mouse_lock_widget_ = render_widget_host; |
| 1908 render_widget_host->GotResponseToLockMouseRequest(true); |
| 1909 return; |
| 1910 } |
| 1911 |
1906 bool widget_in_frame_tree = false; | 1912 bool widget_in_frame_tree = false; |
1907 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 1913 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
1908 if (node->current_frame_host()->GetRenderWidgetHost() == | 1914 if (node->current_frame_host()->GetRenderWidgetHost() == |
1909 render_widget_host) { | 1915 render_widget_host) { |
1910 widget_in_frame_tree = true; | 1916 widget_in_frame_tree = true; |
1911 break; | 1917 break; |
1912 } | 1918 } |
1913 } | 1919 } |
1914 | 1920 |
1915 if (widget_in_frame_tree && delegate_) { | 1921 if (widget_in_frame_tree && delegate_) { |
1916 mouse_lock_widget_ = render_widget_host; | 1922 mouse_lock_widget_ = render_widget_host; |
1917 delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target); | 1923 delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target); |
1918 } else { | 1924 } else { |
1919 render_widget_host->GotResponseToLockMouseRequest(false); | 1925 render_widget_host->GotResponseToLockMouseRequest(false); |
1920 } | 1926 } |
1921 } | 1927 } |
1922 | 1928 |
1923 void WebContentsImpl::LostMouseLock(RenderWidgetHostImpl* render_widget_host) { | 1929 void WebContentsImpl::LostMouseLock(RenderWidgetHostImpl* render_widget_host) { |
1924 CHECK(mouse_lock_widget_); | 1930 CHECK(mouse_lock_widget_); |
1925 mouse_lock_widget_->SendMouseLockLost(); | 1931 mouse_lock_widget_->SendMouseLockLost(); |
1926 mouse_lock_widget_ = nullptr; | 1932 mouse_lock_widget_ = nullptr; |
1927 | 1933 |
1928 if (delegate_) | 1934 if (delegate_) |
1929 delegate_->LostMouseLock(); | 1935 delegate_->LostMouseLock(); |
1930 } | 1936 } |
1931 | 1937 |
| 1938 bool WebContentsImpl::HasMouseLock(RenderWidgetHostImpl* render_widget_host) { |
| 1939 // To verify if the mouse is locked, the mouse_lock_widget_ needs to be |
| 1940 // assigned to the widget that requested the mouse lock, and the top-level |
| 1941 // platform RenderWidgetHostView needs to hold the mouse lock from the OS. |
| 1942 return mouse_lock_widget_ == render_widget_host && |
| 1943 GetTopLevelRenderWidgetHostView()->IsMouseLocked(); |
| 1944 } |
| 1945 |
1932 void WebContentsImpl::ForwardCompositorProto( | 1946 void WebContentsImpl::ForwardCompositorProto( |
1933 RenderWidgetHostImpl* render_widget_host, | 1947 RenderWidgetHostImpl* render_widget_host, |
1934 const std::vector<uint8_t>& proto) { | 1948 const std::vector<uint8_t>& proto) { |
1935 if (delegate_) | 1949 if (delegate_) |
1936 delegate_->ForwardCompositorProto(render_widget_host, proto); | 1950 delegate_->ForwardCompositorProto(render_widget_host, proto); |
1937 } | 1951 } |
1938 | 1952 |
1939 void WebContentsImpl::OnRenderFrameProxyVisibilityChanged(bool visible) { | 1953 void WebContentsImpl::OnRenderFrameProxyVisibilityChanged(bool visible) { |
1940 if (visible) | 1954 if (visible) |
1941 WasShown(); | 1955 WasShown(); |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2979 } | 2993 } |
2980 | 2994 |
2981 gfx::Size WebContentsImpl::GetPreferredSize() const { | 2995 gfx::Size WebContentsImpl::GetPreferredSize() const { |
2982 return capturer_count_ == 0 ? preferred_size_ : preferred_size_for_capture_; | 2996 return capturer_count_ == 0 ? preferred_size_ : preferred_size_for_capture_; |
2983 } | 2997 } |
2984 | 2998 |
2985 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) { | 2999 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) { |
2986 if (GetBrowserPluginGuest()) | 3000 if (GetBrowserPluginGuest()) |
2987 return GetBrowserPluginGuest()->LockMouse(allowed); | 3001 return GetBrowserPluginGuest()->LockMouse(allowed); |
2988 | 3002 |
2989 if (mouse_lock_widget_) | 3003 if (mouse_lock_widget_ && |
2990 return mouse_lock_widget_->GotResponseToLockMouseRequest(allowed); | 3004 mouse_lock_widget_->GotResponseToLockMouseRequest(allowed)) |
| 3005 return true; |
| 3006 |
| 3007 mouse_lock_widget_ = nullptr; |
2991 return false; | 3008 return false; |
2992 } | 3009 } |
2993 | 3010 |
2994 bool WebContentsImpl::HasOpener() const { | 3011 bool WebContentsImpl::HasOpener() const { |
2995 return GetOpener() != NULL; | 3012 return GetOpener() != NULL; |
2996 } | 3013 } |
2997 | 3014 |
2998 WebContentsImpl* WebContentsImpl::GetOpener() const { | 3015 WebContentsImpl* WebContentsImpl::GetOpener() const { |
2999 FrameTreeNode* opener_ftn = frame_tree_.root()->opener(); | 3016 FrameTreeNode* opener_ftn = frame_tree_.root()->opener(); |
3000 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr; | 3017 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr; |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5157 for (RenderViewHost* render_view_host : render_view_host_set) | 5174 for (RenderViewHost* render_view_host : render_view_host_set) |
5158 render_view_host->OnWebkitPreferencesChanged(); | 5175 render_view_host->OnWebkitPreferencesChanged(); |
5159 } | 5176 } |
5160 | 5177 |
5161 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5178 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5162 JavaScriptDialogManager* dialog_manager) { | 5179 JavaScriptDialogManager* dialog_manager) { |
5163 dialog_manager_ = dialog_manager; | 5180 dialog_manager_ = dialog_manager; |
5164 } | 5181 } |
5165 | 5182 |
5166 } // namespace content | 5183 } // namespace content |
OLD | NEW |