OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" | 7 #include "chrome/browser/tab_contents/tab_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 "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" | 13 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" |
13 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" | 14 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" |
14 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h" | 15 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h" |
15 #import "chrome/browser/ui/cocoa/focus_tracker.h" | 16 #import "chrome/browser/ui/cocoa/focus_tracker.h" |
16 #import "chrome/browser/ui/cocoa/view_id_util.h" | 17 #import "chrome/browser/ui/cocoa/view_id_util.h" |
17 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
18 #include "content/browser/renderer_host/render_view_host_factory.h" | 19 #include "content/browser/renderer_host/render_view_host_factory.h" |
19 #include "content/browser/renderer_host/render_widget_host.h" | 20 #include "content/browser/renderer_host/render_widget_host.h" |
20 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
21 #include "content/browser/tab_contents/popup_menu_helper_mac.h" | 22 #include "content/browser/tab_contents/popup_menu_helper_mac.h" |
22 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
23 #include "content/browser/tab_contents/tab_contents_delegate.h" | 24 #include "content/browser/tab_contents/tab_contents_delegate.h" |
24 #import "content/browser/tab_contents/web_drag_dest_mac.h" | 25 #import "content/browser/tab_contents/web_drag_dest_mac.h" |
25 #import "content/browser/tab_contents/web_drag_source_mac.h" | 26 #import "content/browser/tab_contents/web_drag_source_mac.h" |
26 #import "content/common/chrome_application_mac.h" | |
27 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
28 #include "skia/ext/skia_utils_mac.h" | 28 #include "skia/ext/skia_utils_mac.h" |
29 #import "third_party/mozilla/NSPasteboard+Utils.h" | 29 #import "third_party/mozilla/NSPasteboard+Utils.h" |
30 | 30 |
31 using WebKit::WebDragOperation; | 31 using WebKit::WebDragOperation; |
32 using WebKit::WebDragOperationsMask; | 32 using WebKit::WebDragOperationsMask; |
33 | 33 |
34 // Ensure that the WebKit::WebDragOperation enum values stay in sync with | 34 // Ensure that the WebKit::WebDragOperation enum values stay in sync with |
35 // NSDragOperation constants, since the code below static_casts between 'em. | 35 // NSDragOperation constants, since the code below static_casts between 'em. |
36 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 36 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 double item_font_size, | 362 double item_font_size, |
363 int selected_item, | 363 int selected_item, |
364 const std::vector<WebMenuItem>& items, | 364 const std::vector<WebMenuItem>& items, |
365 bool right_aligned) { | 365 bool right_aligned) { |
366 PopupMenuHelper popup_menu_helper(tab_contents_->render_view_host()); | 366 PopupMenuHelper popup_menu_helper(tab_contents_->render_view_host()); |
367 popup_menu_helper.ShowPopupMenu(bounds, item_height, item_font_size, | 367 popup_menu_helper.ShowPopupMenu(bounds, item_height, item_font_size, |
368 selected_item, items, right_aligned); | 368 selected_item, items, right_aligned); |
369 } | 369 } |
370 | 370 |
371 bool TabContentsViewMac::IsEventTracking() const { | 371 bool TabContentsViewMac::IsEventTracking() const { |
372 if ([NSApp isKindOfClass:[CrApplication class]] && | 372 return base::MessagePumpMac::IsHandlingSendEvent(); |
373 [static_cast<CrApplication*>(NSApp) isHandlingSendEvent]) { | |
374 return true; | |
375 } | |
376 return false; | |
377 } | 373 } |
378 | 374 |
379 // Arrange to call CloseTab() after we're back to the main event loop. | 375 // Arrange to call CloseTab() after we're back to the main event loop. |
380 // The obvious way to do this would be PostNonNestableTask(), but that | 376 // The obvious way to do this would be PostNonNestableTask(), but that |
381 // will fire when the event-tracking loop polls for events. So we | 377 // will fire when the event-tracking loop polls for events. So we |
382 // need to bounce the message via Cocoa, instead. | 378 // need to bounce the message via Cocoa, instead. |
383 void TabContentsViewMac::CloseTabAfterEventTracking() { | 379 void TabContentsViewMac::CloseTabAfterEventTracking() { |
384 [cocoa_view_ cancelDeferredClose]; | 380 [cocoa_view_ cancelDeferredClose]; |
385 [cocoa_view_ performSelector:@selector(closeTabAfterEvent) | 381 [cocoa_view_ performSelector:@selector(closeTabAfterEvent) |
386 withObject:nil | 382 withObject:nil |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 [[[notification userInfo] objectForKey:kSelectionDirection] | 602 [[[notification userInfo] objectForKey:kSelectionDirection] |
607 unsignedIntegerValue]; | 603 unsignedIntegerValue]; |
608 if (direction == NSDirectSelection) | 604 if (direction == NSDirectSelection) |
609 return; | 605 return; |
610 | 606 |
611 [self tabContents]-> | 607 [self tabContents]-> |
612 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 608 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
613 } | 609 } |
614 | 610 |
615 @end | 611 @end |
OLD | NEW |