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 <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/tab_contents/web_contents_view_mac.h" | 7 #import "content/browser/tab_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #import "base/mac/scoped_sending_event.h" | 11 #import "base/mac/scoped_sending_event.h" |
12 #import "base/message_pump_mac.h" | 12 #import "base/message_pump_mac.h" |
13 #include "content/browser/renderer_host/render_view_host_factory.h" | 13 #include "content/browser/renderer_host/render_view_host_factory.h" |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
15 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
16 #include "content/browser/tab_contents/popup_menu_helper_mac.h" | 16 #include "content/browser/tab_contents/popup_menu_helper_mac.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #import "content/browser/tab_contents/web_drag_dest_mac.h" | 18 #import "content/browser/tab_contents/web_drag_dest_mac.h" |
19 #import "content/browser/tab_contents/web_drag_source_mac.h" | 19 #import "content/browser/tab_contents/web_drag_source_mac.h" |
20 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
21 #include "content/public/browser/web_contents_delegate.h" | 21 #include "content/public/browser/web_contents_delegate.h" |
22 #include "content/public/browser/web_contents_view_mac_delegate.h" | 22 #include "content/public/browser/web_contents_view_delegate.h" |
23 #include "skia/ext/skia_utils_mac.h" | 23 #include "skia/ext/skia_utils_mac.h" |
24 #import "third_party/mozilla/NSPasteboard+Utils.h" | 24 #import "third_party/mozilla/NSPasteboard+Utils.h" |
25 #import "ui/base/cocoa/focus_tracker.h" | 25 #import "ui/base/cocoa/focus_tracker.h" |
26 | 26 |
27 using WebKit::WebDragOperation; | 27 using WebKit::WebDragOperation; |
28 using WebKit::WebDragOperationsMask; | 28 using WebKit::WebDragOperationsMask; |
29 using content::RenderWidgetHostView; | 29 using content::RenderWidgetHostView; |
30 using content::WebContents; | 30 using content::WebContents; |
31 | 31 |
32 // Ensure that the WebKit::WebDragOperation enum values stay in sync with | 32 // Ensure that the WebKit::WebDragOperation enum values stay in sync with |
(...skipping 19 matching lines...) Expand all Loading... |
52 offset:(NSPoint)offset; | 52 offset:(NSPoint)offset; |
53 - (void)cancelDeferredClose; | 53 - (void)cancelDeferredClose; |
54 - (void)clearTabContentsView; | 54 - (void)clearTabContentsView; |
55 - (void)closeTabAfterEvent; | 55 - (void)closeTabAfterEvent; |
56 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; | 56 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; |
57 @end | 57 @end |
58 | 58 |
59 namespace web_contents_view_mac { | 59 namespace web_contents_view_mac { |
60 content::WebContentsView* CreateWebContentsView( | 60 content::WebContentsView* CreateWebContentsView( |
61 WebContents* web_contents, | 61 WebContents* web_contents, |
62 content::WebContentsViewMacDelegate* delegate) { | 62 content::WebContentsViewDelegate* delegate) { |
63 return new WebContentsViewMac(web_contents, delegate); | 63 return new WebContentsViewMac(web_contents, delegate); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 WebContentsViewMac::WebContentsViewMac( | 67 WebContentsViewMac::WebContentsViewMac( |
68 WebContents* web_contents, | 68 WebContents* web_contents, |
69 content::WebContentsViewMacDelegate* delegate) | 69 content::WebContentsViewDelegate* delegate) |
70 : tab_contents_(static_cast<TabContents*>(web_contents)), | 70 : tab_contents_(static_cast<TabContents*>(web_contents)), |
71 delegate_(delegate) { | 71 delegate_(delegate) { |
72 } | 72 } |
73 | 73 |
74 WebContentsViewMac::~WebContentsViewMac() { | 74 WebContentsViewMac::~WebContentsViewMac() { |
75 // This handles the case where a renderer close call was deferred | 75 // This handles the case where a renderer close call was deferred |
76 // while the user was operating a UI control which resulted in a | 76 // while the user was operating a UI control which resulted in a |
77 // close. In that case, the Cocoa view outlives the | 77 // close. In that case, the Cocoa view outlives the |
78 // WebContentsViewMac instance due to Cocoa retain count. | 78 // WebContentsViewMac instance due to Cocoa retain count. |
79 [cocoa_view_ cancelDeferredClose]; | 79 [cocoa_view_ cancelDeferredClose]; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 [[WebDragDest alloc] initWithTabContents:[self tabContents]]); | 401 [[WebDragDest alloc] initWithTabContents:[self tabContents]]); |
402 [self registerDragTypes]; | 402 [self registerDragTypes]; |
403 | 403 |
404 [[NSNotificationCenter defaultCenter] | 404 [[NSNotificationCenter defaultCenter] |
405 addObserver:self | 405 addObserver:self |
406 selector:@selector(viewDidBecomeFirstResponder:) | 406 selector:@selector(viewDidBecomeFirstResponder:) |
407 name:kViewDidBecomeFirstResponder | 407 name:kViewDidBecomeFirstResponder |
408 object:nil]; | 408 object:nil]; |
409 | 409 |
410 if (webContentsView_->delegate()) { | 410 if (webContentsView_->delegate()) { |
411 [dragDest_ setDragDelegate:webContentsView_->delegate()->DragDelegate()]; | 411 [dragDest_ setDragDelegate:webContentsView_->delegate()-> |
| 412 GetDragDestDelegate()]; |
412 webContentsView_->delegate()->NativeViewCreated(self); | 413 webContentsView_->delegate()->NativeViewCreated(self); |
413 } | 414 } |
414 } | 415 } |
415 return self; | 416 return self; |
416 } | 417 } |
417 | 418 |
418 - (void)dealloc { | 419 - (void)dealloc { |
419 if (webContentsView_ && webContentsView_->delegate()) | 420 if (webContentsView_ && webContentsView_->delegate()) |
420 webContentsView_->delegate()->NativeViewDestroyed(self); | 421 webContentsView_->delegate()->NativeViewDestroyed(self); |
421 | 422 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 [[[notification userInfo] objectForKey:kSelectionDirection] | 574 [[[notification userInfo] objectForKey:kSelectionDirection] |
574 unsignedIntegerValue]; | 575 unsignedIntegerValue]; |
575 if (direction == NSDirectSelection) | 576 if (direction == NSDirectSelection) |
576 return; | 577 return; |
577 | 578 |
578 [self tabContents]-> | 579 [self tabContents]-> |
579 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 580 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
580 } | 581 } |
581 | 582 |
582 @end | 583 @end |
OLD | NEW |