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

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: 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
35 // If the bubble is showing then don't reshow it when the mouse is released.
36 suppress_mouse_released_action_ = WebsiteSettingsPopupView::IsPopupShowing();
33 // Showing the bubble on mouse release is standard button behavior. 37 // Showing the bubble on mouse release is standard button behavior.
34 return true; 38 return true;
Peter Kasting 2014/09/17 20:51:42 Nit: I'd just eliminate both comments here. I don
Gaja 2014/09/18 02:51:39 Done.
35 } 39 }
36 40
37 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { 41 void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) {
38 if (event.IsOnlyMiddleMouseButton()) 42 if (event.IsOnlyMiddleMouseButton())
39 return; 43 return;
44 // If this is the second click on this view then the bubble was showing on
Peter Kasting 2014/09/17 20:51:42 Nit: Blank line above this
Gaja 2014/09/18 02:51:39 Done.
45 // the mouse pressed event and is hidden now. Prevent the bubble from
46 // reshowing by doing nothing here.
47 if (suppress_mouse_released_action_) {
48 suppress_mouse_released_action_ = false;
49 return;
50 }
51
40 OnClickOrTap(event); 52 OnClickOrTap(event);
41 } 53 }
42 54
43 bool LocationIconView::OnMouseDragged(const ui::MouseEvent& event) { 55 bool LocationIconView::OnMouseDragged(const ui::MouseEvent& event) {
44 page_info_helper_.location_bar()->GetOmniboxView()->CloseOmniboxPopup(); 56 page_info_helper_.location_bar()->GetOmniboxView()->CloseOmniboxPopup();
45 return false; 57 return false;
46 } 58 }
47 59
48 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { 60 void LocationIconView::OnGestureEvent(ui::GestureEvent* event) {
49 if (event->type() != ui::ET_GESTURE_TAP) 61 if (event->type() != ui::ET_GESTURE_TAP)
50 return; 62 return;
51 OnClickOrTap(*event); 63 OnClickOrTap(*event);
52 event->SetHandled(); 64 event->SetHandled();
53 } 65 }
54 66
55 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { 67 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) {
56 // Do not show page info if the user has been editing the location bar or the 68 // Do not show page info if the user has been editing the location bar or the
57 // location bar is at the NTP. 69 // location bar is at the NTP.
58 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty()) 70 if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty())
59 return; 71 return;
60 72
61 page_info_helper_.ProcessEvent(event); 73 page_info_helper_.ProcessEvent(event);
62 } 74 }
63 75
64 void LocationIconView::ShowTooltip(bool show) { 76 void LocationIconView::ShowTooltip(bool show) {
65 SetTooltipText(show ? 77 SetTooltipText(show ?
66 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16()); 78 l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON) : base::string16());
67 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698