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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 8970016: refactoring mouse lock to support pepper and WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CONTENT_EXPORT Created 8 years, 10 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
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 // Don't actually verify that the object is in the set since during module 1668 // Don't actually verify that the object is in the set since during module
1669 // deletion we'll be in the process of freeing them. 1669 // deletion we'll be in the process of freeing them.
1670 live_plugin_objects_.erase(plugin_object); 1670 live_plugin_objects_.erase(plugin_object);
1671 } 1671 }
1672 1672
1673 bool PluginInstance::IsFullPagePlugin() const { 1673 bool PluginInstance::IsFullPagePlugin() const {
1674 WebFrame* frame = container()->element().document().frame(); 1674 WebFrame* frame = container()->element().document().frame();
1675 return frame->view()->mainFrame()->document().isPluginDocument(); 1675 return frame->view()->mainFrame()->document().isPluginDocument();
1676 } 1676 }
1677 1677
1678 void PluginInstance::OnLockMouseACK(int32_t result) { 1678 void PluginInstance::OnLockMouseACK(bool succeeded) {
1679 if (!lock_mouse_callback_.func) { 1679 if (!lock_mouse_callback_.func) {
1680 NOTREACHED(); 1680 NOTREACHED();
1681 return; 1681 return;
1682 } 1682 }
1683 1683 PP_RunAndClearCompletionCallback(&lock_mouse_callback_,
1684 PP_RunAndClearCompletionCallback(&lock_mouse_callback_, result); 1684 succeeded ? PP_OK : PP_ERROR_FAILED);
1685 } 1685 }
1686 1686
1687 void PluginInstance::OnMouseLockLost() { 1687 void PluginInstance::OnMouseLockLost() {
1688 if (LoadMouseLockInterface()) 1688 if (LoadMouseLockInterface())
1689 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); 1689 plugin_mouse_lock_interface_->MouseLockLost(pp_instance());
1690 } 1690 }
1691 1691
1692 void PluginInstance::HandleMouseLockedInputEvent(
1693 const WebKit::WebMouseEvent& event) {
1694 // |cursor_info| is ignored since it is hidden when the mouse is locked.
1695 WebKit::WebCursorInfo cursor_info;
1696 HandleInputEvent(event, &cursor_info);
1697 }
1698
1692 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) { 1699 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
1693 WebView* web_view = container()->element().document().frame()->view(); 1700 WebView* web_view = container()->element().document().frame()->view();
1694 if (!web_view) { 1701 if (!web_view) {
1695 NOTREACHED(); 1702 NOTREACHED();
1696 return; 1703 return;
1697 } 1704 }
1698 1705
1699 std::vector<linked_ptr<WebInputEvent> > events = 1706 std::vector<linked_ptr<WebInputEvent> > events =
1700 CreateSimulatedWebInputEvents( 1707 CreateSimulatedWebInputEvents(
1701 input_event, 1708 input_event,
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { 1974 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
1968 message_channel_->PostMessageToJavaScript(message); 1975 message_channel_->PostMessageToJavaScript(message);
1969 } 1976 }
1970 1977
1971 int32_t PluginInstance::LockMouse(PP_Instance instance, 1978 int32_t PluginInstance::LockMouse(PP_Instance instance,
1972 PP_CompletionCallback callback) { 1979 PP_CompletionCallback callback) {
1973 if (!callback.func) { 1980 if (!callback.func) {
1974 // Don't support synchronous call. 1981 // Don't support synchronous call.
1975 return PP_ERROR_BLOCKS_MAIN_THREAD; 1982 return PP_ERROR_BLOCKS_MAIN_THREAD;
1976 } 1983 }
1977 if (lock_mouse_callback_.func) 1984 if (lock_mouse_callback_.func) // A lock is pending.
1978 return PP_ERROR_INPROGRESS; 1985 return PP_ERROR_INPROGRESS;
1986
1987 if (delegate()->IsMouseLocked(this))
1988 return PP_OK;
1989
1979 if (!CanAccessMainFrame()) 1990 if (!CanAccessMainFrame())
1980 return PP_ERROR_NOACCESS; 1991 return PP_ERROR_NOACCESS;
1981 1992
1982 lock_mouse_callback_ = callback; 1993 if (delegate()->LockMouse(this)) {
1983 // We will be notified on completion via OnLockMouseACK(), either 1994 lock_mouse_callback_ = callback;
1984 // synchronously or asynchronously. 1995 return PP_OK_COMPLETIONPENDING;
1985 delegate()->LockMouse(this); 1996 } else {
1986 return PP_OK_COMPLETIONPENDING; 1997 return PP_ERROR_FAILED;
1998 }
1987 } 1999 }
1988 2000
1989 void PluginInstance::UnlockMouse(PP_Instance instance) { 2001 void PluginInstance::UnlockMouse(PP_Instance instance) {
1990 delegate()->UnlockMouse(this); 2002 delegate()->UnlockMouse(this);
1991 } 2003 }
1992 2004
1993 PP_Var PluginInstance::ResolveRelativeToDocument( 2005 PP_Var PluginInstance::ResolveRelativeToDocument(
1994 PP_Instance instance, 2006 PP_Instance instance,
1995 PP_Var relative, 2007 PP_Var relative,
1996 PP_URLComponents_Dev* components) { 2008 PP_URLComponents_Dev* components) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 screen_size_for_fullscreen_ = gfx::Size(); 2123 screen_size_for_fullscreen_ = gfx::Size();
2112 WebElement element = container_->element(); 2124 WebElement element = container_->element();
2113 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2125 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2114 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2126 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2115 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2127 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2116 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2128 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2117 } 2129 }
2118 2130
2119 } // namespace ppapi 2131 } // namespace ppapi
2120 } // namespace webkit 2132 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698