OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bubble_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/bubble_icon_view.h" |
6 | 6 |
7 #include "chrome/browser/command_updater.h" | 7 #include "chrome/browser/command_updater.h" |
8 #include "ui/accessibility/ax_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 | 10 |
11 BubbleIconView::BubbleIconView() : command_updater_(nullptr), command_id_(0) { | |
msw
2014/10/24 00:00:55
This ctor should also SetAccessibilityFocusable(tr
Dan Beam
2014/10/24 00:26:19
meh, just removed this ctor
| |
12 } | |
13 | |
11 BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id) | 14 BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id) |
12 : command_updater_(command_updater), | 15 : command_updater_(command_updater), |
13 command_id_(command_id), | 16 command_id_(command_id), |
14 suppress_mouse_released_action_(false) { | 17 suppress_mouse_released_action_(false) { |
15 SetAccessibilityFocusable(true); | 18 SetAccessibilityFocusable(true); |
16 } | 19 } |
17 | 20 |
18 BubbleIconView::~BubbleIconView() { | 21 BubbleIconView::~BubbleIconView() { |
19 } | 22 } |
20 | 23 |
(...skipping 21 matching lines...) Expand all Loading... | |
42 | 45 |
43 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { | 46 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { |
44 // If this is the second click on this view then the bubble was showing on the | 47 // If this is the second click on this view then the bubble was showing on the |
45 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by | 48 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by |
46 // doing nothing here. | 49 // doing nothing here. |
47 if (suppress_mouse_released_action_) { | 50 if (suppress_mouse_released_action_) { |
48 suppress_mouse_released_action_ = false; | 51 suppress_mouse_released_action_ = false; |
49 return; | 52 return; |
50 } | 53 } |
51 | 54 |
52 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) { | 55 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) |
53 OnExecuting(EXECUTE_SOURCE_MOUSE); | 56 ExecuteCommand(EXECUTE_SOURCE_MOUSE); |
54 command_updater_->ExecuteCommand(command_id_); | |
55 } | |
56 } | 57 } |
57 | 58 |
58 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { | 59 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { |
59 if (event.key_code() == ui::VKEY_SPACE || | 60 if (event.key_code() == ui::VKEY_SPACE || |
60 event.key_code() == ui::VKEY_RETURN) { | 61 event.key_code() == ui::VKEY_RETURN) { |
61 OnExecuting(EXECUTE_SOURCE_KEYBOARD); | 62 ExecuteCommand(EXECUTE_SOURCE_KEYBOARD); |
62 command_updater_->ExecuteCommand(command_id_); | |
63 return true; | 63 return true; |
64 } | 64 } |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { | 68 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { |
69 if (event->type() == ui::ET_GESTURE_TAP) { | 69 if (event->type() == ui::ET_GESTURE_TAP) { |
70 OnExecuting(EXECUTE_SOURCE_GESTURE); | 70 ExecuteCommand(EXECUTE_SOURCE_GESTURE); |
71 command_updater_->ExecuteCommand(command_id_); | |
72 event->SetHandled(); | 71 event->SetHandled(); |
73 } | 72 } |
74 } | 73 } |
74 | |
75 void BubbleIconView::ExecuteCommand(ExecuteSource source) { | |
76 OnExecuting(source); | |
77 if (command_updater_) | |
78 command_updater_->ExecuteCommand(command_id_); | |
79 } | |
OLD | NEW |