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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 25 matching lines...) Expand all
36 #include "third_party/WebKit/public/web/WebPluginContainer.h" 36 #include "third_party/WebKit/public/web/WebPluginContainer.h"
37 #include "third_party/WebKit/public/web/WebPluginParams.h" 37 #include "third_party/WebKit/public/web/WebPluginParams.h"
38 #include "third_party/WebKit/public/web/WebScriptSource.h" 38 #include "third_party/WebKit/public/web/WebScriptSource.h"
39 #include "third_party/WebKit/public/web/WebView.h" 39 #include "third_party/WebKit/public/web/WebView.h"
40 #include "ui/events/keycodes/keyboard_codes.h" 40 #include "ui/events/keycodes/keyboard_codes.h"
41 41
42 #if defined (OS_WIN) 42 #if defined (OS_WIN)
43 #include "base/sys_info.h" 43 #include "base/sys_info.h"
44 #endif 44 #endif
45 45
46 using WebKit::WebCanvas; 46 using blink::WebCanvas;
47 using WebKit::WebPluginContainer; 47 using blink::WebPluginContainer;
48 using WebKit::WebPluginParams; 48 using blink::WebPluginParams;
49 using WebKit::WebPoint; 49 using blink::WebPoint;
50 using WebKit::WebRect; 50 using blink::WebRect;
51 using WebKit::WebURL; 51 using blink::WebURL;
52 using WebKit::WebVector; 52 using blink::WebVector;
53 53
54 namespace content { 54 namespace content {
55 55
56 namespace { 56 namespace {
57 57
58 static std::string GetInternalEventName(const char* event_name) { 58 static std::string GetInternalEventName(const char* event_name) {
59 return base::StringPrintf("-internal-%s", event_name); 59 return base::StringPrintf("-internal-%s", event_name);
60 } 60 }
61 61
62 typedef std::map<WebKit::WebPluginContainer*, 62 typedef std::map<blink::WebPluginContainer*,
63 BrowserPlugin*> PluginContainerMap; 63 BrowserPlugin*> PluginContainerMap;
64 static base::LazyInstance<PluginContainerMap> g_plugin_container_map = 64 static base::LazyInstance<PluginContainerMap> g_plugin_container_map =
65 LAZY_INSTANCE_INITIALIZER; 65 LAZY_INSTANCE_INITIALIZER;
66 66
67 } // namespace 67 } // namespace
68 68
69 BrowserPlugin::BrowserPlugin( 69 BrowserPlugin::BrowserPlugin(
70 RenderViewImpl* render_view, 70 RenderViewImpl* render_view,
71 WebKit::WebFrame* frame, 71 blink::WebFrame* frame,
72 const WebPluginParams& params) 72 const WebPluginParams& params)
73 : guest_instance_id_(browser_plugin::kInstanceIDNone), 73 : guest_instance_id_(browser_plugin::kInstanceIDNone),
74 attached_(false), 74 attached_(false),
75 render_view_(render_view->AsWeakPtr()), 75 render_view_(render_view->AsWeakPtr()),
76 render_view_routing_id_(render_view->GetRoutingID()), 76 render_view_routing_id_(render_view->GetRoutingID()),
77 container_(NULL), 77 container_(NULL),
78 damage_buffer_sequence_id_(0), 78 damage_buffer_sequence_id_(0),
79 paint_ack_received_(true), 79 paint_ack_received_(true),
80 last_device_scale_factor_(1.0f), 80 last_device_scale_factor_(1.0f),
81 sad_guest_(NULL), 81 sad_guest_(NULL),
(...skipping 19 matching lines...) Expand all
101 if (!HasGuestInstanceID()) 101 if (!HasGuestInstanceID())
102 return; 102 return;
103 browser_plugin_manager()->RemoveBrowserPlugin(guest_instance_id_); 103 browser_plugin_manager()->RemoveBrowserPlugin(guest_instance_id_);
104 browser_plugin_manager()->Send( 104 browser_plugin_manager()->Send(
105 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_, 105 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_,
106 guest_instance_id_)); 106 guest_instance_id_));
107 } 107 }
108 108
109 /*static*/ 109 /*static*/
110 BrowserPlugin* BrowserPlugin::FromContainer( 110 BrowserPlugin* BrowserPlugin::FromContainer(
111 WebKit::WebPluginContainer* container) { 111 blink::WebPluginContainer* container) {
112 PluginContainerMap* browser_plugins = g_plugin_container_map.Pointer(); 112 PluginContainerMap* browser_plugins = g_plugin_container_map.Pointer();
113 PluginContainerMap::iterator it = browser_plugins->find(container); 113 PluginContainerMap::iterator it = browser_plugins->find(container);
114 return it == browser_plugins->end() ? NULL : it->second; 114 return it == browser_plugins->end() ? NULL : it->second;
115 } 115 }
116 116
117 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { 117 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
118 bool handled = true; 118 bool handled = true;
119 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) 119 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message)
120 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) 120 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus)
121 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) 121 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK)
(...skipping 12 matching lines...) Expand all
134 IPC_MESSAGE_UNHANDLED(handled = false) 134 IPC_MESSAGE_UNHANDLED(handled = false)
135 IPC_END_MESSAGE_MAP() 135 IPC_END_MESSAGE_MAP()
136 return handled; 136 return handled;
137 } 137 }
138 138
139 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, 139 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name,
140 const std::string& attribute_value) { 140 const std::string& attribute_value) {
141 if (!container()) 141 if (!container())
142 return; 142 return;
143 143
144 WebKit::WebElement element = container()->element(); 144 blink::WebElement element = container()->element();
145 WebKit::WebString web_attribute_name = 145 blink::WebString web_attribute_name =
146 WebKit::WebString::fromUTF8(attribute_name); 146 blink::WebString::fromUTF8(attribute_name);
147 if (!HasDOMAttribute(attribute_name) || 147 if (!HasDOMAttribute(attribute_name) ||
148 (std::string(element.getAttribute(web_attribute_name).utf8()) != 148 (std::string(element.getAttribute(web_attribute_name).utf8()) !=
149 attribute_value)) { 149 attribute_value)) {
150 element.setAttribute(web_attribute_name, 150 element.setAttribute(web_attribute_name,
151 WebKit::WebString::fromUTF8(attribute_value)); 151 blink::WebString::fromUTF8(attribute_value));
152 } 152 }
153 } 153 }
154 154
155 void BrowserPlugin::RemoveDOMAttribute(const std::string& attribute_name) { 155 void BrowserPlugin::RemoveDOMAttribute(const std::string& attribute_name) {
156 if (!container()) 156 if (!container())
157 return; 157 return;
158 158
159 container()->element().removeAttribute( 159 container()->element().removeAttribute(
160 WebKit::WebString::fromUTF8(attribute_name)); 160 blink::WebString::fromUTF8(attribute_name));
161 } 161 }
162 162
163 std::string BrowserPlugin::GetDOMAttributeValue( 163 std::string BrowserPlugin::GetDOMAttributeValue(
164 const std::string& attribute_name) const { 164 const std::string& attribute_name) const {
165 if (!container()) 165 if (!container())
166 return std::string(); 166 return std::string();
167 167
168 return container()->element().getAttribute( 168 return container()->element().getAttribute(
169 WebKit::WebString::fromUTF8(attribute_name)).utf8(); 169 blink::WebString::fromUTF8(attribute_name)).utf8();
170 } 170 }
171 171
172 bool BrowserPlugin::HasDOMAttribute(const std::string& attribute_name) const { 172 bool BrowserPlugin::HasDOMAttribute(const std::string& attribute_name) const {
173 if (!container()) 173 if (!container())
174 return false; 174 return false;
175 175
176 return container()->element().hasAttribute( 176 return container()->element().hasAttribute(
177 WebKit::WebString::fromUTF8(attribute_name)); 177 blink::WebString::fromUTF8(attribute_name));
178 } 178 }
179 179
180 std::string BrowserPlugin::GetNameAttribute() const { 180 std::string BrowserPlugin::GetNameAttribute() const {
181 return GetDOMAttributeValue(browser_plugin::kAttributeName); 181 return GetDOMAttributeValue(browser_plugin::kAttributeName);
182 } 182 }
183 183
184 std::string BrowserPlugin::GetSrcAttribute() const { 184 std::string BrowserPlugin::GetSrcAttribute() const {
185 return GetDOMAttributeValue(browser_plugin::kAttributeSrc); 185 return GetDOMAttributeValue(browser_plugin::kAttributeSrc);
186 } 186 }
187 187
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 return; 474 return;
475 } 475 }
476 render_view_->mouse_lock_dispatcher()->UnlockMouse(this); 476 render_view_->mouse_lock_dispatcher()->UnlockMouse(this);
477 } 477 }
478 } 478 }
479 479
480 void BrowserPlugin::OnShouldAcceptTouchEvents(int guest_instance_id, 480 void BrowserPlugin::OnShouldAcceptTouchEvents(int guest_instance_id,
481 bool accept) { 481 bool accept) {
482 if (container()) { 482 if (container()) {
483 container()->requestTouchEventType(accept ? 483 container()->requestTouchEventType(accept ?
484 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : 484 blink::WebPluginContainer::TouchEventRequestTypeRaw :
485 WebKit::WebPluginContainer::TouchEventRequestTypeNone); 485 blink::WebPluginContainer::TouchEventRequestTypeNone);
486 } 486 }
487 } 487 }
488 488
489 void BrowserPlugin::OnUpdatedName(int guest_instance_id, 489 void BrowserPlugin::OnUpdatedName(int guest_instance_id,
490 const std::string& name) { 490 const std::string& name) {
491 UpdateDOMAttribute(browser_plugin::kAttributeName, name); 491 UpdateDOMAttribute(browser_plugin::kAttributeName, name);
492 } 492 }
493 493
494 void BrowserPlugin::OnUpdateRect( 494 void BrowserPlugin::OnUpdateRect(
495 int guest_instance_id, 495 int guest_instance_id,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 size.height() <= GetAdjustedMaxHeight(); 629 size.height() <= GetAdjustedMaxHeight();
630 } 630 }
631 631
632 NPObject* BrowserPlugin::GetContentWindow() const { 632 NPObject* BrowserPlugin::GetContentWindow() const {
633 if (content_window_routing_id_ == MSG_ROUTING_NONE) 633 if (content_window_routing_id_ == MSG_ROUTING_NONE)
634 return NULL; 634 return NULL;
635 RenderViewImpl* guest_render_view = RenderViewImpl::FromRoutingID( 635 RenderViewImpl* guest_render_view = RenderViewImpl::FromRoutingID(
636 content_window_routing_id_); 636 content_window_routing_id_);
637 if (!guest_render_view) 637 if (!guest_render_view)
638 return NULL; 638 return NULL;
639 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); 639 blink::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame();
640 return guest_frame->windowObject(); 640 return guest_frame->windowObject();
641 } 641 }
642 642
643 // static 643 // static
644 bool BrowserPlugin::AttachWindowTo(const WebKit::WebNode& node, int window_id) { 644 bool BrowserPlugin::AttachWindowTo(const blink::WebNode& node, int window_id) {
645 if (node.isNull()) 645 if (node.isNull())
646 return false; 646 return false;
647 647
648 if (!node.isElementNode()) 648 if (!node.isElementNode())
649 return false; 649 return false;
650 650
651 WebKit::WebElement shim_element = node.toConst<WebKit::WebElement>(); 651 blink::WebElement shim_element = node.toConst<blink::WebElement>();
652 // The shim containing the BrowserPlugin must be attached to a document. 652 // The shim containing the BrowserPlugin must be attached to a document.
653 if (shim_element.document().isNull()) 653 if (shim_element.document().isNull())
654 return false; 654 return false;
655 655
656 WebKit::WebNode shadow_root = shim_element.shadowRoot(); 656 blink::WebNode shadow_root = shim_element.shadowRoot();
657 if (shadow_root.isNull() || !shadow_root.hasChildNodes()) 657 if (shadow_root.isNull() || !shadow_root.hasChildNodes())
658 return false; 658 return false;
659 659
660 WebKit::WebNode plugin_element = shadow_root.firstChild(); 660 blink::WebNode plugin_element = shadow_root.firstChild();
661 WebKit::WebPluginContainer* plugin_container = 661 blink::WebPluginContainer* plugin_container =
662 plugin_element.pluginContainer(); 662 plugin_element.pluginContainer();
663 if (!plugin_container) 663 if (!plugin_container)
664 return false; 664 return false;
665 665
666 BrowserPlugin* browser_plugin = 666 BrowserPlugin* browser_plugin =
667 BrowserPlugin::FromContainer(plugin_container); 667 BrowserPlugin::FromContainer(plugin_container);
668 if (!browser_plugin) 668 if (!browser_plugin)
669 return false; 669 return false;
670 670
671 // If the BrowserPlugin has already begun to navigate then we shouldn't allow 671 // If the BrowserPlugin has already begun to navigate then we shouldn't allow
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 render_view_routing_id_, 775 render_view_routing_id_,
776 guest_instance_id_, 776 guest_instance_id_,
777 params)); 777 params));
778 } 778 }
779 779
780 void BrowserPlugin::TriggerEvent(const std::string& event_name, 780 void BrowserPlugin::TriggerEvent(const std::string& event_name,
781 std::map<std::string, base::Value*>* props) { 781 std::map<std::string, base::Value*>* props) {
782 if (!container()) 782 if (!container())
783 return; 783 return;
784 784
785 WebKit::WebFrame* frame = container()->element().document().frame(); 785 blink::WebFrame* frame = container()->element().document().frame();
786 if (!frame) 786 if (!frame)
787 return; 787 return;
788 788
789 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 789 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
790 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 790 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
791 v8::Context::Scope context_scope(context); 791 v8::Context::Scope context_scope(context);
792 792
793 std::string json_string; 793 std::string json_string;
794 if (props) { 794 if (props) {
795 base::DictionaryValue dict; 795 base::DictionaryValue dict;
796 for (std::map<std::string, base::Value*>::iterator iter = props->begin(), 796 for (std::map<std::string, base::Value*>::iterator iter = props->begin(),
797 end = props->end(); iter != end; ++iter) { 797 end = props->end(); iter != end; ++iter) {
798 dict.Set(iter->first, iter->second); 798 dict.Set(iter->first, iter->second);
799 } 799 }
800 800
801 JSONStringValueSerializer serializer(&json_string); 801 JSONStringValueSerializer serializer(&json_string);
802 if (!serializer.Serialize(dict)) 802 if (!serializer.Serialize(dict))
803 return; 803 return;
804 } 804 }
805 805
806 WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent"); 806 blink::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent");
807 WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>(); 807 blink::WebDOMCustomEvent event = dom_event.to<blink::WebDOMCustomEvent>();
808 808
809 // The events triggered directly from the plugin <object> are internal events 809 // The events triggered directly from the plugin <object> are internal events
810 // whose implementation details can (and likely will) change over time. The 810 // whose implementation details can (and likely will) change over time. The
811 // wrapper/shim (e.g. <webview> tag) should receive these events, and expose a 811 // wrapper/shim (e.g. <webview> tag) should receive these events, and expose a
812 // more appropriate (and stable) event to the consumers as part of the API. 812 // more appropriate (and stable) event to the consumers as part of the API.
813 event.initCustomEvent( 813 event.initCustomEvent(
814 WebKit::WebString::fromUTF8(GetInternalEventName(event_name.c_str())), 814 blink::WebString::fromUTF8(GetInternalEventName(event_name.c_str())),
815 false, false, 815 false, false,
816 WebKit::WebSerializedScriptValue::serialize( 816 blink::WebSerializedScriptValue::serialize(
817 v8::String::New(json_string.c_str(), json_string.size()))); 817 v8::String::New(json_string.c_str(), json_string.size())));
818 container()->element().dispatchEvent(event); 818 container()->element().dispatchEvent(event);
819 } 819 }
820 820
821 void BrowserPlugin::UpdateGuestFocusState() { 821 void BrowserPlugin::UpdateGuestFocusState() {
822 if (!HasGuestInstanceID()) 822 if (!HasGuestInstanceID())
823 return; 823 return;
824 bool should_be_focused = ShouldGuestBeFocused(); 824 bool should_be_focused = ShouldGuestBeFocused();
825 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( 825 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus(
826 render_view_routing_id_, 826 render_view_routing_id_,
827 guest_instance_id_, 827 guest_instance_id_,
828 should_be_focused)); 828 should_be_focused));
829 } 829 }
830 830
831 bool BrowserPlugin::ShouldGuestBeFocused() const { 831 bool BrowserPlugin::ShouldGuestBeFocused() const {
832 bool embedder_focused = false; 832 bool embedder_focused = false;
833 if (render_view_.get()) 833 if (render_view_.get())
834 embedder_focused = render_view_->has_focus(); 834 embedder_focused = render_view_->has_focus();
835 return plugin_focused_ && embedder_focused; 835 return plugin_focused_ && embedder_focused;
836 } 836 }
837 837
838 WebKit::WebPluginContainer* BrowserPlugin::container() const { 838 blink::WebPluginContainer* BrowserPlugin::container() const {
839 return container_; 839 return container_;
840 } 840 }
841 841
842 bool BrowserPlugin::initialize(WebPluginContainer* container) { 842 bool BrowserPlugin::initialize(WebPluginContainer* container) {
843 if (!container) 843 if (!container)
844 return false; 844 return false;
845 845
846 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) 846 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container))
847 return false; 847 return false;
848 848
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); 911 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this);
912 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 912 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
913 } 913 }
914 914
915 NPObject* BrowserPlugin::scriptableObject() { 915 NPObject* BrowserPlugin::scriptableObject() {
916 if (!bindings_) 916 if (!bindings_)
917 return NULL; 917 return NULL;
918 918
919 NPObject* browser_plugin_np_object(bindings_->np_object()); 919 NPObject* browser_plugin_np_object(bindings_->np_object());
920 // The object is expected to be retained before it is returned. 920 // The object is expected to be retained before it is returned.
921 WebKit::WebBindings::retainObject(browser_plugin_np_object); 921 blink::WebBindings::retainObject(browser_plugin_np_object);
922 return browser_plugin_np_object; 922 return browser_plugin_np_object;
923 } 923 }
924 924
925 NPP BrowserPlugin::pluginNPP() { 925 NPP BrowserPlugin::pluginNPP() {
926 return npp_.get(); 926 return npp_.get();
927 } 927 }
928 928
929 bool BrowserPlugin::supportsKeyboardFocus() const { 929 bool BrowserPlugin::supportsKeyboardFocus() const {
930 return true; 930 return true;
931 } 931 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 // This also does not take overlapping plugins into account. 983 // This also does not take overlapping plugins into account.
984 bool result = position.x() >= plugin_rect_.x() && 984 bool result = position.x() >= plugin_rect_.x() &&
985 position.x() < plugin_rect_.x() + plugin_rect_.width() && 985 position.x() < plugin_rect_.x() + plugin_rect_.width() &&
986 position.y() >= plugin_rect_.y() && 986 position.y() >= plugin_rect_.y() &&
987 position.y() < plugin_rect_.y() + plugin_rect_.height(); 987 position.y() < plugin_rect_.y() + plugin_rect_.height();
988 return result; 988 return result;
989 } 989 }
990 990
991 gfx::Point BrowserPlugin::ToLocalCoordinates(const gfx::Point& point) const { 991 gfx::Point BrowserPlugin::ToLocalCoordinates(const gfx::Point& point) const {
992 if (container_) 992 if (container_)
993 return container_->windowToLocalPoint(WebKit::WebPoint(point)); 993 return container_->windowToLocalPoint(blink::WebPoint(point));
994 return gfx::Point(point.x() - plugin_rect_.x(), point.y() - plugin_rect_.y()); 994 return gfx::Point(point.x() - plugin_rect_.x(), point.y() - plugin_rect_.y());
995 } 995 }
996 996
997 // static 997 // static
998 bool BrowserPlugin::ShouldForwardToBrowserPlugin( 998 bool BrowserPlugin::ShouldForwardToBrowserPlugin(
999 const IPC::Message& message) { 999 const IPC::Message& message) {
1000 switch (message.type()) { 1000 switch (message.type()) {
1001 case BrowserPluginMsg_AdvanceFocus::ID: 1001 case BrowserPluginMsg_AdvanceFocus::ID:
1002 case BrowserPluginMsg_Attach_ACK::ID: 1002 case BrowserPluginMsg_Attach_ACK::ID:
1003 case BrowserPluginMsg_BuffersSwapped::ID: 1003 case BrowserPluginMsg_BuffersSwapped::ID:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility( 1175 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility(
1176 render_view_routing_id_, 1176 render_view_routing_id_,
1177 guest_instance_id_, 1177 guest_instance_id_,
1178 visible)); 1178 visible));
1179 } 1179 }
1180 1180
1181 bool BrowserPlugin::acceptsInputEvents() { 1181 bool BrowserPlugin::acceptsInputEvents() {
1182 return true; 1182 return true;
1183 } 1183 }
1184 1184
1185 bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event, 1185 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event,
1186 WebKit::WebCursorInfo& cursor_info) { 1186 blink::WebCursorInfo& cursor_info) {
1187 if (guest_crashed_ || !HasGuestInstanceID()) 1187 if (guest_crashed_ || !HasGuestInstanceID())
1188 return false; 1188 return false;
1189 1189
1190 if (event.type == WebKit::WebInputEvent::ContextMenu) 1190 if (event.type == blink::WebInputEvent::ContextMenu)
1191 return true; 1191 return true;
1192 1192
1193 const WebKit::WebInputEvent* modified_event = &event; 1193 const blink::WebInputEvent* modified_event = &event;
1194 scoped_ptr<WebKit::WebTouchEvent> touch_event; 1194 scoped_ptr<blink::WebTouchEvent> touch_event;
1195 // WebKit gives BrowserPlugin a list of touches that are down, but the browser 1195 // WebKit gives BrowserPlugin a list of touches that are down, but the browser
1196 // process expects a list of all touches. We modify the TouchEnd event here to 1196 // process expects a list of all touches. We modify the TouchEnd event here to
1197 // match these expectations. 1197 // match these expectations.
1198 if (event.type == WebKit::WebInputEvent::TouchEnd) { 1198 if (event.type == blink::WebInputEvent::TouchEnd) {
1199 const WebKit::WebTouchEvent* orig_touch_event = 1199 const blink::WebTouchEvent* orig_touch_event =
1200 static_cast<const WebKit::WebTouchEvent*>(&event); 1200 static_cast<const blink::WebTouchEvent*>(&event);
1201 touch_event.reset(new WebKit::WebTouchEvent()); 1201 touch_event.reset(new blink::WebTouchEvent());
1202 memcpy(touch_event.get(), orig_touch_event, sizeof(WebKit::WebTouchEvent)); 1202 memcpy(touch_event.get(), orig_touch_event, sizeof(blink::WebTouchEvent));
1203 if (touch_event->changedTouchesLength > 0) { 1203 if (touch_event->changedTouchesLength > 0) {
1204 memcpy(&touch_event->touches[touch_event->touchesLength], 1204 memcpy(&touch_event->touches[touch_event->touchesLength],
1205 &touch_event->changedTouches, 1205 &touch_event->changedTouches,
1206 touch_event->changedTouchesLength * sizeof(WebKit::WebTouchPoint)); 1206 touch_event->changedTouchesLength * sizeof(blink::WebTouchPoint));
1207 } 1207 }
1208 touch_event->touchesLength += touch_event->changedTouchesLength; 1208 touch_event->touchesLength += touch_event->changedTouchesLength;
1209 modified_event = touch_event.get(); 1209 modified_event = touch_event.get();
1210 } 1210 }
1211 1211
1212 if (WebKit::WebInputEvent::isKeyboardEventType(event.type) && 1212 if (blink::WebInputEvent::isKeyboardEventType(event.type) &&
1213 !edit_commands_.empty()) { 1213 !edit_commands_.empty()) {
1214 browser_plugin_manager()->Send( 1214 browser_plugin_manager()->Send(
1215 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( 1215 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent(
1216 render_view_routing_id_, 1216 render_view_routing_id_,
1217 guest_instance_id_, 1217 guest_instance_id_,
1218 edit_commands_)); 1218 edit_commands_));
1219 edit_commands_.clear(); 1219 edit_commands_.clear();
1220 } 1220 }
1221 1221
1222 browser_plugin_manager()->Send( 1222 browser_plugin_manager()->Send(
1223 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1223 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1224 guest_instance_id_, 1224 guest_instance_id_,
1225 plugin_rect_, 1225 plugin_rect_,
1226 modified_event)); 1226 modified_event));
1227 GetWebKitCursorInfo(cursor_, &cursor_info); 1227 GetWebKitCursorInfo(cursor_, &cursor_info);
1228 return true; 1228 return true;
1229 } 1229 }
1230 1230
1231 bool BrowserPlugin::handleDragStatusUpdate(WebKit::WebDragStatus drag_status, 1231 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status,
1232 const WebKit::WebDragData& drag_data, 1232 const blink::WebDragData& drag_data,
1233 WebKit::WebDragOperationsMask mask, 1233 blink::WebDragOperationsMask mask,
1234 const WebKit::WebPoint& position, 1234 const blink::WebPoint& position,
1235 const WebKit::WebPoint& screen) { 1235 const blink::WebPoint& screen) {
1236 if (guest_crashed_ || !HasGuestInstanceID()) 1236 if (guest_crashed_ || !HasGuestInstanceID())
1237 return false; 1237 return false;
1238 browser_plugin_manager()->Send( 1238 browser_plugin_manager()->Send(
1239 new BrowserPluginHostMsg_DragStatusUpdate( 1239 new BrowserPluginHostMsg_DragStatusUpdate(
1240 render_view_routing_id_, 1240 render_view_routing_id_,
1241 guest_instance_id_, 1241 guest_instance_id_,
1242 drag_status, 1242 drag_status,
1243 DropDataBuilder::Build(drag_data), 1243 DropDataBuilder::Build(drag_data),
1244 mask, 1244 mask,
1245 position)); 1245 position));
1246 return true; 1246 return true;
1247 } 1247 }
1248 1248
1249 void BrowserPlugin::didReceiveResponse( 1249 void BrowserPlugin::didReceiveResponse(
1250 const WebKit::WebURLResponse& response) { 1250 const blink::WebURLResponse& response) {
1251 } 1251 }
1252 1252
1253 void BrowserPlugin::didReceiveData(const char* data, int data_length) { 1253 void BrowserPlugin::didReceiveData(const char* data, int data_length) {
1254 } 1254 }
1255 1255
1256 void BrowserPlugin::didFinishLoading() { 1256 void BrowserPlugin::didFinishLoading() {
1257 } 1257 }
1258 1258
1259 void BrowserPlugin::didFailLoading(const WebKit::WebURLError& error) { 1259 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) {
1260 } 1260 }
1261 1261
1262 void BrowserPlugin::didFinishLoadingFrameRequest(const WebKit::WebURL& url, 1262 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url,
1263 void* notify_data) { 1263 void* notify_data) {
1264 } 1264 }
1265 1265
1266 void BrowserPlugin::didFailLoadingFrameRequest( 1266 void BrowserPlugin::didFailLoadingFrameRequest(
1267 const WebKit::WebURL& url, 1267 const blink::WebURL& url,
1268 void* notify_data, 1268 void* notify_data,
1269 const WebKit::WebURLError& error) { 1269 const blink::WebURLError& error) {
1270 } 1270 }
1271 1271
1272 bool BrowserPlugin::executeEditCommand(const WebKit::WebString& name) { 1272 bool BrowserPlugin::executeEditCommand(const blink::WebString& name) {
1273 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ExecuteEditCommand( 1273 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ExecuteEditCommand(
1274 render_view_routing_id_, 1274 render_view_routing_id_,
1275 guest_instance_id_, 1275 guest_instance_id_,
1276 name.utf8())); 1276 name.utf8()));
1277 1277
1278 // BrowserPlugin swallows edit commands. 1278 // BrowserPlugin swallows edit commands.
1279 return true; 1279 return true;
1280 } 1280 }
1281 1281
1282 bool BrowserPlugin::executeEditCommand(const WebKit::WebString& name, 1282 bool BrowserPlugin::executeEditCommand(const blink::WebString& name,
1283 const WebKit::WebString& value) { 1283 const blink::WebString& value) {
1284 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); 1284 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8()));
1285 // BrowserPlugin swallows edit commands. 1285 // BrowserPlugin swallows edit commands.
1286 return true; 1286 return true;
1287 } 1287 }
1288 1288
1289 void BrowserPlugin::OnLockMouseACK(bool succeeded) { 1289 void BrowserPlugin::OnLockMouseACK(bool succeeded) {
1290 mouse_locked_ = succeeded; 1290 mouse_locked_ = succeeded;
1291 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK( 1291 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK(
1292 render_view_routing_id_, 1292 render_view_routing_id_,
1293 guest_instance_id_, 1293 guest_instance_id_,
1294 succeeded)); 1294 succeeded));
1295 } 1295 }
1296 1296
1297 void BrowserPlugin::OnMouseLockLost() { 1297 void BrowserPlugin::OnMouseLockLost() {
1298 mouse_locked_ = false; 1298 mouse_locked_ = false;
1299 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( 1299 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK(
1300 render_view_routing_id_, 1300 render_view_routing_id_,
1301 guest_instance_id_)); 1301 guest_instance_id_));
1302 } 1302 }
1303 1303
1304 bool BrowserPlugin::HandleMouseLockedInputEvent( 1304 bool BrowserPlugin::HandleMouseLockedInputEvent(
1305 const WebKit::WebMouseEvent& event) { 1305 const blink::WebMouseEvent& event) {
1306 browser_plugin_manager()->Send( 1306 browser_plugin_manager()->Send(
1307 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1307 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1308 guest_instance_id_, 1308 guest_instance_id_,
1309 plugin_rect_, 1309 plugin_rect_,
1310 &event)); 1310 &event));
1311 return true; 1311 return true;
1312 } 1312 }
1313 1313
1314 } // namespace content 1314 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698