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

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: Refactor MouseLockDispatcher out of RenderViewImpl Created 8 years, 11 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 "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 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 // Don't actually verify that the object is in the set since during module 1656 // Don't actually verify that the object is in the set since during module
1657 // deletion we'll be in the process of freeing them. 1657 // deletion we'll be in the process of freeing them.
1658 live_plugin_objects_.erase(plugin_object); 1658 live_plugin_objects_.erase(plugin_object);
1659 } 1659 }
1660 1660
1661 bool PluginInstance::IsFullPagePlugin() const { 1661 bool PluginInstance::IsFullPagePlugin() const {
1662 WebFrame* frame = container()->element().document().frame(); 1662 WebFrame* frame = container()->element().document().frame();
1663 return frame->view()->mainFrame()->document().isPluginDocument(); 1663 return frame->view()->mainFrame()->document().isPluginDocument();
1664 } 1664 }
1665 1665
1666 void PluginInstance::OnLockMouseACK(int32_t result) { 1666 void PluginInstance::OnLockMouseACK(bool succeeded) {
1667 if (!lock_mouse_callback_.func) { 1667 if (!lock_mouse_callback_.func) {
1668 NOTREACHED(); 1668 NOTREACHED();
1669 return; 1669 return;
1670 } 1670 }
1671 1671 PP_RunAndClearCompletionCallback(&lock_mouse_callback_,
1672 PP_RunAndClearCompletionCallback(&lock_mouse_callback_, result); 1672 succeeded ? PP_OK : PP_ERROR_FAILED);
1673 } 1673 }
1674 1674
1675 void PluginInstance::OnMouseLockLost() { 1675 void PluginInstance::OnMouseLockLost() {
1676 if (LoadMouseLockInterface()) 1676 if (LoadMouseLockInterface())
1677 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); 1677 plugin_mouse_lock_interface_->MouseLockLost(pp_instance());
1678 } 1678 }
1679 1679
1680 void PluginInstance::HandleMouseLockedInputEvent(
1681 const WebKit::WebMouseEvent& event) {
1682 // |cursor_info| is ignored since it is hidden when the mouse is locked.
1683 WebKit::WebCursorInfo cursor_info;
1684 HandleInputEvent(event, &cursor_info);
1685 }
1686
1680 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) { 1687 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
1681 WebView* web_view = container()->element().document().frame()->view(); 1688 WebView* web_view = container()->element().document().frame()->view();
1682 if (!web_view) { 1689 if (!web_view) {
1683 NOTREACHED(); 1690 NOTREACHED();
1684 return; 1691 return;
1685 } 1692 }
1686 1693
1687 std::vector<linked_ptr<WebInputEvent> > events = 1694 std::vector<linked_ptr<WebInputEvent> > events =
1688 CreateSimulatedWebInputEvents( 1695 CreateSimulatedWebInputEvents(
1689 input_event, 1696 input_event,
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { 1962 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
1956 message_channel_->PostMessageToJavaScript(message); 1963 message_channel_->PostMessageToJavaScript(message);
1957 } 1964 }
1958 1965
1959 int32_t PluginInstance::LockMouse(PP_Instance instance, 1966 int32_t PluginInstance::LockMouse(PP_Instance instance,
1960 PP_CompletionCallback callback) { 1967 PP_CompletionCallback callback) {
1961 if (!callback.func) { 1968 if (!callback.func) {
1962 // Don't support synchronous call. 1969 // Don't support synchronous call.
1963 return PP_ERROR_BLOCKS_MAIN_THREAD; 1970 return PP_ERROR_BLOCKS_MAIN_THREAD;
1964 } 1971 }
1965 if (lock_mouse_callback_.func) 1972 if (lock_mouse_callback_.func) // a lock is pending
1966 return PP_ERROR_INPROGRESS; 1973 return PP_ERROR_INPROGRESS;
1974
1975 if (delegate()->IsMouseLocked(this))
1976 return PP_OK;
1977
1967 if (!CanAccessMainFrame()) 1978 if (!CanAccessMainFrame())
1968 return PP_ERROR_NOACCESS; 1979 return PP_ERROR_NOACCESS;
1969 1980
1970 lock_mouse_callback_ = callback; 1981 if (delegate()->LockMouse(this)) {
1971 // We will be notified on completion via OnLockMouseACK(), either 1982 lock_mouse_callback_ = callback;
1972 // synchronously or asynchronously. 1983 return PP_OK_COMPLETIONPENDING;
1973 delegate()->LockMouse(this); 1984 } else {
1974 return PP_OK_COMPLETIONPENDING; 1985 return PP_ERROR_FAILED;
1986 }
1975 } 1987 }
1976 1988
1977 void PluginInstance::UnlockMouse(PP_Instance instance) { 1989 void PluginInstance::UnlockMouse(PP_Instance instance) {
1978 delegate()->UnlockMouse(this); 1990 delegate()->UnlockMouse(this);
1979 } 1991 }
1980 1992
1981 PP_Var PluginInstance::ResolveRelativeToDocument( 1993 PP_Var PluginInstance::ResolveRelativeToDocument(
1982 PP_Instance instance, 1994 PP_Instance instance,
1983 PP_Var relative, 1995 PP_Var relative,
1984 PP_URLComponents_Dev* components) { 1996 PP_URLComponents_Dev* components) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 screen_size_for_fullscreen_ = gfx::Size(); 2111 screen_size_for_fullscreen_ = gfx::Size();
2100 WebElement element = container_->element(); 2112 WebElement element = container_->element();
2101 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2113 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2102 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2114 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2103 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2115 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2104 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2116 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2105 } 2117 }
2106 2118
2107 } // namespace ppapi 2119 } // namespace ppapi
2108 } // namespace webkit 2120 } // namespace webkit
OLDNEW
« content/renderer/render_view_impl.cc ('K') | « 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