OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/tab_contents_controller.h" | 5 #import "chrome/browser/cocoa/tab_contents_controller.h" |
6 | 6 |
7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
11 | 11 |
12 @implementation TabContentsController | 12 @implementation TabContentsController |
13 | 13 |
14 - (id)initWithNibName:(NSString*)name | 14 - (id)initWithNibName:(NSString*)name |
15 contents:(TabContents*)contents { | 15 contents:(TabContents*)contents { |
16 if ((self = [super initWithNibName:name | 16 if ((self = [super initWithNibName:name |
17 bundle:mac_util::MainAppBundle()])) { | 17 bundle:mac_util::MainAppBundle()])) { |
18 contents_ = contents; | 18 contents_ = contents; |
19 } | 19 } |
20 return self; | 20 return self; |
21 } | 21 } |
22 | 22 |
23 - (void)dealloc { | 23 - (void)dealloc { |
24 // make sure our contents have been removed from the window | 24 // make sure our contents have been removed from the window |
25 [[self view] removeFromSuperview]; | 25 [[self view] removeFromSuperview]; |
26 [super dealloc]; | 26 [super dealloc]; |
27 } | 27 } |
28 | 28 |
29 - (void)awakeFromNib { | 29 // Call when the tab view is properly sized and the render widget host view |
| 30 // should be put into the view hierarchy. |
| 31 - (void)ensureContentsVisible { |
30 [contentsBox_ setContentView:contents_->GetNativeView()]; | 32 [contentsBox_ setContentView:contents_->GetNativeView()]; |
31 } | 33 } |
32 | 34 |
33 // Returns YES if the tab represented by this controller is the front-most. | 35 // Returns YES if the tab represented by this controller is the front-most. |
34 - (BOOL)isCurrentTab { | 36 - (BOOL)isCurrentTab { |
35 // We're the current tab if we're in the view hierarchy, otherwise some other | 37 // We're the current tab if we're in the view hierarchy, otherwise some other |
36 // tab is. | 38 // tab is. |
37 return [[self view] superview] ? YES : NO; | 39 return [[self view] superview] ? YES : NO; |
38 } | 40 } |
39 | 41 |
40 - (void)willBecomeSelectedTab { | 42 - (void)willBecomeSelectedTab { |
41 } | 43 } |
42 | 44 |
43 - (void)tabDidChange:(TabContents*)updatedContents { | 45 - (void)tabDidChange:(TabContents*)updatedContents { |
44 // Calling setContentView: here removes any first responder status | 46 // Calling setContentView: here removes any first responder status |
45 // the view may have, so avoid changing the view hierarchy unless | 47 // the view may have, so avoid changing the view hierarchy unless |
46 // the view is different. | 48 // the view is different. |
47 if (contents_ != updatedContents) { | 49 if (contents_ != updatedContents) { |
48 contents_ = updatedContents; | 50 contents_ = updatedContents; |
49 [contentsBox_ setContentView:contents_->GetNativeView()]; | 51 [contentsBox_ setContentView:contents_->GetNativeView()]; |
50 } | 52 } |
51 } | 53 } |
52 | 54 |
53 @end | 55 @end |
OLD | NEW |