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 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 11 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
12 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
13 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" | 13 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" |
14 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" | 14 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" |
15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
16 #import "chrome/browser/ui/cocoa/focus_tracker.h" | 16 #import "chrome/browser/ui/cocoa/focus_tracker.h" |
17 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 17 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
18 #import "chrome/browser/ui/cocoa/tab_contents/web_drag_source.h" | 18 #import "chrome/browser/ui/cocoa/tab_contents/web_drag_source.h" |
19 #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" | 19 #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" |
20 #import "chrome/browser/ui/cocoa/view_id_util.h" | 20 #import "chrome/browser/ui/cocoa/view_id_util.h" |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
22 #include "content/browser/renderer_host/render_view_host.h" | 22 #include "content/browser/renderer_host/render_view_host.h" |
23 #include "content/browser/renderer_host/render_view_host_factory.h" | 23 #include "content/browser/renderer_host/render_view_host_factory.h" |
24 #include "content/browser/renderer_host/render_widget_host.h" | 24 #include "content/browser/renderer_host/render_widget_host.h" |
25 #include "content/browser/tab_contents/tab_contents.h" | 25 #include "content/browser/tab_contents/tab_contents.h" |
26 #include "content/browser/tab_contents/tab_contents_delegate.h" | 26 #include "content/browser/tab_contents/tab_contents_delegate.h" |
27 #import "content/common/chrome_application_mac.h" | 27 #import "content/common/chrome_application_mac.h" |
| 28 #include "content/common/content_notification_types.h" |
28 #include "content/common/notification_details.h" | 29 #include "content/common/notification_details.h" |
29 #include "content/common/notification_source.h" | 30 #include "content/common/notification_source.h" |
30 #include "content/common/notification_type.h" | |
31 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
32 #include "skia/ext/skia_utils_mac.h" | 32 #include "skia/ext/skia_utils_mac.h" |
33 #import "third_party/mozilla/NSPasteboard+Utils.h" | 33 #import "third_party/mozilla/NSPasteboard+Utils.h" |
34 | 34 |
35 using WebKit::WebDragOperation; | 35 using WebKit::WebDragOperation; |
36 using WebKit::WebDragOperationsMask; | 36 using WebKit::WebDragOperationsMask; |
37 | 37 |
38 // Ensure that the WebKit::WebDragOperation enum values stay in sync with | 38 // Ensure that the WebKit::WebDragOperation enum values stay in sync with |
39 // NSDragOperation constants, since the code below static_casts between 'em. | 39 // NSDragOperation constants, since the code below static_casts between 'em. |
40 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 40 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
(...skipping 21 matching lines...) Expand all Loading... |
62 @end | 62 @end |
63 | 63 |
64 // static | 64 // static |
65 TabContentsView* TabContentsView::Create(TabContents* tab_contents) { | 65 TabContentsView* TabContentsView::Create(TabContents* tab_contents) { |
66 return new TabContentsViewMac(tab_contents); | 66 return new TabContentsViewMac(tab_contents); |
67 } | 67 } |
68 | 68 |
69 TabContentsViewMac::TabContentsViewMac(TabContents* tab_contents) | 69 TabContentsViewMac::TabContentsViewMac(TabContents* tab_contents) |
70 : TabContentsView(tab_contents), | 70 : TabContentsView(tab_contents), |
71 preferred_width_(0) { | 71 preferred_width_(0) { |
72 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, | 72 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED, |
73 Source<TabContents>(tab_contents)); | 73 Source<TabContents>(tab_contents)); |
74 } | 74 } |
75 | 75 |
76 TabContentsViewMac::~TabContentsViewMac() { | 76 TabContentsViewMac::~TabContentsViewMac() { |
77 // This handles the case where a renderer close call was deferred | 77 // This handles the case where a renderer close call was deferred |
78 // while the user was operating a UI control which resulted in a | 78 // while the user was operating a UI control which resulted in a |
79 // close. In that case, the Cocoa view outlives the | 79 // close. In that case, the Cocoa view outlives the |
80 // TabContentsViewMac instance due to Cocoa retain count. | 80 // TabContentsViewMac instance due to Cocoa retain count. |
81 [cocoa_view_ cancelDeferredClose]; | 81 [cocoa_view_ cancelDeferredClose]; |
82 } | 82 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 void TabContentsViewMac::GetViewBounds(gfx::Rect* out) const { | 352 void TabContentsViewMac::GetViewBounds(gfx::Rect* out) const { |
353 // This method is noth currently used on mac. | 353 // This method is noth currently used on mac. |
354 NOTIMPLEMENTED(); | 354 NOTIMPLEMENTED(); |
355 } | 355 } |
356 | 356 |
357 void TabContentsViewMac::CloseTab() { | 357 void TabContentsViewMac::CloseTab() { |
358 tab_contents()->Close(tab_contents()->render_view_host()); | 358 tab_contents()->Close(tab_contents()->render_view_host()); |
359 } | 359 } |
360 | 360 |
361 void TabContentsViewMac::Observe(NotificationType type, | 361 void TabContentsViewMac::Observe(int type, |
362 const NotificationSource& source, | 362 const NotificationSource& source, |
363 const NotificationDetails& details) { | 363 const NotificationDetails& details) { |
364 switch (type.value) { | 364 switch (type) { |
365 case NotificationType::TAB_CONTENTS_CONNECTED: { | 365 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: { |
366 sad_tab_.reset(); | 366 sad_tab_.reset(); |
367 break; | 367 break; |
368 } | 368 } |
369 default: | 369 default: |
370 NOTREACHED() << "Got a notification we didn't register for."; | 370 NOTREACHED() << "Got a notification we didn't register for."; |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 @implementation TabContentsViewCocoa | 374 @implementation TabContentsViewCocoa |
375 | 375 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 [[[notification userInfo] objectForKey:kSelectionDirection] | 544 [[[notification userInfo] objectForKey:kSelectionDirection] |
545 unsignedIntegerValue]; | 545 unsignedIntegerValue]; |
546 if (direction == NSDirectSelection) | 546 if (direction == NSDirectSelection) |
547 return; | 547 return; |
548 | 548 |
549 [self tabContents]-> | 549 [self tabContents]-> |
550 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 550 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
551 } | 551 } |
552 | 552 |
553 @end | 553 @end |
OLD | NEW |