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

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

Issue 1998493002: Update omnibox chips in MD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review 2 Created 4 years, 7 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 std::max(GetPreferredSize().height() - (vertical_padding * 2), 0); 211 std::max(GetPreferredSize().height() - (vertical_padding * 2), 0);
212 font_list = font_list.DeriveWithHeightUpperBound(location_height); 212 font_list = font_list.DeriveWithHeightUpperBound(location_height);
213 213
214 // Determine the font for use inside the bubbles. 214 // Determine the font for use inside the bubbles.
215 const int bubble_padding = 215 const int bubble_padding =
216 GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + 216 GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) +
217 GetLayoutConstant(LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING); 217 GetLayoutConstant(LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING);
218 const int bubble_height = location_height - (bubble_padding * 2); 218 const int bubble_height = location_height - (bubble_padding * 2);
219 gfx::FontList bubble_font_list = 219 gfx::FontList bubble_font_list =
220 font_list.DeriveWithHeightUpperBound(bubble_height); 220 font_list.DeriveWithHeightUpperBound(bubble_height);
221 gfx::FontList chip_font_list = ui::MaterialDesignController::IsModeMaterial()
222 ? font_list
223 : bubble_font_list;
221 224
222 const SkColor background_color = GetColor(BACKGROUND); 225 const SkColor background_color = GetColor(BACKGROUND);
223 location_icon_view_ = 226 location_icon_view_ =
224 new LocationIconView(bubble_font_list, background_color, this); 227 new LocationIconView(chip_font_list, background_color, this);
225 location_icon_view_->set_drag_controller(this); 228 location_icon_view_->set_drag_controller(this);
226 AddChildView(location_icon_view_); 229 AddChildView(location_icon_view_);
227 230
228 // Initialize the Omnibox view. 231 // Initialize the Omnibox view.
229 omnibox_view_ = new OmniboxViewViews( 232 omnibox_view_ = new OmniboxViewViews(
230 this, profile(), command_updater(), is_popup_mode_, this, font_list); 233 this, profile(), command_updater(), is_popup_mode_, this, font_list);
231 omnibox_view_->Init(); 234 omnibox_view_->Init();
232 omnibox_view_->SetFocusBehavior(FocusBehavior::ALWAYS); 235 omnibox_view_->SetFocusBehavior(FocusBehavior::ALWAYS);
233 AddChildView(omnibox_view_); 236 AddChildView(omnibox_view_);
234 237
235 // Initialize the inline autocomplete view which is visible only when IME is 238 // Initialize the inline autocomplete view which is visible only when IME is
236 // turned on. Use the same font with the omnibox and highlighted background. 239 // turned on. Use the same font with the omnibox and highlighted background.
237 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); 240 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list);
238 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 241 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
239 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); 242 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false);
240 ime_inline_autocomplete_view_->set_background( 243 ime_inline_autocomplete_view_->set_background(
241 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 244 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
242 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 245 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
243 ime_inline_autocomplete_view_->SetEnabledColor( 246 ime_inline_autocomplete_view_->SetEnabledColor(
244 GetNativeTheme()->GetSystemColor( 247 GetNativeTheme()->GetSystemColor(
245 ui::NativeTheme::kColorId_TextfieldSelectionColor)); 248 ui::NativeTheme::kColorId_TextfieldSelectionColor));
246 ime_inline_autocomplete_view_->SetVisible(false); 249 ime_inline_autocomplete_view_->SetVisible(false);
247 AddChildView(ime_inline_autocomplete_view_); 250 AddChildView(ime_inline_autocomplete_view_);
248 251
249 const SkColor selected_text_color = GetColor(TEXT); 252 const SkColor selected_text_color = GetColor(TEXT);
250 selected_keyword_view_ = new SelectedKeywordView( 253 selected_keyword_view_ = new SelectedKeywordView(
251 bubble_font_list, selected_text_color, background_color, profile()); 254 chip_font_list, selected_text_color, background_color, profile());
252 AddChildView(selected_keyword_view_); 255 AddChildView(selected_keyword_view_);
253 256
254 suggested_text_view_ = new views::Label(base::string16(), font_list); 257 suggested_text_view_ = new views::Label(base::string16(), font_list);
255 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 258 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
256 suggested_text_view_->SetAutoColorReadabilityEnabled(false); 259 suggested_text_view_->SetAutoColorReadabilityEnabled(false);
257 suggested_text_view_->SetEnabledColor( 260 suggested_text_view_->SetEnabledColor(
258 GetColor(LocationBarView::DEEMPHASIZED_TEXT)); 261 GetColor(LocationBarView::DEEMPHASIZED_TEXT));
259 suggested_text_view_->SetVisible(false); 262 suggested_text_view_->SetVisible(false);
260 AddChildView(suggested_text_view_); 263 AddChildView(suggested_text_view_);
261 264
262 keyword_hint_view_ = new KeywordHintView( 265 keyword_hint_view_ = new KeywordHintView(
263 profile(), font_list, bubble_font_list, location_height, 266 profile(), font_list, bubble_font_list, location_height,
264 GetColor(LocationBarView::DEEMPHASIZED_TEXT), background_color); 267 GetColor(LocationBarView::DEEMPHASIZED_TEXT), background_color);
265 AddChildView(keyword_hint_view_); 268 AddChildView(keyword_hint_view_);
266 269
267 ScopedVector<ContentSettingImageModel> models = 270 ScopedVector<ContentSettingImageModel> models =
268 ContentSettingImageModel::GenerateContentSettingImageModels(); 271 ContentSettingImageModel::GenerateContentSettingImageModels();
269 for (ContentSettingImageModel* model : models.get()) { 272 for (ContentSettingImageModel* model : models.get()) {
270 // ContentSettingImageView takes ownership of its model. 273 // ContentSettingImageView takes ownership of its model.
271 ContentSettingImageView* image_view = new ContentSettingImageView( 274 ContentSettingImageView* image_view = new ContentSettingImageView(
272 model, this, bubble_font_list, background_color); 275 model, this, chip_font_list, background_color);
273 content_setting_views_.push_back(image_view); 276 content_setting_views_.push_back(image_view);
274 image_view->SetVisible(false); 277 image_view->SetVisible(false);
275 AddChildView(image_view); 278 AddChildView(image_view);
276 } 279 }
277 models.weak_clear(); 280 models.weak_clear();
278 281
279 zoom_view_ = new ZoomView(delegate_); 282 zoom_view_ = new ZoomView(delegate_);
280 AddChildView(zoom_view_); 283 AddChildView(zoom_view_);
281 284
282 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); 285 open_pdf_in_reader_view_ = new OpenPDFInReaderView();
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); 573 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
571 const int edge_thickness = GetHorizontalEdgeThickness(); 574 const int edge_thickness = GetHorizontalEdgeThickness();
572 int trailing_edge_item_padding = 0; 575 int trailing_edge_item_padding = 0;
573 if (!ui::MaterialDesignController::IsModeMaterial()) { 576 if (!ui::MaterialDesignController::IsModeMaterial()) {
574 trailing_edge_item_padding = 577 trailing_edge_item_padding =
575 item_padding - edge_thickness - omnibox_view_->GetInsets().right(); 578 item_padding - edge_thickness - omnibox_view_->GetInsets().right();
576 } 579 }
577 580
578 LocationBarLayout leading_decorations( 581 LocationBarLayout leading_decorations(
579 LocationBarLayout::LEFT_EDGE, item_padding, 582 LocationBarLayout::LEFT_EDGE, item_padding,
580 item_padding - omnibox_view_->GetInsets().left() - 583 ui::MaterialDesignController::IsModeMaterial()
581 GetEditLeadingInternalSpace()); 584 ? 2
585 : item_padding - omnibox_view_->GetInsets().left() -
586 GetEditLeadingInternalSpace());
Peter Kasting 2016/05/20 20:54:11 Nit: I'd parenthesize this last subexpr just to av
Evan Stade 2016/05/20 22:33:53 Done.
582 LocationBarLayout trailing_decorations( 587 LocationBarLayout trailing_decorations(
583 LocationBarLayout::RIGHT_EDGE, item_padding, trailing_edge_item_padding); 588 LocationBarLayout::RIGHT_EDGE, item_padding, trailing_edge_item_padding);
584 589
585 const base::string16 keyword(omnibox_view_->model()->keyword()); 590 const base::string16 keyword(omnibox_view_->model()->keyword());
586 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 591 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
587 // to position our child views in this case, because other things may be 592 // to position our child views in this case, because other things may be
588 // positioned relative to them (e.g. the "bookmark added" bubble if the user 593 // positioned relative to them (e.g. the "bookmark added" bubble if the user
589 // hits ctrl-d). 594 // hits ctrl-d).
590 const int bubble_horizontal_padding = 595 const int bubble_horizontal_padding =
591 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING); 596 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 // LocationBarView, private TemplateURLServiceObserver implementation: 1389 // LocationBarView, private TemplateURLServiceObserver implementation:
1385 1390
1386 void LocationBarView::OnTemplateURLServiceChanged() { 1391 void LocationBarView::OnTemplateURLServiceChanged() {
1387 template_url_service_->RemoveObserver(this); 1392 template_url_service_->RemoveObserver(this);
1388 template_url_service_ = nullptr; 1393 template_url_service_ = nullptr;
1389 // If the browser is no longer active, let's not show the info bubble, as this 1394 // If the browser is no longer active, let's not show the info bubble, as this
1390 // would make the browser the active window again. 1395 // would make the browser the active window again.
1391 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1396 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1392 ShowFirstRunBubble(); 1397 ShowFirstRunBubble();
1393 } 1398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698