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

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

Issue 2373773002: Fix a bug that viewed Omnibox hint when hint loses focus (Closed)
Patch Set: Revise code indentation and add comment Created 4 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/command_line.h" 10 #include "base/command_line.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 trailing_width); 535 trailing_width);
536 return min_size; 536 return min_size;
537 } 537 }
538 538
539 void LocationBarView::Layout() { 539 void LocationBarView::Layout() {
540 if (!IsInitialized()) 540 if (!IsInitialized())
541 return; 541 return;
542 542
543 selected_keyword_view_->SetVisible(false); 543 selected_keyword_view_->SetVisible(false);
544 location_icon_view_->SetVisible(false); 544 location_icon_view_->SetVisible(false);
545 keyword_hint_view_->SetVisible(false); 545 keyword_hint_view_->SetVisible(false);
Peter Kasting 2016/09/30 22:47:26 Might be clearer to set the visibility here based
546 546
547 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); 547 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
548 const int edge_thickness = GetHorizontalEdgeThickness(); 548 const int edge_thickness = GetHorizontalEdgeThickness();
549 549
550 LocationBarLayout leading_decorations( 550 LocationBarLayout leading_decorations(
551 LocationBarLayout::LEFT_EDGE, item_padding, 551 LocationBarLayout::LEFT_EDGE, item_padding,
552 item_padding - omnibox_view_->GetInsets().left()); 552 item_padding - omnibox_view_->GetInsets().left());
553 LocationBarLayout trailing_decorations( 553 LocationBarLayout trailing_decorations(
554 LocationBarLayout::RIGHT_EDGE, item_padding, 554 LocationBarLayout::RIGHT_EDGE, item_padding,
555 item_padding - omnibox_view_->GetInsets().right()); 555 item_padding - omnibox_view_->GetInsets().right());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 content_setting_views_.rbegin()); i != content_setting_views_.rend(); 630 content_setting_views_.rbegin()); i != content_setting_views_.rend();
631 ++i) { 631 ++i) {
632 if ((*i)->visible()) { 632 if ((*i)->visible()) {
633 trailing_decorations.AddDecoration(vertical_padding, location_height, 633 trailing_decorations.AddDecoration(vertical_padding, location_height,
634 false, 0, item_padding, item_padding, 634 false, 0, item_padding, item_padding,
635 *i); 635 *i);
636 } 636 }
637 } 637 }
638 // Because IMEs may eat the tab key, we don't show "press tab to search" while 638 // Because IMEs may eat the tab key, we don't show "press tab to search" while
639 // IME composition is in progress. 639 // IME composition is in progress.
640 if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() && 640 if (HasFocus() && !keyword.empty() && omnibox_view_->model()->is_keyword_hint( ) &&
Peter Kasting 2016/09/30 22:47:26 80 columns
641 !omnibox_view_->IsImeComposing()) { 641 » !omnibox_view_->IsImeComposing()) {
Peter Kasting 2016/09/30 22:47:26 Spaces, not tabs
642 trailing_decorations.AddDecoration(vertical_padding, location_height, true, 642 » trailing_decorations.AddDecoration(vertical_padding, location_height, true,
643 0, item_padding, item_padding, 643 » » 0, item_padding, item_padding,
644 keyword_hint_view_); 644 » » keyword_hint_view_);
645 if (keyword_hint_view_->keyword() != keyword) 645 » if (keyword_hint_view_->keyword() != keyword)
Peter Kasting 2016/09/30 22:47:26 Do not add trailing space
646 keyword_hint_view_->SetKeyword(keyword); 646 » keyword_hint_view_->SetKeyword(keyword);
647 } 647 }
648
Peter Kasting 2016/09/30 22:47:26 Do not add second blank line
648 649
649 // Perform layout. 650 // Perform layout.
650 int full_width = width() - (2 * edge_thickness); 651 int full_width = width() - (2 * edge_thickness);
651 652
652 int entry_width = full_width; 653 int entry_width = full_width;
653 leading_decorations.LayoutPass1(&entry_width); 654 leading_decorations.LayoutPass1(&entry_width);
654 trailing_decorations.LayoutPass1(&entry_width); 655 trailing_decorations.LayoutPass1(&entry_width);
655 leading_decorations.LayoutPass2(&entry_width); 656 leading_decorations.LayoutPass2(&entry_width);
656 trailing_decorations.LayoutPass2(&entry_width); 657 trailing_decorations.LayoutPass2(&entry_width);
657 658
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // LocationBarView, private TemplateURLServiceObserver implementation: 1328 // LocationBarView, private TemplateURLServiceObserver implementation:
1328 1329
1329 void LocationBarView::OnTemplateURLServiceChanged() { 1330 void LocationBarView::OnTemplateURLServiceChanged() {
1330 template_url_service_->RemoveObserver(this); 1331 template_url_service_->RemoveObserver(this);
1331 template_url_service_ = nullptr; 1332 template_url_service_ = nullptr;
1332 // If the browser is no longer active, let's not show the info bubble, as this 1333 // If the browser is no longer active, let's not show the info bubble, as this
1333 // would make the browser the active window again. 1334 // would make the browser the active window again.
1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1335 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1335 ShowFirstRunBubble(); 1336 ShowFirstRunBubble();
1336 } 1337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698