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

Side by Side Diff: webkit/plugins/npapi/webplugin_delegate_impl_mac.mm

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #import <QuartzCore/QuartzCore.h> 6 #import <QuartzCore/QuartzCore.h>
7 7
8 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
9 9
10 #include <string> 10 #include <string>
11 #include <unistd.h> 11 #include <unistd.h>
12 #include <set> 12 #include <set>
13 13
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/stats_counters.h" 16 #include "base/metrics/stats_counters.h"
17 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/sys_string_conversions.h" 20 #include "base/sys_string_conversions.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 21 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
22 #include "webkit/glue/plugins/plugin_instance.h"
23 #include "webkit/glue/plugins/plugin_lib.h"
24 #include "webkit/glue/plugins/plugin_list.h"
25 #include "webkit/glue/plugins/plugin_stream_url.h"
26 #include "webkit/glue/plugins/plugin_web_event_converter_mac.h"
27 #include "webkit/glue/plugins/webplugin.h"
28 #include "webkit/glue/plugins/webplugin_accelerated_surface_mac.h"
29 #include "webkit/glue/webkit_glue.h" 22 #include "webkit/glue/webkit_glue.h"
23 #include "webkit/plugins/npapi/plugin_instance.h"
24 #include "webkit/plugins/npapi/plugin_lib.h"
25 #include "webkit/plugins/npapi/plugin_list.h"
26 #include "webkit/plugins/npapi/plugin_stream_url.h"
27 #include "webkit/plugins/npapi/plugin_web_event_converter_mac.h"
28 #include "webkit/plugins/npapi/webplugin.h"
29 #include "webkit/plugins/npapi/webplugin_accelerated_surface_mac.h"
30 30
31 #ifndef NP_NO_CARBON 31 #ifndef NP_NO_CARBON
32 #include "webkit/glue/plugins/carbon_plugin_window_tracker_mac.h" 32 #include "webkit/plugins/npapi/carbon_plugin_window_tracker_mac.h"
33 #endif 33 #endif
34 34
35 #ifndef NP_NO_QUICKDRAW 35 #ifndef NP_NO_QUICKDRAW
36 #include "webkit/glue/plugins/quickdraw_drawing_manager_mac.h" 36 #include "webkit/plugins/npapi/quickdraw_drawing_manager_mac.h"
37 #endif 37 #endif
38 38
39 using webkit_glue::WebPlugin;
40 using webkit_glue::WebPluginDelegate;
41 using webkit_glue::WebPluginResourceClient;
42 using WebKit::WebCursorInfo; 39 using WebKit::WebCursorInfo;
43 using WebKit::WebKeyboardEvent; 40 using WebKit::WebKeyboardEvent;
44 using WebKit::WebInputEvent; 41 using WebKit::WebInputEvent;
45 using WebKit::WebMouseEvent; 42 using WebKit::WebMouseEvent;
46 using WebKit::WebMouseWheelEvent; 43 using WebKit::WebMouseWheelEvent;
47 44
48 const int kCoreAnimationRedrawPeriodMs = 10; // 100 Hz
49
50 // Important implementation notes: The Mac definition of NPAPI, particularly 45 // Important implementation notes: The Mac definition of NPAPI, particularly
51 // the distinction between windowed and windowless modes, differs from the 46 // the distinction between windowed and windowless modes, differs from the
52 // Windows and Linux definitions. Most of those differences are 47 // Windows and Linux definitions. Most of those differences are
53 // accomodated by the WebPluginDelegate class. 48 // accomodated by the WebPluginDelegate class.
54 49
50 namespace webkit {
51 namespace npapi {
52
55 namespace { 53 namespace {
56 54
55 const int kCoreAnimationRedrawPeriodMs = 10; // 100 Hz
56
57 WebPluginDelegateImpl* g_active_delegate; 57 WebPluginDelegateImpl* g_active_delegate;
58 58
59 // Helper to simplify correct usage of g_active_delegate. Instantiating will 59 // Helper to simplify correct usage of g_active_delegate. Instantiating will
60 // set the active delegate to |delegate| for the lifetime of the object, then 60 // set the active delegate to |delegate| for the lifetime of the object, then
61 // NULL when it goes out of scope. 61 // NULL when it goes out of scope.
62 class ScopedActiveDelegate { 62 class ScopedActiveDelegate {
63 public: 63 public:
64 explicit ScopedActiveDelegate(WebPluginDelegateImpl* delegate) { 64 explicit ScopedActiveDelegate(WebPluginDelegateImpl* delegate) {
65 g_active_delegate = delegate; 65 g_active_delegate = delegate;
66 } 66 }
67 ~ScopedActiveDelegate() { 67 ~ScopedActiveDelegate() {
68 g_active_delegate = NULL; 68 g_active_delegate = NULL;
69 } 69 }
70 private: 70
71 private:
71 DISALLOW_COPY_AND_ASSIGN(ScopedActiveDelegate); 72 DISALLOW_COPY_AND_ASSIGN(ScopedActiveDelegate);
72 }; 73 };
73 74
74 #ifndef NP_NO_CARBON 75 #ifndef NP_NO_CARBON
75 // Timer periods for sending idle events to Carbon plugins. The visible value 76 // Timer periods for sending idle events to Carbon plugins. The visible value
76 // (50Hz) matches both Safari and Firefox. The hidden value (8Hz) matches 77 // (50Hz) matches both Safari and Firefox. The hidden value (8Hz) matches
77 // Firefox; according to https://bugzilla.mozilla.org/show_bug.cgi?id=525533 78 // Firefox; according to https://bugzilla.mozilla.org/show_bug.cgi?id=525533
78 // going lower than that causes issues. 79 // going lower than that causes issues.
79 const int kVisibleIdlePeriodMs = 20; // (50Hz) 80 const int kVisibleIdlePeriodMs = 20; // (50Hz)
80 const int kHiddenIdlePeriodMs = 125; // (8Hz) 81 const int kHiddenIdlePeriodMs = 125; // (8Hz)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 return WebInputEvent::LeftButtonDown | 242 return WebInputEvent::LeftButtonDown |
242 WebInputEvent::RightButtonDown | 243 WebInputEvent::RightButtonDown |
243 WebInputEvent::MiddleButtonDown; 244 WebInputEvent::MiddleButtonDown;
244 } 245 }
245 246
246 #pragma mark - 247 #pragma mark -
247 #pragma mark Core WebPluginDelegate implementation 248 #pragma mark Core WebPluginDelegate implementation
248 249
249 WebPluginDelegateImpl::WebPluginDelegateImpl( 250 WebPluginDelegateImpl::WebPluginDelegateImpl(
250 gfx::PluginWindowHandle containing_view, 251 gfx::PluginWindowHandle containing_view,
251 NPAPI::PluginInstance *instance) 252 PluginInstance *instance)
252 : windowed_handle_(NULL), 253 : windowed_handle_(NULL),
253 // all Mac plugins are "windowless" in the Windows/X11 sense 254 // all Mac plugins are "windowless" in the Windows/X11 sense
254 windowless_(true), 255 windowless_(true),
255 plugin_(NULL), 256 plugin_(NULL),
256 instance_(instance), 257 instance_(instance),
257 parent_(containing_view), 258 parent_(containing_view),
258 quirks_(0), 259 quirks_(0),
259 buffer_context_(NULL), 260 buffer_context_(NULL),
260 layer_(nil), 261 layer_(nil),
261 surface_(NULL), 262 surface_(NULL),
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // If we add a page capture mode at the WebKit layer (like the plugin 562 // If we add a page capture mode at the WebKit layer (like the plugin
562 // capture mode that handles drags starting inside) this can be removed. 563 // capture mode that handles drags starting inside) this can be removed.
563 bool drag_related = external_drag_tracker_->EventIsRelatedToDrag(event); 564 bool drag_related = external_drag_tracker_->EventIsRelatedToDrag(event);
564 external_drag_tracker_->UpdateDragStateFromEvent(event); 565 external_drag_tracker_->UpdateDragStateFromEvent(event);
565 if (drag_related) { 566 if (drag_related) {
566 if (event.type == WebInputEvent::MouseUp && 567 if (event.type == WebInputEvent::MouseUp &&
567 !external_drag_tracker_->IsDragInProgress()) { 568 !external_drag_tracker_->IsDragInProgress()) {
568 // When an external drag ends, we need to synthesize a MouseEntered. 569 // When an external drag ends, we need to synthesize a MouseEntered.
569 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event)); 570 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event));
570 enter_event.type = NPCocoaEventMouseEntered; 571 enter_event.type = NPCocoaEventMouseEntered;
571 NPAPI::ScopedCurrentPluginEvent event_scope(instance(), &enter_event); 572 ScopedCurrentPluginEvent event_scope(instance(), &enter_event);
572 instance()->NPP_HandleEvent(&enter_event); 573 instance()->NPP_HandleEvent(&enter_event);
573 } 574 }
574 return false; 575 return false;
575 } 576 }
576 } 577 }
577 578
578 // Send the plugin the event. 579 // Send the plugin the event.
579 scoped_ptr<NPAPI::ScopedCurrentPluginEvent> event_scope(NULL); 580 scoped_ptr<ScopedCurrentPluginEvent> event_scope(NULL);
580 if (instance()->event_model() == NPEventModelCocoa) { 581 if (instance()->event_model() == NPEventModelCocoa) {
581 event_scope.reset(new NPAPI::ScopedCurrentPluginEvent( 582 event_scope.reset(new ScopedCurrentPluginEvent(
582 instance(), static_cast<NPCocoaEvent*>(plugin_event))); 583 instance(), static_cast<NPCocoaEvent*>(plugin_event)));
583 } 584 }
584 int16_t handle_response = instance()->NPP_HandleEvent(plugin_event); 585 int16_t handle_response = instance()->NPP_HandleEvent(plugin_event);
585 bool handled = handle_response != kNPEventNotHandled; 586 bool handled = handle_response != kNPEventNotHandled;
586 587
587 if (handled && event.type == WebInputEvent::KeyDown) { 588 if (handled && event.type == WebInputEvent::KeyDown) {
588 // Update IME state as requested by the plugin. 589 // Update IME state as requested by the plugin.
589 SetImeEnabled(handle_response == kNPEventStartIME); 590 SetImeEnabled(handle_response == kNPEventStartIME);
590 } 591 }
591 592
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 return; 1137 return;
1137 } 1138 }
1138 1139
1139 qd_manager_->SetFastPathEnabled(enabled); 1140 qd_manager_->SetFastPathEnabled(enabled);
1140 qd_port_.port = qd_manager_->port(); 1141 qd_port_.port = qd_manager_->port();
1141 WindowlessSetWindow(); 1142 WindowlessSetWindow();
1142 // Send a paint event so that the new buffer gets updated immediately. 1143 // Send a paint event so that the new buffer gets updated immediately.
1143 WindowlessPaint(buffer_context_, clip_rect_); 1144 WindowlessPaint(buffer_context_, clip_rect_);
1144 } 1145 }
1145 #endif // !NP_NO_QUICKDRAW 1146 #endif // !NP_NO_QUICKDRAW
1147
1148 } // namespace npapi
1149 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc ('k') | webkit/plugins/npapi/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698