Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm

Issue 12334073: Remove WebContents methods that duplicate WebContentsView methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/previewable_contents_controller.h" 5 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 8 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
9 #include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h" 9 #include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h"
10 #include "chrome/browser/ui/cocoa/tab_contents/preview_drop_shadow_view.h" 10 #include "chrome/browser/ui/cocoa/tab_contents/preview_drop_shadow_view.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 if (previewContents_ == preview && 64 if (previewContents_ == preview &&
65 previewHeight_ == height && 65 previewHeight_ == height &&
66 previewHeightUnits_ == heightUnits && 66 previewHeightUnits_ == heightUnits &&
67 drawDropShadow_ == drawDropShadow) { 67 drawDropShadow_ == drawDropShadow) {
68 return; 68 return;
69 } 69 }
70 70
71 // Remove any old preview contents before showing the new one. 71 // Remove any old preview contents before showing the new one.
72 if (previewContents_) { 72 if (previewContents_) {
73 [previewContents_->GetNativeView() removeFromSuperview]; 73 [previewContents_->GetView()->GetNativeView() removeFromSuperview];
74 previewContents_->WasHidden(); 74 previewContents_->WasHidden();
75 } 75 }
76 76
77 previewContents_ = preview; 77 previewContents_ = preview;
78 previewHeight_ = height; 78 previewHeight_ = height;
79 previewHeightUnits_ = heightUnits; 79 previewHeightUnits_ = heightUnits;
80 drawDropShadow_ = drawDropShadow; 80 drawDropShadow_ = drawDropShadow;
81 81
82 // Add the preview contents. 82 // Add the preview contents.
83 if (previewContents_) { 83 if (previewContents_) {
84 [[[self view] window] disableScreenUpdatesUntilFlush]; 84 [[[self view] window] disableScreenUpdatesUntilFlush];
85 previewContents_->GetView()->SetAllowOverlappingViews(true); 85 previewContents_->GetView()->SetAllowOverlappingViews(true);
86 [[self view] addSubview:previewContents_->GetNativeView()]; 86 [[self view] addSubview:previewContents_->GetView()->GetNativeView()];
87 } 87 }
88 88
89 if (drawDropShadow_) { 89 if (drawDropShadow_) {
90 if (!dropShadowView_) { 90 if (!dropShadowView_) {
91 dropShadowView_.reset( 91 dropShadowView_.reset(
92 [[PreviewDropShadowView alloc] initWithFrame:NSZeroRect]); 92 [[PreviewDropShadowView alloc] initWithFrame:NSZeroRect]);
93 [[self view] addSubview:dropShadowView_]; 93 [[self view] addSubview:dropShadowView_];
94 } 94 }
95 } else { 95 } else {
96 [dropShadowView_ removeFromSuperview]; 96 [dropShadowView_ removeFromSuperview];
97 dropShadowView_.reset(); 97 dropShadowView_.reset();
98 } 98 }
99 99
100 [self layoutViews]; 100 [self layoutViews];
101 101
102 if (previewContents_) 102 if (previewContents_)
103 previewContents_->WasShown(); 103 previewContents_->WasShown();
104 } 104 }
105 105
106 - (void)onActivateTabWithContents:(content::WebContents*)contents { 106 - (void)onActivateTabWithContents:(content::WebContents*)contents {
107 if (previewContents_ == contents) { 107 if (previewContents_ == contents) {
108 if (previewContents_) { 108 if (previewContents_) {
109 [previewContents_->GetNativeView() removeFromSuperview]; 109 [previewContents_->GetView()->GetNativeView() removeFromSuperview];
110 previewContents_ = NULL; 110 previewContents_ = NULL;
111 } 111 }
112 [self setPreview:NULL 112 [self setPreview:NULL
113 height:0 113 height:0
114 heightUnits:INSTANT_SIZE_PIXELS 114 heightUnits:INSTANT_SIZE_PIXELS
115 drawDropShadow:NO]; 115 drawDropShadow:NO];
116 } 116 }
117 } 117 }
118 118
119 - (BOOL)isShowingPreview { 119 - (BOOL)isShowingPreview {
(...skipping 24 matching lines...) Expand all
144 [self layoutViews]; 144 [self layoutViews];
145 } 145 }
146 146
147 - (void)layoutViews { 147 - (void)layoutViews {
148 NSRect bounds = [[self view] bounds]; 148 NSRect bounds = [[self view] bounds];
149 149
150 if (previewContents_) { 150 if (previewContents_) {
151 NSRect previewFrame = bounds; 151 NSRect previewFrame = bounds;
152 previewFrame.size.height = [self previewHeightInPixels]; 152 previewFrame.size.height = [self previewHeightInPixels];
153 previewFrame.origin.y = NSMaxY(bounds) - NSHeight(previewFrame); 153 previewFrame.origin.y = NSMaxY(bounds) - NSHeight(previewFrame);
154 [previewContents_->GetNativeView() setFrame:previewFrame]; 154 [previewContents_->GetView()->GetNativeView() setFrame:previewFrame];
155 155
156 if (dropShadowView_) { 156 if (dropShadowView_) {
157 NSRect dropShadowFrame = bounds; 157 NSRect dropShadowFrame = bounds;
158 dropShadowFrame.size.height = [PreviewDropShadowView preferredHeight]; 158 dropShadowFrame.size.height = [PreviewDropShadowView preferredHeight];
159 dropShadowFrame.origin.y = 159 dropShadowFrame.origin.y =
160 NSMinY(previewFrame) - NSHeight(dropShadowFrame); 160 NSMinY(previewFrame) - NSHeight(dropShadowFrame);
161 [dropShadowView_ setFrame:dropShadowFrame]; 161 [dropShadowView_ setFrame:dropShadowFrame];
162 } 162 }
163 } 163 }
164 164
165 NSRect activeFrame = bounds; 165 NSRect activeFrame = bounds;
166 activeFrame.size.height -= activeContainerOffset_; 166 activeFrame.size.height -= activeContainerOffset_;
167 [activeContainer_ setFrame:activeFrame]; 167 [activeContainer_ setFrame:activeFrame];
168 } 168 }
169 169
170 - (CGFloat)previewHeightInPixels { 170 - (CGFloat)previewHeightInPixels {
171 CGFloat height = NSHeight([[self view] bounds]); 171 CGFloat height = NSHeight([[self view] bounds]);
172 switch (previewHeightUnits_) { 172 switch (previewHeightUnits_) {
173 case INSTANT_SIZE_PERCENT: 173 case INSTANT_SIZE_PERCENT:
174 return std::min(height, (height * previewHeight_) / 100); 174 return std::min(height, (height * previewHeight_) / 100);
175 case INSTANT_SIZE_PIXELS: 175 case INSTANT_SIZE_PIXELS:
176 return std::min(height, previewHeight_); 176 return std::min(height, previewHeight_);
177 } 177 }
178 } 178 }
179 179
180 @end 180 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698