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

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

Issue 5998002: Revert "Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi" (Closed) Base URL: svn://svn.chromium.org/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/plugins/npapi/webplugin_delegate_impl.h" 8 #include "webkit/glue/plugins/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"
22 #include "webkit/glue/webkit_glue.h" 29 #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/plugins/npapi/carbon_plugin_window_tracker_mac.h" 32 #include "webkit/glue/plugins/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/plugins/npapi/quickdraw_drawing_manager_mac.h" 36 #include "webkit/glue/plugins/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;
39 using WebKit::WebCursorInfo; 42 using WebKit::WebCursorInfo;
40 using WebKit::WebKeyboardEvent; 43 using WebKit::WebKeyboardEvent;
41 using WebKit::WebInputEvent; 44 using WebKit::WebInputEvent;
42 using WebKit::WebMouseEvent; 45 using WebKit::WebMouseEvent;
43 using WebKit::WebMouseWheelEvent; 46 using WebKit::WebMouseWheelEvent;
44 47
48 const int kCoreAnimationRedrawPeriodMs = 10; // 100 Hz
49
45 // Important implementation notes: The Mac definition of NPAPI, particularly 50 // Important implementation notes: The Mac definition of NPAPI, particularly
46 // the distinction between windowed and windowless modes, differs from the 51 // the distinction between windowed and windowless modes, differs from the
47 // Windows and Linux definitions. Most of those differences are 52 // Windows and Linux definitions. Most of those differences are
48 // accomodated by the WebPluginDelegate class. 53 // accomodated by the WebPluginDelegate class.
49 54
50 namespace webkit {
51 namespace npapi {
52
53 namespace { 55 namespace {
54 56
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 70 private:
71 private:
72 DISALLOW_COPY_AND_ASSIGN(ScopedActiveDelegate); 71 DISALLOW_COPY_AND_ASSIGN(ScopedActiveDelegate);
73 }; 72 };
74 73
75 #ifndef NP_NO_CARBON 74 #ifndef NP_NO_CARBON
76 // Timer periods for sending idle events to Carbon plugins. The visible value 75 // Timer periods for sending idle events to Carbon plugins. The visible value
77 // (50Hz) matches both Safari and Firefox. The hidden value (8Hz) matches 76 // (50Hz) matches both Safari and Firefox. The hidden value (8Hz) matches
78 // Firefox; according to https://bugzilla.mozilla.org/show_bug.cgi?id=525533 77 // Firefox; according to https://bugzilla.mozilla.org/show_bug.cgi?id=525533
79 // going lower than that causes issues. 78 // going lower than that causes issues.
80 const int kVisibleIdlePeriodMs = 20; // (50Hz) 79 const int kVisibleIdlePeriodMs = 20; // (50Hz)
81 const int kHiddenIdlePeriodMs = 125; // (8Hz) 80 const int kHiddenIdlePeriodMs = 125; // (8Hz)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return WebInputEvent::LeftButtonDown | 241 return WebInputEvent::LeftButtonDown |
243 WebInputEvent::RightButtonDown | 242 WebInputEvent::RightButtonDown |
244 WebInputEvent::MiddleButtonDown; 243 WebInputEvent::MiddleButtonDown;
245 } 244 }
246 245
247 #pragma mark - 246 #pragma mark -
248 #pragma mark Core WebPluginDelegate implementation 247 #pragma mark Core WebPluginDelegate implementation
249 248
250 WebPluginDelegateImpl::WebPluginDelegateImpl( 249 WebPluginDelegateImpl::WebPluginDelegateImpl(
251 gfx::PluginWindowHandle containing_view, 250 gfx::PluginWindowHandle containing_view,
252 PluginInstance *instance) 251 NPAPI::PluginInstance *instance)
253 : windowed_handle_(NULL), 252 : windowed_handle_(NULL),
254 // all Mac plugins are "windowless" in the Windows/X11 sense 253 // all Mac plugins are "windowless" in the Windows/X11 sense
255 windowless_(true), 254 windowless_(true),
256 plugin_(NULL), 255 plugin_(NULL),
257 instance_(instance), 256 instance_(instance),
258 parent_(containing_view), 257 parent_(containing_view),
259 quirks_(0), 258 quirks_(0),
260 buffer_context_(NULL), 259 buffer_context_(NULL),
261 layer_(nil), 260 layer_(nil),
262 surface_(NULL), 261 surface_(NULL),
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 // If we add a page capture mode at the WebKit layer (like the plugin 561 // If we add a page capture mode at the WebKit layer (like the plugin
563 // capture mode that handles drags starting inside) this can be removed. 562 // capture mode that handles drags starting inside) this can be removed.
564 bool drag_related = external_drag_tracker_->EventIsRelatedToDrag(event); 563 bool drag_related = external_drag_tracker_->EventIsRelatedToDrag(event);
565 external_drag_tracker_->UpdateDragStateFromEvent(event); 564 external_drag_tracker_->UpdateDragStateFromEvent(event);
566 if (drag_related) { 565 if (drag_related) {
567 if (event.type == WebInputEvent::MouseUp && 566 if (event.type == WebInputEvent::MouseUp &&
568 !external_drag_tracker_->IsDragInProgress()) { 567 !external_drag_tracker_->IsDragInProgress()) {
569 // When an external drag ends, we need to synthesize a MouseEntered. 568 // When an external drag ends, we need to synthesize a MouseEntered.
570 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event)); 569 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event));
571 enter_event.type = NPCocoaEventMouseEntered; 570 enter_event.type = NPCocoaEventMouseEntered;
572 ScopedCurrentPluginEvent event_scope(instance(), &enter_event); 571 NPAPI::ScopedCurrentPluginEvent event_scope(instance(), &enter_event);
573 instance()->NPP_HandleEvent(&enter_event); 572 instance()->NPP_HandleEvent(&enter_event);
574 } 573 }
575 return false; 574 return false;
576 } 575 }
577 } 576 }
578 577
579 // Send the plugin the event. 578 // Send the plugin the event.
580 scoped_ptr<ScopedCurrentPluginEvent> event_scope(NULL); 579 scoped_ptr<NPAPI::ScopedCurrentPluginEvent> event_scope(NULL);
581 if (instance()->event_model() == NPEventModelCocoa) { 580 if (instance()->event_model() == NPEventModelCocoa) {
582 event_scope.reset(new ScopedCurrentPluginEvent( 581 event_scope.reset(new NPAPI::ScopedCurrentPluginEvent(
583 instance(), static_cast<NPCocoaEvent*>(plugin_event))); 582 instance(), static_cast<NPCocoaEvent*>(plugin_event)));
584 } 583 }
585 int16_t handle_response = instance()->NPP_HandleEvent(plugin_event); 584 int16_t handle_response = instance()->NPP_HandleEvent(plugin_event);
586 bool handled = handle_response != kNPEventNotHandled; 585 bool handled = handle_response != kNPEventNotHandled;
587 586
588 if (handled && event.type == WebInputEvent::KeyDown) { 587 if (handled && event.type == WebInputEvent::KeyDown) {
589 // Update IME state as requested by the plugin. 588 // Update IME state as requested by the plugin.
590 SetImeEnabled(handle_response == kNPEventStartIME); 589 SetImeEnabled(handle_response == kNPEventStartIME);
591 } 590 }
592 591
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 return; 1136 return;
1138 } 1137 }
1139 1138
1140 qd_manager_->SetFastPathEnabled(enabled); 1139 qd_manager_->SetFastPathEnabled(enabled);
1141 qd_port_.port = qd_manager_->port(); 1140 qd_port_.port = qd_manager_->port();
1142 WindowlessSetWindow(); 1141 WindowlessSetWindow();
1143 // Send a paint event so that the new buffer gets updated immediately. 1142 // Send a paint event so that the new buffer gets updated immediately.
1144 WindowlessPaint(buffer_context_, clip_rect_); 1143 WindowlessPaint(buffer_context_, clip_rect_);
1145 } 1144 }
1146 #endif // !NP_NO_QUICKDRAW 1145 #endif // !NP_NO_QUICKDRAW
1147
1148 } // namespace npapi
1149 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/glue/plugins/webplugin_delegate_impl_gtk.cc ('k') | webkit/glue/plugins/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698