| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/tab_contents/tab_contents_view_mac.h" | 5 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. | 9 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. |
| 10 #import "chrome/browser/cocoa/focus_tracker.h" | 10 #import "chrome/browser/cocoa/focus_tracker.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); | 36 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); |
| 37 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); | 37 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); |
| 38 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); | 38 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); |
| 39 COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate); | 39 COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate); |
| 40 COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove); | 40 COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove); |
| 41 COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); | 41 COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); |
| 42 COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); | 42 COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); |
| 43 | 43 |
| 44 @interface TabContentsViewCocoa (Private) | 44 @interface TabContentsViewCocoa (Private) |
| 45 - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w; | 45 - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w; |
| 46 - (void)processKeyboardEvent:(NSEvent*)event; | 46 - (void)processKeyboardEvent:(NativeWebKeyboardEvent*)event; |
| 47 - (void)registerDragTypes; | 47 - (void)registerDragTypes; |
| 48 - (void)setCurrentDragOperation:(NSDragOperation)operation; | 48 - (void)setCurrentDragOperation:(NSDragOperation)operation; |
| 49 - (void)startDragWithDropData:(const WebDropData&)dropData | 49 - (void)startDragWithDropData:(const WebDropData&)dropData |
| 50 dragOperationMask:(NSDragOperation)operationMask; | 50 dragOperationMask:(NSDragOperation)operationMask; |
| 51 @end | 51 @end |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 TabContentsView* TabContentsView::Create(TabContents* tab_contents) { | 54 TabContentsView* TabContentsView::Create(TabContents* tab_contents) { |
| 55 return new TabContentsViewMac(tab_contents); | 55 return new TabContentsViewMac(tab_contents); |
| 56 } | 56 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void TabContentsViewMac::TakeFocus(bool reverse) { | 195 void TabContentsViewMac::TakeFocus(bool reverse) { |
| 196 if (reverse) { | 196 if (reverse) { |
| 197 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; | 197 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; |
| 198 } else { | 198 } else { |
| 199 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; | 199 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 void TabContentsViewMac::HandleKeyboardEvent( | 203 void TabContentsViewMac::HandleKeyboardEvent( |
| 204 const NativeWebKeyboardEvent& event) { | 204 const NativeWebKeyboardEvent& event) { |
| 205 [cocoa_view_.get() processKeyboardEvent:event.os_event]; | 205 [cocoa_view_.get() processKeyboardEvent: |
| 206 const_cast<NativeWebKeyboardEvent*>(&event)]; |
| 206 } | 207 } |
| 207 | 208 |
| 208 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { | 209 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { |
| 209 RenderViewContextMenuMac menu(tab_contents(), | 210 RenderViewContextMenuMac menu(tab_contents(), |
| 210 params, | 211 params, |
| 211 GetNativeView()); | 212 GetNativeView()); |
| 212 menu.Init(); | 213 menu.Init(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 RenderWidgetHostView* TabContentsViewMac::CreateNewWidgetInternal( | 216 RenderWidgetHostView* TabContentsViewMac::CreateNewWidgetInternal( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 287 } |
| 287 | 288 |
| 288 - (void)setCurrentDragOperation:(NSDragOperation)operation { | 289 - (void)setCurrentDragOperation:(NSDragOperation)operation { |
| 289 [dropTarget_ setCurrentOperation:operation]; | 290 [dropTarget_ setCurrentOperation:operation]; |
| 290 } | 291 } |
| 291 | 292 |
| 292 - (TabContents*)tabContents { | 293 - (TabContents*)tabContents { |
| 293 return tabContentsView_->tab_contents(); | 294 return tabContentsView_->tab_contents(); |
| 294 } | 295 } |
| 295 | 296 |
| 296 - (void)processKeyboardEvent:(NSEvent*)event { | 297 - (void)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent { |
| 298 NSEvent* event = wkEvent->os_event; |
| 299 |
| 300 if ([event type] == NSKeyDown && ([event modifierFlags] & NSCommandKeyMask)) { |
| 301 // We need to dispatch this to the menu. |
| 302 if ([[NSApp mainMenu] performKeyEquivalent:event]) |
| 303 return; |
| 304 } |
| 305 |
| 297 // If this tab is no longer active, it's window will be |nil|. In that case, | 306 // If this tab is no longer active, it's window will be |nil|. In that case, |
| 298 // best ignore the event. | 307 // best ignore the event. |
| 299 if (![self window]) | 308 if (![self window]) |
| 300 return; | 309 return; |
| 301 | 310 |
| 302 // Do not fire shortcuts on key up. | 311 // Do not fire shortcuts on key up. |
| 303 if ([event type] == NSKeyDown) { | 312 if ([event type] == NSKeyDown) { |
| 304 ChromeBrowserWindow* window = (ChromeBrowserWindow*)[self window]; | 313 ChromeBrowserWindow* window = (ChromeBrowserWindow*)[self window]; |
| 305 DCHECK([window isKindOfClass:[ChromeBrowserWindow class]]); | 314 DCHECK([window isKindOfClass:[ChromeBrowserWindow class]]); |
| 306 if ([window handleExtraBrowserKeyboardShortcut:event]) | 315 if ([window handleExtraBrowserKeyboardShortcut:event]) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 429 } |
| 421 | 430 |
| 422 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { | 431 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
| 423 return [dropTarget_ performDragOperation:sender view:self]; | 432 return [dropTarget_ performDragOperation:sender view:self]; |
| 424 } | 433 } |
| 425 | 434 |
| 426 // Tons of stuff goes here, where we grab events going on in Cocoaland and send | 435 // Tons of stuff goes here, where we grab events going on in Cocoaland and send |
| 427 // them into the C++ system. TODO(avi): all that jazz | 436 // them into the C++ system. TODO(avi): all that jazz |
| 428 | 437 |
| 429 @end | 438 @end |
| OLD | NEW |