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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 678823002: MacViews: Create abstraction for event monitoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@views-tabs
Patch Set: Add test Created 6 years, 1 month 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
« no previous file with comments | « no previous file | ui/views/event_monitor.h » ('j') | ui/views/event_monitor.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/views/tabs/tab.h" 22 #include "chrome/browser/ui/views/tabs/tab.h"
23 #include "chrome/browser/ui/views/tabs/tab_strip.h" 23 #include "chrome/browser/ui/views/tabs/tab_strip.h"
24 #include "chrome/browser/ui/views/tabs/window_finder.h" 24 #include "chrome/browser/ui/views/tabs/window_finder.h"
25 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/user_metrics.h" 29 #include "content/public/browser/user_metrics.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "extensions/browser/extension_function_dispatcher.h" 31 #include "extensions/browser/extension_function_dispatcher.h"
32 #include "ui/aura/env.h"
33 #include "ui/aura/window.h"
34 #include "ui/events/event_constants.h" 32 #include "ui/events/event_constants.h"
35 #include "ui/events/gestures/gesture_recognizer.h" 33 #include "ui/events/gestures/gesture_recognizer.h"
36 #include "ui/gfx/geometry/point_conversions.h" 34 #include "ui/gfx/geometry/point_conversions.h"
37 #include "ui/gfx/screen.h" 35 #include "ui/gfx/screen.h"
38 #include "ui/views/focus/view_storage.h" 36 #include "ui/views/focus/view_storage.h"
39 #include "ui/views/widget/root_view.h" 37 #include "ui/views/widget/root_view.h"
40 #include "ui/views/widget/widget.h" 38 #include "ui/views/widget/widget.h"
41 39
42 #if defined(USE_ASH) 40 #if defined(USE_ASH)
43 #include "ash/accelerators/accelerator_commands.h" 41 #include "ash/accelerators/accelerator_commands.h"
44 #include "ash/shell.h" 42 #include "ash/shell.h"
45 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 43 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
46 #include "ash/wm/window_state.h" 44 #include "ash/wm/window_state.h"
47 #include "ui/wm/core/coordinate_conversion.h" 45 #include "ui/wm/core/coordinate_conversion.h"
48 #endif 46 #endif
49 47
50 #if defined(USE_AURA) 48 #if defined(USE_AURA)
49 #include "ui/aura/window.h"
51 #include "ui/wm/core/window_modality_controller.h" 50 #include "ui/wm/core/window_modality_controller.h"
52 #endif 51 #endif
53 52
54 using base::UserMetricsAction; 53 using base::UserMetricsAction;
55 using content::OpenURLParams; 54 using content::OpenURLParams;
56 using content::WebContents; 55 using content::WebContents;
57 56
58 // If non-null there is a drag underway. 57 // If non-null there is a drag underway.
59 static TabDragController* instance_ = NULL; 58 static TabDragController* instance_ = NULL;
60 59
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // position managed' property during a show and we need the property set to 133 // position managed' property during a show and we need the property set to
135 // false before WorkspaceLayoutManager sees the visibility change. 134 // false before WorkspaceLayoutManager sees the visibility change.
136 class WindowPositionManagedUpdater : public views::WidgetObserver { 135 class WindowPositionManagedUpdater : public views::WidgetObserver {
137 public: 136 public:
138 virtual void OnWidgetVisibilityChanged(views::Widget* widget, 137 virtual void OnWidgetVisibilityChanged(views::Widget* widget,
139 bool visible) override { 138 bool visible) override {
140 SetWindowPositionManaged(widget->GetNativeWindow(), false); 139 SetWindowPositionManaged(widget->GetNativeWindow(), false);
141 } 140 }
142 }; 141 };
143 142
144 // EscapeTracker installs itself as a pre-target handler on aura::Env and runs a 143 // EscapeTracker installs an event monitor and runs a callback when it receives
145 // callback when it receives the escape key. 144 // the escape key.
146 class EscapeTracker : public ui::EventHandler { 145 class EscapeTracker : public ui::EventHandler {
147 public: 146 public:
148 explicit EscapeTracker(const base::Closure& callback) 147 explicit EscapeTracker(const base::Closure& callback)
149 : escape_callback_(callback) { 148 : escape_callback_(callback),
150 aura::Env::GetInstance()->AddPreTargetHandler(this); 149 event_monitor_(views::EventMonitor::Create(this)) {
151 }
152
153 virtual ~EscapeTracker() {
154 aura::Env::GetInstance()->RemovePreTargetHandler(this);
155 } 150 }
156 151
157 private: 152 private:
158 // ui::EventHandler: 153 // ui::EventHandler:
159 virtual void OnKeyEvent(ui::KeyEvent* key) override { 154 virtual void OnKeyEvent(ui::KeyEvent* key) override {
160 if (key->type() == ui::ET_KEY_PRESSED && 155 if (key->type() == ui::ET_KEY_PRESSED &&
161 key->key_code() == ui::VKEY_ESCAPE) { 156 key->key_code() == ui::VKEY_ESCAPE) {
162 escape_callback_.Run(); 157 escape_callback_.Run();
163 } 158 }
164 } 159 }
165 160
166 base::Closure escape_callback_; 161 base::Closure escape_callback_;
162 scoped_ptr<views::EventMonitor> event_monitor_;
167 163
168 DISALLOW_COPY_AND_ASSIGN(EscapeTracker); 164 DISALLOW_COPY_AND_ASSIGN(EscapeTracker);
169 }; 165 };
170 166
171 } // namespace 167 } // namespace
172 168
173 TabDragController::TabDragData::TabDragData() 169 TabDragController::TabDragData::TabDragData()
174 : contents(NULL), 170 : contents(NULL),
175 source_model_index(-1), 171 source_model_index(-1),
176 attached_tab(NULL), 172 attached_tab(NULL),
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 it != browser_list->end(); ++it) { 1802 it != browser_list->end(); ++it) {
1807 if ((*it)->tab_strip_model()->empty()) 1803 if ((*it)->tab_strip_model()->empty())
1808 exclude.insert((*it)->window()->GetNativeWindow()); 1804 exclude.insert((*it)->window()->GetNativeWindow());
1809 } 1805 }
1810 #endif 1806 #endif
1811 return GetLocalProcessWindowAtPoint(host_desktop_type_, 1807 return GetLocalProcessWindowAtPoint(host_desktop_type_,
1812 screen_point, 1808 screen_point,
1813 exclude); 1809 exclude);
1814 1810
1815 } 1811 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/event_monitor.h » ('j') | ui/views/event_monitor.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698