OLD | NEW |
---|---|
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 "ash/wm/workspace/workspace_event_handler.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
6 | 6 |
7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/touch/touch_uma.h" | 9 #include "ash/touch/touch_uma.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "ash/wm/wm_event.h" | 11 #include "ash/wm/wm_event.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
14 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 WorkspaceEventHandler::WorkspaceEventHandler() | 18 WorkspaceEventHandler::WorkspaceEventHandler() |
19 : click_component_(HTNOWHERE) { | 19 : click_component_(HTNOWHERE) { |
20 } | 20 } |
21 | 21 |
22 WorkspaceEventHandler::~WorkspaceEventHandler() { | 22 WorkspaceEventHandler::~WorkspaceEventHandler() { |
23 } | 23 } |
24 | 24 |
25 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 25 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
26 aura::Window* target = static_cast<aura::Window*>(event->target()); | 26 aura::Window* target = static_cast<aura::Window*>(event->target()); |
27 | |
28 if (!target->delegate()) | |
Nina
2015/01/09 15:43:49
Without the change, this code would crash if the u
| |
29 return; | |
30 | |
27 if (event->type() == ui::ET_MOUSE_PRESSED && | 31 if (event->type() == ui::ET_MOUSE_PRESSED && |
28 event->IsOnlyLeftMouseButton() && | 32 event->IsOnlyLeftMouseButton() && |
29 ((event->flags() & | 33 ((event->flags() & |
30 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) { | 34 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) { |
31 click_component_ = target->delegate()-> | 35 click_component_ = target->delegate()-> |
32 GetNonClientComponent(event->location()); | 36 GetNonClientComponent(event->location()); |
33 } | 37 } |
34 | 38 |
35 if (event->handled()) | 39 if (event->handled()) |
36 return; | 40 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 default: | 79 default: |
76 break; | 80 break; |
77 } | 81 } |
78 } | 82 } |
79 | 83 |
80 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 84 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
81 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) | 85 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) |
82 return; | 86 return; |
83 | 87 |
84 aura::Window* target = static_cast<aura::Window*>(event->target()); | 88 aura::Window* target = static_cast<aura::Window*>(event->target()); |
89 | |
90 if (!target->delegate()) | |
91 return; | |
92 | |
85 int previous_target_component = click_component_; | 93 int previous_target_component = click_component_; |
86 click_component_ = target->delegate()-> | 94 click_component_ = target->delegate()-> |
87 GetNonClientComponent(event->location()); | 95 GetNonClientComponent(event->location()); |
88 | 96 |
89 if (click_component_ != HTCAPTION) | 97 if (click_component_ != HTCAPTION) |
90 return; | 98 return; |
91 | 99 |
92 if (event->details().tap_count() != 2) { | 100 if (event->details().tap_count() != 2) { |
93 TouchUMA::GetInstance()-> | 101 TouchUMA::GetInstance()-> |
94 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); | 102 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); |
(...skipping 29 matching lines...) Expand all Loading... | |
124 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 132 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
125 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 133 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
126 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); | 134 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); |
127 target_state->OnWMEvent(&wm_event); | 135 target_state->OnWMEvent(&wm_event); |
128 event->StopPropagation(); | 136 event->StopPropagation(); |
129 } | 137 } |
130 } | 138 } |
131 } | 139 } |
132 | 140 |
133 } // namespace ash | 141 } // namespace ash |
OLD | NEW |