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_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/search/search.h" | |
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
10 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
12 | 11 |
13 LocationIconView::LocationIconView(LocationBarView* location_bar) | 12 LocationIconView::LocationIconView(LocationBarView* location_bar) |
14 : page_info_helper_(this, location_bar) { | 13 : page_info_helper_(this, location_bar) { |
15 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); | 14 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); |
16 } | 15 } |
17 | 16 |
18 LocationIconView::~LocationIconView() { | 17 LocationIconView::~LocationIconView() { |
(...skipping 29 matching lines...) Expand all Loading... |
48 | 47 |
49 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { | 48 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { |
50 if (event->type() != ui::ET_GESTURE_TAP) | 49 if (event->type() != ui::ET_GESTURE_TAP) |
51 return; | 50 return; |
52 OnClickOrTap(*event); | 51 OnClickOrTap(*event); |
53 event->SetHandled(); | 52 event->SetHandled(); |
54 } | 53 } |
55 | 54 |
56 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { | 55 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
57 // Do not show page info if the user has been editing the location bar or the | 56 // Do not show page info if the user has been editing the location bar or the |
58 // location bar is at the NTP. Also skip showing the page info if the | 57 // location bar is at the NTP. |
59 // toolbar-based origin chip is being shown because it is responsible for | 58 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty()) |
60 // showing the page info instead. | |
61 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty() || | |
62 chrome::ShouldDisplayOriginChip()) | |
63 return; | 59 return; |
64 | 60 |
65 page_info_helper_.ProcessEvent(event); | 61 page_info_helper_.ProcessEvent(event); |
66 } | 62 } |
67 | 63 |
68 void LocationIconView::ShowTooltip(bool show) { | 64 void LocationIconView::ShowTooltip(bool show) { |
69 SetTooltipText(show ? | 65 SetTooltipText(show ? |
70 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); | 66 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); |
71 } | 67 } |
OLD | NEW |