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" | 8 #include "chrome/browser/search/search.h" |
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 LocationIconView::LocationIconView(LocationBarView* location_bar) | 13 LocationIconView::LocationIconView(LocationBarView* location_bar) |
14 : page_info_helper_(this, location_bar) { | 14 : page_info_helper_(this, location_bar), |
15 location_bar_(location_bar) { | |
15 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); | 16 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); |
16 LocationBarView::InitTouchableLocationBarChildView(this); | 17 LocationBarView::InitTouchableLocationBarChildView(this); |
17 } | 18 } |
18 | 19 |
19 LocationIconView::~LocationIconView() { | 20 LocationIconView::~LocationIconView() { |
20 } | 21 } |
21 | 22 |
22 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { | 23 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { |
23 // We want to show the dialog on mouse release; that is the standard behavior | 24 // We want to show the dialog on mouse release; that is the standard behavior |
24 // for buttons. | 25 // for buttons. |
25 return true; | 26 return true; |
26 } | 27 } |
27 | 28 |
28 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { | 29 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { |
29 if (!chrome::ShouldDisplayOriginChip() && | 30 // Do not show page info if the user has been editing the location bar or the |
30 !chrome::ShouldDisplayOriginChipV2()) | 31 // location bar is at the NTP. Also skip showing the page info if the |
31 page_info_helper_.ProcessEvent(event); | 32 // toolbar-based origin chip is being shown because it is responsible for |
33 // showing the page info instead. | |
34 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty() || | |
groby-ooo-7-16
2014/03/12 19:53:46
Random drive-by-question: Why not handle this in |
Peter Kasting
2014/03/12 21:11:27
Yeah, it's not clear to me why the code like this
Justin Donnelly
2014/03/14 15:27:51
PageInfoHelper is used in 3 places:
- The location
| |
35 chrome::ShouldDisplayOriginChip()) | |
36 return; | |
37 | |
38 page_info_helper_.ProcessEvent(event); | |
32 } | 39 } |
33 | 40 |
34 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { | 41 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { |
35 if (!chrome::ShouldDisplayOriginChip() && | 42 // Do not show page info if the user has been editing the location bar or the |
36 !chrome::ShouldDisplayOriginChipV2() && | 43 // location bar is at the NTP. Also skip showing the page info if the |
37 (event->type() == ui::ET_GESTURE_TAP)) { | 44 // toolbar-based origin chip is being shown because it is responsible for |
38 page_info_helper_.ProcessEvent(*event); | 45 // showing the page info instead. |
39 event->SetHandled(); | 46 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty() || |
40 } | 47 chrome::ShouldDisplayOriginChip() || |
48 (event->type() != ui::ET_GESTURE_TAP)) | |
49 return; | |
50 | |
51 page_info_helper_.ProcessEvent(*event); | |
52 event->SetHandled(); | |
41 } | 53 } |
42 | 54 |
43 void LocationIconView::ShowTooltip(bool show) { | 55 void LocationIconView::ShowTooltip(bool show) { |
44 SetTooltipText(show ? | 56 SetTooltipText(show ? |
45 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); | 57 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); |
46 } | 58 } |
OLD | NEW |