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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm

Issue 2934873002: Omnibox UI Experiments: Add border and shadow to narrow dropdown in Mac. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 void OmniboxPopupViewMac::CreatePopupIfNeeded() { 169 void OmniboxPopupViewMac::CreatePopupIfNeeded() {
170 if (!popup_) { 170 if (!popup_) {
171 popup_.reset( 171 popup_.reset(
172 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater 172 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
173 styleMask:NSBorderlessWindowMask 173 styleMask:NSBorderlessWindowMask
174 backing:NSBackingStoreBuffered 174 backing:NSBackingStoreBuffered
175 defer:NO]); 175 defer:NO]);
176 [popup_ setBackgroundColor:[NSColor clearColor]]; 176 [popup_ setBackgroundColor:[NSColor clearColor]];
177 [popup_ setOpaque:NO]; 177 [popup_ setOpaque:NO];
178 bool narrow_popup =
179 base::FeatureList::IsEnabled(omnibox::kUIExperimentNarrowDropdown);
180 if (narrow_popup)
181 [popup_ setHasShadow:YES];
178 182
179 // Use a flipped view to pin the matrix top the top left. This is needed 183 // Use a flipped view to pin the matrix top the top left. This is needed
180 // for animated resize. 184 // for animated resize.
181 base::scoped_nsobject<FlippedView> contentView( 185 base::scoped_nsobject<FlippedView> contentView(
182 [[FlippedView alloc] initWithFrame:NSZeroRect]); 186 [[FlippedView alloc] initWithFrame:NSZeroRect]);
183 [popup_ setContentView:contentView]; 187 [popup_ setContentView:contentView];
184 188
185 BOOL is_dark_theme = [[field_ window] hasDarkTheme]; 189 BOOL is_dark_theme = [[field_ window] hasDarkTheme];
186 190
187 // View to draw a background beneath the matrix. 191 // View to draw a background beneath the matrix.
188 background_view_.reset([[NSBox alloc] initWithFrame:NSZeroRect]); 192 background_view_.reset([[NSBox alloc] initWithFrame:NSZeroRect]);
189 [background_view_ setBoxType:NSBoxCustom]; 193 [background_view_ setBoxType:NSBoxCustom];
190 [background_view_ setBorderType:NSNoBorder]; 194 [background_view_ setBorderType:NSNoBorder];
191 [background_view_ setFillColor:BackgroundColor(is_dark_theme)]; 195 [background_view_ setFillColor:BackgroundColor(is_dark_theme)];
192 [background_view_ setContentViewMargins:NSZeroSize]; 196 [background_view_ setContentViewMargins:NSZeroSize];
193 [contentView addSubview:background_view_]; 197 [contentView addSubview:background_view_];
194 198
195 matrix_.reset([[OmniboxPopupMatrix alloc] initWithObserver:this 199 matrix_.reset([[OmniboxPopupMatrix alloc] initWithObserver:this
196 forDarkTheme:is_dark_theme]); 200 forDarkTheme:is_dark_theme]);
197 [background_view_ addSubview:matrix_]; 201 [background_view_ addSubview:matrix_];
198 202
199 top_separator_view_.reset( 203 if (!narrow_popup) {
200 [[OmniboxPopupTopSeparatorView alloc] initWithFrame:NSZeroRect]); 204 top_separator_view_.reset(
201 [contentView addSubview:top_separator_view_]; 205 [[OmniboxPopupTopSeparatorView alloc] initWithFrame:NSZeroRect]);
206 [contentView addSubview:top_separator_view_];
202 207
203 bottom_separator_view_.reset([[OmniboxPopupBottomSeparatorView alloc] 208 bottom_separator_view_.reset([[OmniboxPopupBottomSeparatorView alloc]
204 initWithFrame:NSZeroRect 209 initWithFrame:NSZeroRect
205 forDarkTheme:is_dark_theme]); 210 forDarkTheme:is_dark_theme]);
206 [contentView addSubview:bottom_separator_view_]; 211 [contentView addSubview:bottom_separator_view_];
212 }
207 213
208 // TODO(dtseng): Ignore until we provide NSAccessibility support. 214 // TODO(dtseng): Ignore until we provide NSAccessibility support.
209 [popup_ accessibilitySetOverrideValue:NSAccessibilityUnknownRole 215 [popup_ accessibilitySetOverrideValue:NSAccessibilityUnknownRole
210 forAttribute:NSAccessibilityRoleAttribute]; 216 forAttribute:NSAccessibilityRoleAttribute];
211 } 217 }
212 } 218 }
213 219
214 void OmniboxPopupViewMac::PositionPopup(const CGFloat matrixHeight) { 220 void OmniboxPopupViewMac::PositionPopup(const CGFloat matrixHeight) {
215 BrowserWindowController* controller = 221 BrowserWindowController* controller =
216 [BrowserWindowController browserWindowControllerForView:field_]; 222 [BrowserWindowController browserWindowControllerForView:field_];
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 return NSImageFromImageSkia( 355 return NSImageFromImageSkia(
350 gfx::CreateVectorIcon(vector_icon, kIconSize, icon_color)); 356 gfx::CreateVectorIcon(vector_icon, kIconSize, icon_color));
351 } 357 }
352 358
353 void OmniboxPopupViewMac::OpenURLForRow(size_t row, 359 void OmniboxPopupViewMac::OpenURLForRow(size_t row,
354 WindowOpenDisposition disposition) { 360 WindowOpenDisposition disposition) {
355 DCHECK_LT(row, GetResult().size()); 361 DCHECK_LT(row, GetResult().size());
356 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), 362 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(),
357 base::string16(), row); 363 base::string16(), row);
358 } 364 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698