Chromium Code Reviews

Side by Side Diff: webkit/glue/plugins/plugin_instance_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.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/plugin_instance.cc ('k') | webkit/glue/plugins/plugin_lib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "build/build_config.h"
6
5 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
6 8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "build/build_config.h" 10 #include "webkit/glue/plugins/plugin_instance.h"
9 #include "webkit/plugins/npapi/plugin_instance.h"
10 11
11 // When C++ exceptions are disabled, the C++ library defines |try| and 12 // When C++ exceptions are disabled, the C++ library defines |try| and
12 // |catch| so as to allow exception-expecting C++ code to build properly when 13 // |catch| so as to allow exception-expecting C++ code to build properly when
13 // language support for exceptions is not present. These macros interfere 14 // language support for exceptions is not present. These macros interfere
14 // with the use of |@try| and |@catch| in Objective-C files such as this one. 15 // with the use of |@try| and |@catch| in Objective-C files such as this one.
15 // Undefine these macros here, after everything has been #included, since 16 // Undefine these macros here, after everything has been #included, since
16 // there will be no C++ uses and only Objective-C uses from this point on. 17 // there will be no C++ uses and only Objective-C uses from this point on.
17 #undef try 18 #undef try
18 #undef catch 19 #undef catch
19 20
20 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 21 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
21 @interface NSMenu (SnowLeopardMenuPopUpDeclaration) 22 @interface NSMenu (SnowLeopardMenuPopUpDeclaration)
22 - (BOOL)popUpMenuPositioningItem:(NSMenuItem*)item 23 - (BOOL)popUpMenuPositioningItem:(NSMenuItem*)item
23 atLocation:(NSPoint)location 24 atLocation:(NSPoint)location
24 inView:(NSView*)view; 25 inView:(NSView*)view;
25 @end 26 @end
26 #endif 27 #endif
27 28
28 namespace webkit {
29 namespace npapi {
30
31 namespace { 29 namespace {
32 30
33 // Returns an autoreleased NSEvent constructed from the given np_event, 31 // Returns an autoreleased NSEvent constructed from the given np_event,
34 // targeting the given window. 32 // targeting the given window.
35 NSEvent* NSEventForNPCocoaEvent(NPCocoaEvent* np_event, NSWindow* window) { 33 NSEvent* NSEventForNPCocoaEvent(NPCocoaEvent* np_event, NSWindow* window) {
36 bool mouse_down = 1; 34 bool mouse_down = 1;
37 switch (np_event->type) { 35 switch (np_event->type) {
38 case NPCocoaEventMouseDown: 36 case NPCocoaEventMouseDown:
39 mouse_down = 1; 37 mouse_down = 1;
40 break; 38 break;
(...skipping 30 matching lines...)
71 windowNumber:[window windowNumber] 69 windowNumber:[window windowNumber]
72 context:[NSGraphicsContext currentContext] 70 context:[NSGraphicsContext currentContext]
73 eventNumber:0 71 eventNumber:0
74 clickCount:click_count 72 clickCount:click_count
75 pressure:1.0]; 73 pressure:1.0];
76 return event; 74 return event;
77 } 75 }
78 76
79 } // namespace 77 } // namespace
80 78
79 namespace NPAPI {
80
81 NPError PluginInstance::PopUpContextMenu(NPMenu* menu) { 81 NPError PluginInstance::PopUpContextMenu(NPMenu* menu) {
82 if (!currently_handled_event_) 82 if (!currently_handled_event_)
83 return NPERR_GENERIC_ERROR; 83 return NPERR_GENERIC_ERROR;
84 84
85 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); 85 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID());
86 NSPoint screen_point = NSMakePoint( 86 NSPoint screen_point = NSMakePoint(
87 plugin_origin_.x() + currently_handled_event_->data.mouse.pluginX, 87 plugin_origin_.x() + currently_handled_event_->data.mouse.pluginX,
88 plugin_origin_.y() + currently_handled_event_->data.mouse.pluginY); 88 plugin_origin_.y() + currently_handled_event_->data.mouse.pluginY);
89 // Plugin offsets are upper-left based, so flip vertically for Cocoa. 89 // Plugin offsets are upper-left based, so flip vertically for Cocoa.
90 screen_point.y = main_display_bounds.size.height - screen_point.y; 90 screen_point.y = main_display_bounds.size.height - screen_point.y;
(...skipping 32 matching lines...)
123 [window release]; 123 [window release];
124 } 124 }
125 @catch (NSException* e) { 125 @catch (NSException* e) {
126 NSLog(@"Caught exception while cleaning up in PopUpContextMenu: %@", e); 126 NSLog(@"Caught exception while cleaning up in PopUpContextMenu: %@", e);
127 } 127 }
128 } 128 }
129 129
130 return return_val; 130 return return_val;
131 } 131 }
132 132
133 } // namespace npapi 133 } // namespace NPAPI
134 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_instance.cc ('k') | webkit/glue/plugins/plugin_lib.h » ('j') | no next file with comments »

Powered by Google App Engine