location_icon_view.cc revision ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16
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 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/views/location_bar/location_icon_view.h" 6 7#include "base/strings/utf_string_conversions.h" 8#include "chrome/browser/ui/views/location_bar/location_bar_view.h" 9#include "grit/generated_resources.h" 10#include "ui/base/l10n/l10n_util.h" 11 12LocationIconView::LocationIconView(LocationBarView* location_bar) 13 : page_info_helper_(this, location_bar) { 14 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); 15 LocationBarView::InitTouchableLocationBarChildView(this); 16} 17 18LocationIconView::~LocationIconView() { 19} 20 21bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { 22 // We want to show the dialog on mouse release; that is the standard behavior 23 // for buttons. 24 return true; 25} 26 27void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { 28 page_info_helper_.ProcessEvent(event); 29} 30 31void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { 32 if (event->type() == ui::ET_GESTURE_TAP) { 33 page_info_helper_.ProcessEvent(*event); 34 event->SetHandled(); 35 } 36} 37 38void LocationIconView::ShowTooltip(bool show) { 39 SetTooltipText(show ? 40 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); 41} 42