15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
83d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "grit/generated_resources.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)LocationIconView::LocationIconView(LocationBarView* location_bar)
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    : page_info_helper_(this, location_bar) {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON));
153d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch  LocationBarView::InitTouchableLocationBarChildView(this);
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)LocationIconView::~LocationIconView() {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We want to show the dialog on mouse release; that is the standard behavior
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for buttons.
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return true;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) {
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  page_info_helper_.ProcessEvent(event);
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void LocationIconView::OnGestureEvent(ui::GestureEvent* event) {
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (event->type() == ui::ET_GESTURE_TAP) {
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    page_info_helper_.ProcessEvent(*event);
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    event->SetHandled();
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void LocationIconView::ShowTooltip(bool show) {
393d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch  SetTooltipText(show ?
403d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch      l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16());
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
42