| 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 #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/browser.h" // TODO(beng): this dependency is awful. | 11 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. |
| 12 #import "chrome/browser/cocoa/focus_tracker.h" | 12 #import "chrome/browser/cocoa/focus_tracker.h" |
| 13 #import "chrome/browser/cocoa/chrome_browser_window.h" | 13 #import "chrome/browser/cocoa/chrome_browser_window.h" |
| 14 #import "chrome/browser/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 15 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 15 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 16 #include "chrome/browser/cocoa/sad_tab_view.h" | 16 #include "chrome/browser/cocoa/sad_tab_view.h" |
| 17 #import "chrome/browser/cocoa/web_drag_source.h" | 17 #import "chrome/browser/cocoa/web_drag_source.h" |
| 18 #import "chrome/browser/cocoa/web_drop_target.h" | 18 #import "chrome/browser/cocoa/web_drop_target.h" |
| 19 #include "chrome/browser/renderer_host/render_view_host_factory.h" |
| 19 #include "chrome/browser/renderer_host/render_widget_host.h" | 20 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 20 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 21 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 21 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" | 22 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" |
| 22 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
| 23 #include "chrome/common/notification_type.h" | 24 #include "chrome/common/notification_type.h" |
| 24 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
| 25 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
| 26 #import "third_party/mozilla/include/NSPasteboard+Utils.h" | 27 #import "third_party/mozilla/include/NSPasteboard+Utils.h" |
| 27 | 28 |
| 28 #include "chrome/common/temp_scaffolding_stubs.h" | 29 #include "chrome/common/temp_scaffolding_stubs.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 65 } |
| 65 | 66 |
| 66 void TabContentsViewMac::CreateView(const gfx::Size& initial_size) { | 67 void TabContentsViewMac::CreateView(const gfx::Size& initial_size) { |
| 67 TabContentsViewCocoa* view = | 68 TabContentsViewCocoa* view = |
| 68 [[TabContentsViewCocoa alloc] initWithTabContentsViewMac:this]; | 69 [[TabContentsViewCocoa alloc] initWithTabContentsViewMac:this]; |
| 69 cocoa_view_.reset(view); | 70 cocoa_view_.reset(view); |
| 70 } | 71 } |
| 71 | 72 |
| 72 RenderWidgetHostView* TabContentsViewMac::CreateViewForWidget( | 73 RenderWidgetHostView* TabContentsViewMac::CreateViewForWidget( |
| 73 RenderWidgetHost* render_widget_host) { | 74 RenderWidgetHost* render_widget_host) { |
| 74 DCHECK(!render_widget_host->view()); | 75 if (render_widget_host->view()) { |
| 76 // During testing, the view will already be set up in most cases to the |
| 77 // test view, so we don't want to clobber it with a real one. To verify that |
| 78 // this actually is happening (and somebody isn't accidentally creating the |
| 79 // view twice), we check for the RVH Factory, which will be set when we're |
| 80 // making special ones (which go along with the special views). |
| 81 DCHECK(RenderViewHostFactory::has_factory()); |
| 82 return render_widget_host->view(); |
| 83 } |
| 84 |
| 75 RenderWidgetHostViewMac* view = | 85 RenderWidgetHostViewMac* view = |
| 76 new RenderWidgetHostViewMac(render_widget_host); | 86 new RenderWidgetHostViewMac(render_widget_host); |
| 77 | 87 |
| 78 // Fancy layout comes later; for now just make it our size and resize it | 88 // Fancy layout comes later; for now just make it our size and resize it |
| 79 // with us. In case there are other siblings of the content area, we want | 89 // with us. In case there are other siblings of the content area, we want |
| 80 // to make sure the content area is on the bottom so other things draw over | 90 // to make sure the content area is on the bottom so other things draw over |
| 81 // it. | 91 // it. |
| 82 NSView* view_view = view->native_view(); | 92 NSView* view_view = view->native_view(); |
| 83 [view_view setFrame:[cocoa_view_.get() bounds]]; | 93 [view_view setFrame:[cocoa_view_.get() bounds]]; |
| 84 [view_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 94 [view_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 464 } |
| 455 | 465 |
| 456 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { | 466 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
| 457 return [dropTarget_ performDragOperation:sender view:self]; | 467 return [dropTarget_ performDragOperation:sender view:self]; |
| 458 } | 468 } |
| 459 | 469 |
| 460 // Tons of stuff goes here, where we grab events going on in Cocoaland and send | 470 // Tons of stuff goes here, where we grab events going on in Cocoaland and send |
| 461 // them into the C++ system. TODO(avi): all that jazz | 471 // them into the C++ system. TODO(avi): all that jazz |
| 462 | 472 |
| 463 @end | 473 @end |
| OLD | NEW |