Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 529 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 530 i != content_setting_views_.end(); ++i) | 530 i != content_setting_views_.end(); ++i) |
| 531 trailing_width += IncrementalMinimumWidth((*i)); | 531 trailing_width += IncrementalMinimumWidth((*i)); |
| 532 | 532 |
| 533 min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() + | 533 min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() + |
| 534 2 * padding - omnibox_view_->GetInsets().width() + | 534 2 * padding - omnibox_view_->GetInsets().width() + |
| 535 trailing_width); | 535 trailing_width); |
| 536 return min_size; | 536 return min_size; |
| 537 } | 537 } |
| 538 | 538 |
| 539 void LocationBarView::UpdatedKeywordHintVisibility() { | |
|
Peter Kasting
2016/10/02 19:01:37
Nit: Update, not Updated
| |
| 540 keyword_hint_view_->SetVisible(HasFocus()); | |
| 541 } | |
| 542 | |
| 539 void LocationBarView::Layout() { | 543 void LocationBarView::Layout() { |
| 540 if (!IsInitialized()) | 544 if (!IsInitialized()) |
| 541 return; | 545 return; |
| 542 | 546 |
| 543 selected_keyword_view_->SetVisible(false); | 547 selected_keyword_view_->SetVisible(false); |
| 544 location_icon_view_->SetVisible(false); | 548 location_icon_view_->SetVisible(false); |
| 545 keyword_hint_view_->SetVisible(false); | 549 // keyword_hint_view_->SetVisible(false); |
|
Peter Kasting
2016/10/02 19:01:37
This needs to call UpdateKeywordHintVisibility().
| |
| 546 | 550 |
| 547 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | 551 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); |
| 548 const int edge_thickness = GetHorizontalEdgeThickness(); | 552 const int edge_thickness = GetHorizontalEdgeThickness(); |
| 549 | 553 |
| 550 LocationBarLayout leading_decorations( | 554 LocationBarLayout leading_decorations( |
| 551 LocationBarLayout::LEFT_EDGE, item_padding, | 555 LocationBarLayout::LEFT_EDGE, item_padding, |
| 552 item_padding - omnibox_view_->GetInsets().left()); | 556 item_padding - omnibox_view_->GetInsets().left()); |
| 553 LocationBarLayout trailing_decorations( | 557 LocationBarLayout trailing_decorations( |
| 554 LocationBarLayout::RIGHT_EDGE, item_padding, | 558 LocationBarLayout::RIGHT_EDGE, item_padding, |
| 555 item_padding - omnibox_view_->GetInsets().right()); | 559 item_padding - omnibox_view_->GetInsets().right()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 634 content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
| 631 ++i) { | 635 ++i) { |
| 632 if ((*i)->visible()) { | 636 if ((*i)->visible()) { |
| 633 trailing_decorations.AddDecoration(vertical_padding, location_height, | 637 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 634 false, 0, item_padding, item_padding, | 638 false, 0, item_padding, item_padding, |
| 635 *i); | 639 *i); |
| 636 } | 640 } |
| 637 } | 641 } |
| 638 // Because IMEs may eat the tab key, we don't show "press tab to search" while | 642 // Because IMEs may eat the tab key, we don't show "press tab to search" while |
| 639 // IME composition is in progress. | 643 // IME composition is in progress. |
| 640 if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() && | 644 if (keyword_hint_view_->visible() && !keyword.empty() && |
| 645 omnibox_view_->model()->is_keyword_hint() && | |
| 641 !omnibox_view_->IsImeComposing()) { | 646 !omnibox_view_->IsImeComposing()) { |
|
Peter Kasting
2016/10/02 19:01:37
You need all this logic to go in UpdateKeywordHint
| |
| 642 trailing_decorations.AddDecoration(vertical_padding, location_height, true, | 647 trailing_decorations.AddDecoration(vertical_padding, location_height, true, |
| 643 0, item_padding, item_padding, | 648 0, item_padding, item_padding, |
| 644 keyword_hint_view_); | 649 keyword_hint_view_); |
| 645 if (keyword_hint_view_->keyword() != keyword) | 650 if (keyword_hint_view_->keyword() != keyword) |
| 646 keyword_hint_view_->SetKeyword(keyword); | 651 keyword_hint_view_->SetKeyword(keyword); |
| 647 } | 652 } |
| 648 | 653 |
| 649 // Perform layout. | 654 // Perform layout. |
| 650 int full_width = width() - (2 * edge_thickness); | 655 int full_width = width() - (2 * edge_thickness); |
| 651 | 656 |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1217 } | 1222 } |
| 1218 | 1223 |
| 1219 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1224 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1220 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); | 1225 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); |
| 1221 if (popup->IsOpen()) | 1226 if (popup->IsOpen()) |
| 1222 popup->UpdatePopupAppearance(); | 1227 popup->UpdatePopupAppearance(); |
| 1223 } | 1228 } |
| 1224 | 1229 |
| 1225 void LocationBarView::OnFocus() { | 1230 void LocationBarView::OnFocus() { |
| 1226 omnibox_view_->SetFocus(); | 1231 omnibox_view_->SetFocus(); |
| 1232 UpdatedKeywordHintVisibility(); | |
| 1233 } | |
| 1234 | |
| 1235 void LocationBarView::OnBlur() { | |
| 1236 UpdatedKeywordHintVisibility(); | |
| 1227 } | 1237 } |
| 1228 | 1238 |
| 1229 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 1239 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
| 1230 View::OnPaint(canvas); | 1240 View::OnPaint(canvas); |
| 1231 | 1241 |
| 1232 if (show_focus_rect_ && omnibox_view_->HasFocus()) { | 1242 if (show_focus_rect_ && omnibox_view_->HasFocus()) { |
| 1233 SkPaint paint; | 1243 SkPaint paint; |
| 1234 paint.setAntiAlias(true); | 1244 paint.setAntiAlias(true); |
| 1235 paint.setColor(GetNativeTheme()->GetSystemColor( | 1245 paint.setColor(GetNativeTheme()->GetSystemColor( |
| 1236 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor)); | 1246 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 // LocationBarView, private TemplateURLServiceObserver implementation: | 1337 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1328 | 1338 |
| 1329 void LocationBarView::OnTemplateURLServiceChanged() { | 1339 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1330 template_url_service_->RemoveObserver(this); | 1340 template_url_service_->RemoveObserver(this); |
| 1331 template_url_service_ = nullptr; | 1341 template_url_service_ = nullptr; |
| 1332 // If the browser is no longer active, let's not show the info bubble, as this | 1342 // 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. | 1343 // would make the browser the active window again. |
| 1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1344 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1335 ShowFirstRunBubble(); | 1345 ShowFirstRunBubble(); |
| 1336 } | 1346 } |
| OLD | NEW |