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

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

Issue 7538006: Pepper and WebKit API change to support a plugin knowing if a scrollbar is an overlay one. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get rid of ScrollbarGroup's methods and the ResizeClient interface Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "webkit/plugins/ppapi/message_channel.h" 54 #include "webkit/plugins/ppapi/message_channel.h"
55 #include "webkit/plugins/ppapi/npapi_glue.h" 55 #include "webkit/plugins/ppapi/npapi_glue.h"
56 #include "webkit/plugins/ppapi/plugin_delegate.h" 56 #include "webkit/plugins/ppapi/plugin_delegate.h"
57 #include "webkit/plugins/ppapi/plugin_module.h" 57 #include "webkit/plugins/ppapi/plugin_module.h"
58 #include "webkit/plugins/ppapi/plugin_object.h" 58 #include "webkit/plugins/ppapi/plugin_object.h"
59 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 59 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
60 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 60 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
61 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 61 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
62 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 62 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
63 #include "webkit/plugins/ppapi/ppb_input_event_impl.h" 63 #include "webkit/plugins/ppapi/ppb_input_event_impl.h"
64 #include "webkit/plugins/ppapi/ppb_scrollbar_group_impl.h"
64 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" 65 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
65 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" 66 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
66 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" 67 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
67 #include "webkit/plugins/ppapi/ppp_pdf.h" 68 #include "webkit/plugins/ppapi/ppp_pdf.h"
68 #include "webkit/plugins/ppapi/string.h" 69 #include "webkit/plugins/ppapi/string.h"
69 #include "webkit/plugins/sad_plugin.h" 70 #include "webkit/plugins/sad_plugin.h"
70 71
71 #if defined(OS_MACOSX) 72 #if defined(OS_MACOSX)
72 #include "base/mac/mac_util.h" 73 #include "base/mac/mac_util.h"
73 #include "base/mac/scoped_cftyperef.h" 74 #include "base/mac/scoped_cftyperef.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 checked_for_plugin_input_event_interface_(false), 229 checked_for_plugin_input_event_interface_(false),
229 checked_for_plugin_messaging_interface_(false), 230 checked_for_plugin_messaging_interface_(false),
230 plugin_print_interface_(NULL), 231 plugin_print_interface_(NULL),
231 plugin_graphics_3d_interface_(NULL), 232 plugin_graphics_3d_interface_(NULL),
232 always_on_top_(false), 233 always_on_top_(false),
233 fullscreen_container_(NULL), 234 fullscreen_container_(NULL),
234 fullscreen_(false), 235 fullscreen_(false),
235 message_channel_(NULL), 236 message_channel_(NULL),
236 sad_plugin_(NULL), 237 sad_plugin_(NULL),
237 input_event_mask_(0), 238 input_event_mask_(0),
238 filtered_input_event_mask_(0) { 239 filtered_input_event_mask_(0),
240 scrollbar_group_(NULL) {
239 pp_instance_ = ResourceTracker::Get()->AddInstance(this); 241 pp_instance_ = ResourceTracker::Get()->AddInstance(this);
240 242
241 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 243 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
242 DCHECK(delegate); 244 DCHECK(delegate);
243 module_->InstanceCreated(this); 245 module_->InstanceCreated(this);
244 delegate_->InstanceCreated(this); 246 delegate_->InstanceCreated(this);
245 message_channel_.reset(new MessageChannel(this)); 247 message_channel_.reset(new MessageChannel(this));
246 } 248 }
247 249
248 PluginInstance::~PluginInstance() { 250 PluginInstance::~PluginInstance() {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 Resource::ScopedResourceId resource(loader); 436 Resource::ScopedResourceId resource(loader);
435 return PP_ToBool(instance_interface_->HandleDocumentLoad(pp_instance(), 437 return PP_ToBool(instance_interface_->HandleDocumentLoad(pp_instance(),
436 resource.id)); 438 resource.id));
437 } 439 }
438 440
439 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, 441 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event,
440 WebCursorInfo* cursor_info) { 442 WebCursorInfo* cursor_info) {
441 // Keep a reference on the stack. See NOTE above. 443 // Keep a reference on the stack. See NOTE above.
442 scoped_refptr<PluginInstance> ref(this); 444 scoped_refptr<PluginInstance> ref(this);
443 445
446 if (scrollbar_group_) {
447 if (event.type == WebInputEvent::MouseEnter) {
448 scrollbar_group_->MouseEnteredContentArea();
449 } else if (event.type == WebInputEvent::MouseMove) {
450 scrollbar_group_->MouseMovedInContentArea();
451 } else if (event.type == WebInputEvent::MouseLeave) {
452 scrollbar_group_->MouseExitedContentArea();
453 }
454 }
455
444 bool rv = false; 456 bool rv = false;
445 if (LoadInputEventInterface()) { 457 if (LoadInputEventInterface()) {
446 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); 458 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type);
447 if (!event_class) 459 if (!event_class)
448 return false; 460 return false;
449 461
450 if ((filtered_input_event_mask_ & event_class) || 462 if ((filtered_input_event_mask_ & event_class) ||
451 (input_event_mask_ & event_class)) { 463 (input_event_mask_ & event_class)) {
452 // Actually send the event. 464 // Actually send the event.
453 std::vector< ::ppapi::InputEventData > events; 465 std::vector< ::ppapi::InputEventData > events;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 if (clip.IsEmpty()) { 525 if (clip.IsEmpty()) {
514 // WebKit can give weird (x,y) positions for empty clip rects (since the 526 // WebKit can give weird (x,y) positions for empty clip rects (since the
515 // position technically doesn't matter). But we want to make these 527 // position technically doesn't matter). But we want to make these
516 // consistent since this is given to the plugin, so force everything to 0 528 // consistent since this is given to the plugin, so force everything to 0
517 // in the "everything is clipped" case. 529 // in the "everything is clipped" case.
518 clip_ = gfx::Rect(); 530 clip_ = gfx::Rect();
519 } else { 531 } else {
520 clip_ = clip; 532 clip_ = clip;
521 } 533 }
522 534
535 if (scrollbar_group_)
536 scrollbar_group_->ContentResized();
537
523 PP_Rect pp_position, pp_clip; 538 PP_Rect pp_position, pp_clip;
524 RectToPPRect(position_, &pp_position); 539 RectToPPRect(position_, &pp_position);
525 RectToPPRect(clip_, &pp_clip); 540 RectToPPRect(clip_, &pp_clip);
526 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); 541 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip);
527 } 542 }
528 543
529 void PluginInstance::SetWebKitFocus(bool has_focus) { 544 void PluginInstance::SetWebKitFocus(bool has_focus) {
530 if (has_webkit_focus_ == has_focus) 545 if (has_webkit_focus_ == has_focus)
531 return; 546 return;
532 547
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 680
666 void PluginInstance::StopFind() { 681 void PluginInstance::StopFind() {
667 // Keep a reference on the stack. See NOTE above. 682 // Keep a reference on the stack. See NOTE above.
668 scoped_refptr<PluginInstance> ref(this); 683 scoped_refptr<PluginInstance> ref(this);
669 if (!LoadFindInterface()) 684 if (!LoadFindInterface())
670 return; 685 return;
671 find_identifier_ = -1; 686 find_identifier_ = -1;
672 plugin_find_interface_->StopFind(pp_instance()); 687 plugin_find_interface_->StopFind(pp_instance());
673 } 688 }
674 689
690 void PluginInstance::WillStartLiveResize() {
691 if (scrollbar_group_)
692 scrollbar_group_->WillStartLiveResize();
693 }
694
695 void PluginInstance::WillEndLiveResize() {
696 if (scrollbar_group_)
697 scrollbar_group_->WillEndLiveResize();
698 }
699
675 bool PluginInstance::LoadFindInterface() { 700 bool PluginInstance::LoadFindInterface() {
676 if (!plugin_find_interface_) { 701 if (!plugin_find_interface_) {
677 plugin_find_interface_ = 702 plugin_find_interface_ =
678 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( 703 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface(
679 PPP_FIND_DEV_INTERFACE)); 704 PPP_FIND_DEV_INTERFACE));
680 } 705 }
681 706
682 return !!plugin_find_interface_; 707 return !!plugin_find_interface_;
683 } 708 }
684 709
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 // Don't actually verify that the object is in the set since during module 1350 // Don't actually verify that the object is in the set since during module
1326 // deletion we'll be in the process of freeing them. 1351 // deletion we'll be in the process of freeing them.
1327 live_plugin_objects_.erase(plugin_object); 1352 live_plugin_objects_.erase(plugin_object);
1328 } 1353 }
1329 1354
1330 bool PluginInstance::IsFullPagePlugin() const { 1355 bool PluginInstance::IsFullPagePlugin() const {
1331 WebFrame* frame = container()->element().document().frame(); 1356 WebFrame* frame = container()->element().document().frame();
1332 return frame->view()->mainFrame()->document().isPluginDocument(); 1357 return frame->view()->mainFrame()->document().isPluginDocument();
1333 } 1358 }
1334 1359
1360 void PluginInstance::SetScrollbarGroup(
1361 PPB_ScrollbarGroup_Impl* scrollbar_group) {
1362 if (!IsFullPagePlugin())
1363 return;
1364
1365 // Only handle one scrollbar group for now, i.e. the normal case of one group
1366 // for a full-page plugin.
1367 DCHECK(!scrollbar_group || !scrollbar_group_);
1368 scrollbar_group_ = scrollbar_group;
1369 }
1370
1335 PPB_Instance_FunctionAPI* PluginInstance::AsPPB_Instance_FunctionAPI() { 1371 PPB_Instance_FunctionAPI* PluginInstance::AsPPB_Instance_FunctionAPI() {
1336 return this; 1372 return this;
1337 } 1373 }
1338 1374
1339 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, 1375 PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
1340 PP_Resource device) { 1376 PP_Resource device) {
1341 if (bound_graphics_.get()) { 1377 if (bound_graphics_.get()) {
1342 if (GetBoundGraphics2D()) { 1378 if (GetBoundGraphics2D()) {
1343 GetBoundGraphics2D()->BindToInstance(NULL); 1379 GetBoundGraphics2D()->BindToInstance(NULL);
1344 } else if (GetBoundGraphics3D()) { 1380 } else if (GetBoundGraphics3D()) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { 1574 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
1539 message_channel_->PostMessageToJavaScript(message); 1575 message_channel_->PostMessageToJavaScript(message);
1540 } 1576 }
1541 1577
1542 void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) { 1578 void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) {
1543 delegate()->SubscribeToPolicyUpdates(this); 1579 delegate()->SubscribeToPolicyUpdates(this);
1544 } 1580 }
1545 1581
1546 } // namespace ppapi 1582 } // namespace ppapi
1547 } // namespace webkit 1583 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698