blob: 7a3b17978d7db5c34c7ab815a370ff46e1df679f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
LocationIconView::LocationIconView(LocationBarView* location_bar)
: page_info_helper_(this, location_bar) {
SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON));
}
LocationIconView::~LocationIconView() {
}
bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) {
if (event.IsOnlyMiddleMouseButton() &&
ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) {
base::string16 text;
ui::Clipboard::GetForCurrentThread()->ReadText(
ui::CLIPBOARD_TYPE_SELECTION, &text);
text = OmniboxView::SanitizeTextForPaste(text);
OmniboxEditModel* model =
page_info_helper_.location_bar()->GetOmniboxView()->model();
if (model->CanPasteAndGo(text))
model->PasteAndGo(text);
}
// Showing the bubble on mouse release is standard button behavior.
return true;
}
void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) {
if (event.IsOnlyMiddleMouseButton())
return;
OnClickOrTap(event);
}
bool LocationIconView::OnMouseDragged(const ui::MouseEvent& event) {
page_info_helper_.location_bar()->GetOmniboxView()->CloseOmniboxPopup();
return false;
}
void LocationIconView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() != ui::ET_GESTURE_TAP)
return;
OnClickOrTap(*event);
event->SetHandled();
}
void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) {
// Do not show page info if the user has been editing the location bar or the
// location bar is at the NTP.
if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty())
return;
page_info_helper_.ProcessEvent(event);
}
void LocationIconView::ShowTooltip(bool show) {
SetTooltipText(show ?
l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16());
}
|