| 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 "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 11 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_view.h" |
| 13 | 14 |
| 14 using content::WebContents; | 15 using content::WebContents; |
| 15 | 16 |
| 16 | 17 |
| 17 @implementation TabContentsController | 18 @implementation TabContentsController |
| 18 @synthesize webContents = contents_; | 19 @synthesize webContents = contents_; |
| 19 | 20 |
| 20 - (id)initWithContents:(WebContents*)contents { | 21 - (id)initWithContents:(WebContents*)contents { |
| 21 if ((self = [super initWithNibName:nil bundle:nil])) { | 22 if ((self = [super initWithNibName:nil bundle:nil])) { |
| 22 contents_ = contents; | 23 contents_ = contents; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 NSView* contentsNativeView = contents_->GetNativeView(); | 54 NSView* contentsNativeView = contents_->GetNativeView(); |
| 54 [contentsNativeView setFrame:[contentsContainer frame]]; | 55 [contentsNativeView setFrame:[contentsContainer frame]]; |
| 55 if ([subviews count] == 0) { | 56 if ([subviews count] == 0) { |
| 56 [contentsContainer addSubview:contentsNativeView]; | 57 [contentsContainer addSubview:contentsNativeView]; |
| 57 } else if ([subviews objectAtIndex:0] != contentsNativeView) { | 58 } else if ([subviews objectAtIndex:0] != contentsNativeView) { |
| 58 [contentsContainer replaceSubview:[subviews objectAtIndex:0] | 59 [contentsContainer replaceSubview:[subviews objectAtIndex:0] |
| 59 with:contentsNativeView]; | 60 with:contentsNativeView]; |
| 60 } | 61 } |
| 61 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| | 62 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| |
| 62 NSViewHeightSizable]; | 63 NSViewHeightSizable]; |
| 64 // The find bar will overlap the content's view when it comes out; inform |
| 65 // the view. |
| 66 contents_->GetView()->SetAllowOverlappingViews(true); |
| 63 } | 67 } |
| 64 | 68 |
| 65 - (void)changeWebContents:(WebContents*)newContents { | 69 - (void)changeWebContents:(WebContents*)newContents { |
| 66 contents_ = newContents; | 70 contents_ = newContents; |
| 67 } | 71 } |
| 68 | 72 |
| 69 // Returns YES if the tab represented by this controller is the front-most. | 73 // Returns YES if the tab represented by this controller is the front-most. |
| 70 - (BOOL)isCurrentTab { | 74 - (BOOL)isCurrentTab { |
| 71 // We're the current tab if we're in the view hierarchy, otherwise some other | 75 // We're the current tab if we're in the view hierarchy, otherwise some other |
| 72 // tab is. | 76 // tab is. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 92 // Calling setContentView: here removes any first responder status | 96 // Calling setContentView: here removes any first responder status |
| 93 // the view may have, so avoid changing the view hierarchy unless | 97 // the view may have, so avoid changing the view hierarchy unless |
| 94 // the view is different. | 98 // the view is different. |
| 95 if ([self webContents] != updatedContents) { | 99 if ([self webContents] != updatedContents) { |
| 96 contents_ = updatedContents; | 100 contents_ = updatedContents; |
| 97 [self ensureContentsVisible]; | 101 [self ensureContentsVisible]; |
| 98 } | 102 } |
| 99 } | 103 } |
| 100 | 104 |
| 101 @end | 105 @end |
| OLD | NEW |