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

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

Issue 2731113002: Adjust elision of omnibox keyword search label. (Closed)
Patch Set: . Created 3 years, 9 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, 479 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE,
480 item_padding, item_padding); 480 item_padding, item_padding);
481 481
482 const base::string16 keyword(omnibox_view_->model()->keyword()); 482 const base::string16 keyword(omnibox_view_->model()->keyword());
483 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 483 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
484 // to position our child views in this case, because other things may be 484 // to position our child views in this case, because other things may be
485 // positioned relative to them (e.g. the "bookmark added" bubble if the user 485 // positioned relative to them (e.g. the "bookmark added" bubble if the user
486 // hits ctrl-d). 486 // hits ctrl-d).
487 const int vertical_padding = GetTotalVerticalPadding(); 487 const int vertical_padding = GetTotalVerticalPadding();
488 const int location_height = std::max(height() - (vertical_padding * 2), 0); 488 const int location_height = std::max(height() - (vertical_padding * 2), 0);
489 // The largest fraction of the omnibox that can be taken by the EV or search
490 // label/chip.
491 const double kMaxBubbleFraction = 0.5;
Peter Kasting 2017/03/07 02:28:45 Nit: Now that we've moved away from "bubble" prese
489 492
490 location_icon_view_->SetLabel(base::string16()); 493 location_icon_view_->SetLabel(base::string16());
494
491 if (ShouldShowKeywordBubble()) { 495 if (ShouldShowKeywordBubble()) {
492 leading_decorations.AddDecoration(vertical_padding, location_height, true, 496 leading_decorations.AddDecoration(vertical_padding, location_height, false,
493 0, item_padding, item_padding, 497 kMaxBubbleFraction, item_padding,
494 selected_keyword_view_); 498 item_padding, selected_keyword_view_);
495 if (selected_keyword_view_->keyword() != keyword) { 499 if (selected_keyword_view_->keyword() != keyword) {
496 selected_keyword_view_->SetKeyword(keyword); 500 selected_keyword_view_->SetKeyword(keyword);
497 const TemplateURL* template_url = 501 const TemplateURL* template_url =
498 TemplateURLServiceFactory::GetForProfile(profile())-> 502 TemplateURLServiceFactory::GetForProfile(profile())->
499 GetTemplateURLForKeyword(keyword); 503 GetTemplateURLForKeyword(keyword);
500 if (template_url && 504 if (template_url &&
501 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { 505 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) {
502 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> 506 gfx::Image image = extensions::OmniboxAPI::Get(profile())->
503 GetOmniboxIcon(template_url->GetExtensionId()); 507 GetOmniboxIcon(template_url->GetExtensionId());
504 selected_keyword_view_->SetImage(image.AsImageSkia()); 508 selected_keyword_view_->SetImage(image.AsImageSkia());
505 } else { 509 } else {
506 selected_keyword_view_->ResetImage(); 510 selected_keyword_view_->ResetImage();
507 } 511 }
508 } 512 }
509 } else if (ShouldShowLocationIconText()) { 513 } else if (ShouldShowLocationIconText()) {
510 location_icon_view_->SetLabel(GetLocationIconText()); 514 location_icon_view_->SetLabel(GetLocationIconText());
511 // The largest fraction of the omnibox that can be taken by the EV bubble.
512 const double kMaxBubbleFraction = 0.5;
Evan Stade 2017/03/07 01:20:14 I didn't even notice till just now this is the sam
Peter Kasting 2017/03/07 02:28:45 Honestly, we should probably apply these limits to
513 leading_decorations.AddDecoration(vertical_padding, location_height, false, 515 leading_decorations.AddDecoration(vertical_padding, location_height, false,
514 kMaxBubbleFraction, item_padding, 516 kMaxBubbleFraction, item_padding,
515 item_padding, location_icon_view_); 517 item_padding, location_icon_view_);
516 } else { 518 } else {
517 leading_decorations.AddDecoration(vertical_padding, location_height, 519 leading_decorations.AddDecoration(vertical_padding, location_height,
518 location_icon_view_); 520 location_icon_view_);
519 } 521 }
520 522
521 if (star_view_->visible()) { 523 if (star_view_->visible()) {
522 trailing_decorations.AddDecoration(vertical_padding, location_height, 524 trailing_decorations.AddDecoration(vertical_padding, location_height,
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 // LocationBarView, private TemplateURLServiceObserver implementation: 1209 // LocationBarView, private TemplateURLServiceObserver implementation:
1208 1210
1209 void LocationBarView::OnTemplateURLServiceChanged() { 1211 void LocationBarView::OnTemplateURLServiceChanged() {
1210 template_url_service_->RemoveObserver(this); 1212 template_url_service_->RemoveObserver(this);
1211 template_url_service_ = nullptr; 1213 template_url_service_ = nullptr;
1212 // If the browser is no longer active, let's not show the info bubble, as this 1214 // If the browser is no longer active, let's not show the info bubble, as this
1213 // would make the browser the active window again. 1215 // would make the browser the active window again.
1214 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1216 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1215 ShowFirstRunBubble(); 1217 ShowFirstRunBubble();
1216 } 1218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698