OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #import "content/browser/web_contents/web_drag_dest_mac.h" | 5 #import "content/browser/web_contents/web_drag_dest_mac.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
13 #include "content/public/browser/web_drag_dest_delegate.h" | 13 #include "content/public/browser/web_drag_dest_delegate.h" |
14 #include "content/public/common/drop_data.h" | 14 #include "content/public/common/drop_data.h" |
15 #import "third_party/mozilla/NSPasteboard+Utils.h" | 15 #import "third_party/mozilla/NSPasteboard+Utils.h" |
16 #include "third_party/WebKit/public/web/WebInputEvent.h" | 16 #include "third_party/WebKit/public/web/WebInputEvent.h" |
17 #include "ui/base/clipboard/custom_data_helper.h" | 17 #include "ui/base/clipboard/custom_data_helper.h" |
18 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 18 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
19 #include "ui/base/window_open_disposition.h" | 19 #include "ui/base/window_open_disposition.h" |
20 | 20 |
21 using blink::WebDragOperationsMask; | 21 using blink::WebDragOperationsMask; |
22 using content::DropData; | 22 using content::DropData; |
23 using content::OpenURLParams; | 23 using content::OpenURLParams; |
24 using content::Referrer; | 24 using content::Referrer; |
25 using content::WebContentsImpl; | 25 using content::WebContentsImpl; |
26 | 26 |
27 namespace { | |
28 | |
27 int GetModifierFlags() { | 29 int GetModifierFlags() { |
28 int modifier_state = 0; | 30 int modifier_state = 0; |
29 UInt32 currentModifiers = GetCurrentKeyModifiers(); | 31 UInt32 currentModifiers = GetCurrentKeyModifiers(); |
30 if (currentModifiers & ::shiftKey) | 32 if (currentModifiers & ::shiftKey) |
31 modifier_state |= blink::WebInputEvent::ShiftKey; | 33 modifier_state |= blink::WebInputEvent::ShiftKey; |
32 if (currentModifiers & ::controlKey) | 34 if (currentModifiers & ::controlKey) |
33 modifier_state |= blink::WebInputEvent::ControlKey; | 35 modifier_state |= blink::WebInputEvent::ControlKey; |
34 if (currentModifiers & ::optionKey) | 36 if (currentModifiers & ::optionKey) |
35 modifier_state |= blink::WebInputEvent::AltKey; | 37 modifier_state |= blink::WebInputEvent::AltKey; |
36 if (currentModifiers & ::cmdKey) | 38 if (currentModifiers & ::cmdKey) |
37 modifier_state |= blink::WebInputEvent::MetaKey; | 39 modifier_state |= blink::WebInputEvent::MetaKey; |
40 | |
41 // The return value of 1 << 0 corresponds to the left mouse button, | |
42 // 1 << 1 corresponds to the right mouse button, | |
43 // 1 << n, n >= 2 correspond to other mouse buttons. | |
44 NSUInteger pressedButtons = [NSEvent pressedMouseButtons]; | |
45 | |
46 if (pressedButtons & (1 << 0)) | |
47 modifier_state |= blink::WebInputEvent::LeftButtonDown; | |
48 if (pressedButtons & (1 << 1)) | |
49 modifier_state |= blink::WebInputEvent::RightButtonDown; | |
50 if (pressedButtons & (1 << 2)) | |
51 modifier_state |= blink::WebInputEvent::MiddleButtonDown; | |
52 | |
38 return modifier_state; | 53 return modifier_state; |
39 } | 54 } |
40 | 55 |
56 } // namespace | |
Avi (use Gerrit)
2015/03/11 02:08:15
two spaces between } and //
| |
57 | |
41 @implementation WebDragDest | 58 @implementation WebDragDest |
42 | 59 |
43 // |contents| is the WebContentsImpl representing this tab, used to communicate | 60 // |contents| is the WebContentsImpl representing this tab, used to communicate |
44 // drag&drop messages to WebCore and handle navigation on a successful drop | 61 // drag&drop messages to WebCore and handle navigation on a successful drop |
45 // (if necessary). | 62 // (if necessary). |
46 - (id)initWithWebContentsImpl:(WebContentsImpl*)contents { | 63 - (id)initWithWebContentsImpl:(WebContentsImpl*)contents { |
47 if ((self = [super init])) { | 64 if ((self = [super init])) { |
48 webContents_ = contents; | 65 webContents_ = contents; |
49 canceled_ = false; | 66 canceled_ = false; |
50 } | 67 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 // Get custom MIME data. | 321 // Get custom MIME data. |
305 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 322 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
306 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 323 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
307 ui::ReadCustomDataIntoMap([customData bytes], | 324 ui::ReadCustomDataIntoMap([customData bytes], |
308 [customData length], | 325 [customData length], |
309 &data->custom_data); | 326 &data->custom_data); |
310 } | 327 } |
311 } | 328 } |
312 | 329 |
313 @end | 330 @end |
OLD | NEW |