Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_icon_view.cc

Issue 561883006: Hide location icon bubble on 2nd click. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
9 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
11 12
12 LocationIconView::LocationIconView(LocationBarView* location_bar) 13 LocationIconView::LocationIconView(LocationBarView* location_bar)
13 : page_info_helper_(this, location_bar) { 14 : suppress_mouse_released_action_(false),
15 page_info_helper_(this, location_bar) {
14 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); 16 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON));
15 } 17 }
16 18
17 LocationIconView::~LocationIconView() { 19 LocationIconView::~LocationIconView() {
18 } 20 }
19 21
20 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { 22 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) {
21 if (event.IsOnlyMiddleMouseButton() && 23 if (event.IsOnlyMiddleMouseButton() &&
22 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { 24 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) {
23 base::string16 text; 25 base::string16 text;
24 ui::Clipboard::GetForCurrentThread()->ReadText( 26 ui::Clipboard::GetForCurrentThread()->ReadText(
25 ui::CLIPBOARD_TYPE_SELECTION, &text); 27 ui::CLIPBOARD_TYPE_SELECTION, &text);
26 text = OmniboxView::SanitizeTextForPaste(text); 28 text = OmniboxView::SanitizeTextForPaste(text);
27 OmniboxEditModel* model = 29 OmniboxEditModel* model =
28 page_info_helper_.location_bar()->GetOmniboxView()->model(); 30 page_info_helper_.location_bar()->GetOmniboxView()->model();
29 if (model->CanPasteAndGo(text)) 31 if (model->CanPasteAndGo(text))
30 model->PasteAndGo(text); 32 model->PasteAndGo(text);
31 } 33 }
32 34
33 // Showing the bubble on mouse release is standard button behavior. 35 suppress_mouse_released_action_ = WebsiteSettingsPopupView::IsPopupShowing();
34 return true; 36 return true;
35 } 37 }
36 38
37 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { 39 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) {
38 if (event.IsOnlyMiddleMouseButton()) 40 if (event.IsOnlyMiddleMouseButton())
39 return; 41 return;
42
43 // If this is the second click on this view then the bubble was showing on
44 // the mouse pressed event and is hidden now. Prevent the bubble from
45 // reshowing by doing nothing here.
46 if (suppress_mouse_released_action_) {
47 suppress_mouse_released_action_ = false;
48 return;
49 }
50
40 OnClickOrTap(event); 51 OnClickOrTap(event);
41 } 52 }
42 53
43 bool LocationIconView::OnMouseDragged(const ui::MouseEvent& event) { 54 bool LocationIconView::OnMouseDragged(const ui::MouseEvent& event) {
44 page_info_helper_.location_bar()->GetOmniboxView()->CloseOmniboxPopup(); 55 page_info_helper_.location_bar()->GetOmniboxView()->CloseOmniboxPopup();
45 return false; 56 return false;
46 } 57 }
47 58
48 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { 59 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) {
49 if (event->type() != ui::ET_GESTURE_TAP) 60 if (event->type() != ui::ET_GESTURE_TAP)
50 return; 61 return;
51 OnClickOrTap(*event); 62 OnClickOrTap(*event);
52 event->SetHandled(); 63 event->SetHandled();
53 } 64 }
54 65
55 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { 66 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) {
56 // Do not show page info if the user has been editing the location bar or the 67 // Do not show page info if the user has been editing the location bar or the
57 // location bar is at the NTP. 68 // location bar is at the NTP.
58 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty()) 69 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty())
59 return; 70 return;
60 71
61 page_info_helper_.ProcessEvent(event); 72 page_info_helper_.ProcessEvent(event);
62 } 73 }
63 74
64 void LocationIconView::ShowTooltip(bool show) { 75 void LocationIconView::ShowTooltip(bool show) {
65 SetTooltipText(show ? 76 SetTooltipText(show ?
66 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); 77 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16());
67 } 78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698