| 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/command_line.h" |
| 9 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 10 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
| 11 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_view.h" | 15 #include "content/public/browser/web_contents_view.h" |
| 16 #include "content/public/common/content_switches.h" |
| 15 | 17 |
| 16 using content::WebContents; | 18 using content::WebContents; |
| 17 | 19 |
| 18 | 20 |
| 19 @implementation TabContentsController | 21 @implementation TabContentsController |
| 20 @synthesize webContents = contents_; | 22 @synthesize webContents = contents_; |
| 21 | 23 |
| 22 - (id)initWithContents:(WebContents*)contents { | 24 - (id)initWithContents:(WebContents*)contents { |
| 23 if ((self = [super initWithNibName:nil bundle:nil])) { | 25 if ((self = [super initWithNibName:nil bundle:nil])) { |
| 24 contents_ = contents; | 26 contents_ = contents; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 NSView* contentsNativeView = contents_->GetView()->GetNativeView(); | 59 NSView* contentsNativeView = contents_->GetView()->GetNativeView(); |
| 58 [contentsNativeView setFrame:[contentsContainer frame]]; | 60 [contentsNativeView setFrame:[contentsContainer frame]]; |
| 59 if ([subviews count] == 0) { | 61 if ([subviews count] == 0) { |
| 60 [contentsContainer addSubview:contentsNativeView]; | 62 [contentsContainer addSubview:contentsNativeView]; |
| 61 } else if ([subviews objectAtIndex:0] != contentsNativeView) { | 63 } else if ([subviews objectAtIndex:0] != contentsNativeView) { |
| 62 [contentsContainer replaceSubview:[subviews objectAtIndex:0] | 64 [contentsContainer replaceSubview:[subviews objectAtIndex:0] |
| 63 with:contentsNativeView]; | 65 with:contentsNativeView]; |
| 64 } | 66 } |
| 65 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| | 67 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| |
| 66 NSViewHeightSizable]; | 68 NSViewHeightSizable]; |
| 67 // The find bar will overlap the content's view when it comes out; inform | 69 |
| 68 // the view. | 70 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 69 contents_->GetView()->SetAllowOverlappingViews(true); | 71 switches::kUseCoreAnimation)) { |
| 72 // The find bar will overlap the content's view when it comes out; inform |
| 73 // the view. |
| 74 contents_->GetView()->SetAllowOverlappingViews(true); |
| 75 } |
| 70 } | 76 } |
| 71 | 77 |
| 72 - (void)changeWebContents:(WebContents*)newContents { | 78 - (void)changeWebContents:(WebContents*)newContents { |
| 73 contents_ = newContents; | 79 contents_ = newContents; |
| 74 } | 80 } |
| 75 | 81 |
| 76 // Returns YES if the tab represented by this controller is the front-most. | 82 // Returns YES if the tab represented by this controller is the front-most. |
| 77 - (BOOL)isCurrentTab { | 83 - (BOOL)isCurrentTab { |
| 78 // We're the current tab if we're in the view hierarchy, otherwise some other | 84 // We're the current tab if we're in the view hierarchy, otherwise some other |
| 79 // tab is. | 85 // tab is. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Calling setContentView: here removes any first responder status | 119 // Calling setContentView: here removes any first responder status |
| 114 // the view may have, so avoid changing the view hierarchy unless | 120 // the view may have, so avoid changing the view hierarchy unless |
| 115 // the view is different. | 121 // the view is different. |
| 116 if ([self webContents] != updatedContents) { | 122 if ([self webContents] != updatedContents) { |
| 117 contents_ = updatedContents; | 123 contents_ = updatedContents; |
| 118 [self ensureContentsVisible]; | 124 [self ensureContentsVisible]; |
| 119 } | 125 } |
| 120 } | 126 } |
| 121 | 127 |
| 122 @end | 128 @end |
| OLD | NEW |