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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 1378023003: Update Location Bar Bubbles Layout for Material Design (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // TODO(pkasting): Stretch the location bar instead in this case. 211 // TODO(pkasting): Stretch the location bar instead in this case.
212 const int location_height = GetInternalHeight(true); 212 const int location_height = GetInternalHeight(true);
213 font_list = font_list.DeriveWithHeightUpperBound(location_height); 213 font_list = font_list.DeriveWithHeightUpperBound(location_height);
214 214
215 // Determine the font for use inside the bubbles. The bubble background 215 // Determine the font for use inside the bubbles. The bubble background
216 // images have 1 px thick edges, which we don't want to overlap. 216 // images have 1 px thick edges, which we don't want to overlap.
217 const int kBubbleInteriorVerticalPadding = 1; 217 const int kBubbleInteriorVerticalPadding = 1;
218 const int bubble_vertical_padding = 218 const int bubble_vertical_padding =
219 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + 219 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) +
220 kBubbleInteriorVerticalPadding) * 2; 220 kBubbleInteriorVerticalPadding) * 2;
221 const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound( 221 const int desired_bubble_font_size =
222 location_height - bubble_vertical_padding)); 222 GetLayoutConstant(LOCATION_BAR_BUBBLE_FONT_PIXEL_SIZE);
223 gfx::FontList bubble_font_list = font_list;
224 if (bubble_font_list.GetFontSize() != desired_bubble_font_size) {
225 bubble_font_list = bubble_font_list.DeriveWithSizeDelta(
226 desired_bubble_font_size - bubble_font_list.GetFontSize());
227 }
228 bubble_font_list = bubble_font_list.DeriveWithHeightUpperBound(
229 location_height - bubble_vertical_padding);
223 230
224 const SkColor background_color = 231 const SkColor background_color =
225 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND); 232 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND);
226 ev_bubble_view_ = new EVBubbleView( 233 const SkColor ev_text_color =
227 bubble_font_list, GetColor(SecurityStateModel::EV_SECURE, SECURITY_TEXT), 234 GetColor(SecurityStateModel::EV_SECURE,
228 background_color, this); 235 ui::MaterialDesignController::IsModeMaterial() ? BUBBLE_TEXT
236 : SECURITY_TEXT);
237 ev_bubble_view_ =
238 new EVBubbleView(bubble_font_list, ev_text_color, background_color, this);
229 ev_bubble_view_->set_drag_controller(this); 239 ev_bubble_view_->set_drag_controller(this);
230 AddChildView(ev_bubble_view_); 240 AddChildView(ev_bubble_view_);
231 241
232 // Initialize the Omnibox view. 242 // Initialize the Omnibox view.
233 omnibox_view_ = new OmniboxViewViews( 243 omnibox_view_ = new OmniboxViewViews(
234 this, profile(), command_updater(), is_popup_mode_, this, font_list); 244 this, profile(), command_updater(), is_popup_mode_, this, font_list);
235 omnibox_view_->Init(); 245 omnibox_view_->Init();
236 omnibox_view_->SetFocusable(true); 246 omnibox_view_->SetFocusable(true);
237 AddChildView(omnibox_view_); 247 AddChildView(omnibox_view_);
238 248
239 // Initialize the inline autocomplete view which is visible only when IME is 249 // Initialize the inline autocomplete view which is visible only when IME is
240 // turned on. Use the same font with the omnibox and highlighted background. 250 // turned on. Use the same font with the omnibox and highlighted background.
241 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); 251 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list);
242 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 252 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
243 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); 253 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false);
244 ime_inline_autocomplete_view_->set_background( 254 ime_inline_autocomplete_view_->set_background(
245 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 255 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
246 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 256 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
247 ime_inline_autocomplete_view_->SetEnabledColor( 257 ime_inline_autocomplete_view_->SetEnabledColor(
248 GetNativeTheme()->GetSystemColor( 258 GetNativeTheme()->GetSystemColor(
249 ui::NativeTheme::kColorId_TextfieldSelectionColor)); 259 ui::NativeTheme::kColorId_TextfieldSelectionColor));
250 ime_inline_autocomplete_view_->SetVisible(false); 260 ime_inline_autocomplete_view_->SetVisible(false);
251 AddChildView(ime_inline_autocomplete_view_); 261 AddChildView(ime_inline_autocomplete_view_);
252 262
253 const SkColor text_color = GetColor(SecurityStateModel::NONE, TEXT); 263 const SkColor text_color = GetColor(
264 SecurityStateModel::NONE,
265 ui::MaterialDesignController::IsModeMaterial() ? BUBBLE_TEXT : TEXT);
254 selected_keyword_view_ = new SelectedKeywordView( 266 selected_keyword_view_ = new SelectedKeywordView(
255 bubble_font_list, text_color, background_color, profile()); 267 bubble_font_list, text_color, background_color, profile());
256 AddChildView(selected_keyword_view_); 268 AddChildView(selected_keyword_view_);
257 269
258 suggested_text_view_ = new views::Label(base::string16(), font_list); 270 suggested_text_view_ = new views::Label(base::string16(), font_list);
259 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 271 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
260 suggested_text_view_->SetAutoColorReadabilityEnabled(false); 272 suggested_text_view_->SetAutoColorReadabilityEnabled(false);
261 suggested_text_view_->SetEnabledColor( 273 suggested_text_view_->SetEnabledColor(
262 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); 274 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT));
263 suggested_text_view_->SetVisible(false); 275 suggested_text_view_->SetVisible(false);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 break; 376 break;
365 377
366 default: 378 default:
367 NOTREACHED(); 379 NOTREACHED();
368 return GetColor(security_level, TEXT); 380 return GetColor(security_level, TEXT);
369 } 381 }
370 return color_utils::GetReadableColor( 382 return color_utils::GetReadableColor(
371 color, GetColor(security_level, BACKGROUND)); 383 color, GetColor(security_level, BACKGROUND));
372 } 384 }
373 385
386 case BUBBLE_TEXT:
387 return SK_ColorWHITE;
388
374 default: 389 default:
375 NOTREACHED(); 390 NOTREACHED();
376 return GetColor(security_level, TEXT); 391 return GetColor(security_level, TEXT);
377 } 392 }
378 } 393 }
379 394
380 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { 395 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) {
381 DCHECK(zoom_view_); 396 DCHECK(zoom_view_);
382 if (RefreshZoomView()) { 397 if (RefreshZoomView()) {
383 Layout(); 398 Layout();
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 //////////////////////////////////////////////////////////////////////////////// 861 ////////////////////////////////////////////////////////////////////////////////
847 // LocationBarView, private: 862 // LocationBarView, private:
848 863
849 int LocationBarView::IncrementalMinimumWidth(views::View* view) const { 864 int LocationBarView::IncrementalMinimumWidth(views::View* view) const {
850 return view->visible() ? 865 return view->visible() ?
851 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) + 866 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) +
852 view->GetMinimumSize().width()) : 0; 867 view->GetMinimumSize().width()) : 0;
853 } 868 }
854 869
855 int LocationBarView::GetHorizontalEdgeThickness() const { 870 int LocationBarView::GetHorizontalEdgeThickness() const {
871 // In Material Design horizontal layout disregards the border.
872 if (ui::MaterialDesignController::IsModeMaterial())
873 return 0;
Peter Kasting 2015/10/01 01:12:17 Conceptually it seems like if this is correct, we'
856 // In maximized popup mode, there isn't any edge. 874 // In maximized popup mode, there isn't any edge.
857 return (is_popup_mode_ && browser_ && browser_->window() && 875 return (is_popup_mode_ && browser_ && browser_->window() &&
858 browser_->window()->IsMaximized()) ? 876 browser_->window()->IsMaximized()) ?
859 0 : GetVerticalEdgeThickness(); 877 0 : GetVerticalEdgeThickness();
860 } 878 }
861 879
862 int LocationBarView::GetVerticalEdgeThickness() const { 880 int LocationBarView::GetVerticalEdgeThickness() const {
863 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; 881 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness;
864 } 882 }
865 883
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1427
1410 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1428 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1411 const SearchModel::State& new_state) { 1429 const SearchModel::State& new_state) {
1412 const bool visible = !GetToolbarModel()->input_in_progress() && 1430 const bool visible = !GetToolbarModel()->input_in_progress() &&
1413 new_state.voice_search_supported; 1431 new_state.voice_search_supported;
1414 if (mic_search_view_->visible() != visible) { 1432 if (mic_search_view_->visible() != visible) {
1415 mic_search_view_->SetVisible(visible); 1433 mic_search_view_->SetVisible(visible);
1416 Layout(); 1434 Layout();
1417 } 1435 }
1418 } 1436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698