| 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 OnClickOrTap(event); |
| 30 !chrome::ShouldDisplayOriginChipV2()) | |
| 31 page_info_helper_.ProcessEvent(event); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { | 33 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { |
| 35 if (!chrome::ShouldDisplayOriginChip() && | 34 if (event->type() != ui::ET_GESTURE_TAP) |
| 36 !chrome::ShouldDisplayOriginChipV2() && | 35 return; |
| 37 (event->type() == ui::ET_GESTURE_TAP)) { | 36 OnClickOrTap(*event); |
| 38 page_info_helper_.ProcessEvent(*event); | 37 event->SetHandled(); |
| 39 event->SetHandled(); | 38 } |
| 40 } | 39 |
| 40 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
| 41 // Do not show page info if the user has been editing the location bar or the |
| 42 // location bar is at the NTP. Also skip showing the page info if the |
| 43 // toolbar-based origin chip is being shown because it is responsible for |
| 44 // showing the page info instead. |
| 45 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty() || |
| 46 chrome::ShouldDisplayOriginChip()) |
| 47 return; |
| 48 |
| 49 page_info_helper_.ProcessEvent(event); |
| 41 } | 50 } |
| 42 | 51 |
| 43 void LocationIconView::ShowTooltip(bool show) { | 52 void LocationIconView::ShowTooltip(bool show) { |
| 44 SetTooltipText(show ? | 53 SetTooltipText(show ? |
| 45 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); | 54 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); |
| 46 } | 55 } |
| OLD | NEW |