| 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 "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 Loading... |
| 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" |
| 36 #include "ui/views/event_monitor.h" |
| 38 #include "ui/views/focus/view_storage.h" | 37 #include "ui/views/focus/view_storage.h" |
| 39 #include "ui/views/widget/root_view.h" | 38 #include "ui/views/widget/root_view.h" |
| 40 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 41 | 40 |
| 42 #if defined(USE_ASH) | 41 #if defined(USE_ASH) |
| 43 #include "ash/accelerators/accelerator_commands.h" | 42 #include "ash/accelerators/accelerator_commands.h" |
| 44 #include "ash/shell.h" | 43 #include "ash/shell.h" |
| 45 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 44 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 46 #include "ash/wm/window_state.h" | 45 #include "ash/wm/window_state.h" |
| 47 #include "ui/wm/core/coordinate_conversion.h" | 46 #include "ui/wm/core/coordinate_conversion.h" |
| 48 #endif | 47 #endif |
| 49 | 48 |
| 50 #if defined(USE_AURA) | 49 #if defined(USE_AURA) |
| 50 #include "ui/aura/env.h" |
| 51 #include "ui/aura/window.h" |
| 51 #include "ui/wm/core/window_modality_controller.h" | 52 #include "ui/wm/core/window_modality_controller.h" |
| 52 #endif | 53 #endif |
| 53 | 54 |
| 54 using base::UserMetricsAction; | 55 using base::UserMetricsAction; |
| 55 using content::OpenURLParams; | 56 using content::OpenURLParams; |
| 56 using content::WebContents; | 57 using content::WebContents; |
| 57 | 58 |
| 58 // If non-null there is a drag underway. | 59 // If non-null there is a drag underway. |
| 59 static TabDragController* instance_ = NULL; | 60 static TabDragController* instance_ = NULL; |
| 60 | 61 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // position managed' property during a show and we need the property set to | 135 // position managed' property during a show and we need the property set to |
| 135 // false before WorkspaceLayoutManager sees the visibility change. | 136 // false before WorkspaceLayoutManager sees the visibility change. |
| 136 class WindowPositionManagedUpdater : public views::WidgetObserver { | 137 class WindowPositionManagedUpdater : public views::WidgetObserver { |
| 137 public: | 138 public: |
| 138 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | 139 virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
| 139 bool visible) override { | 140 bool visible) override { |
| 140 SetWindowPositionManaged(widget->GetNativeWindow(), false); | 141 SetWindowPositionManaged(widget->GetNativeWindow(), false); |
| 141 } | 142 } |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 // EscapeTracker installs itself as a pre-target handler on aura::Env and runs a | 145 // EscapeTracker installs an event monitor and runs a callback when it receives |
| 145 // callback when it receives the escape key. | 146 // the escape key. |
| 146 class EscapeTracker : public ui::EventHandler { | 147 class EscapeTracker : public ui::EventHandler { |
| 147 public: | 148 public: |
| 148 explicit EscapeTracker(const base::Closure& callback) | 149 explicit EscapeTracker(const base::Closure& callback) |
| 149 : escape_callback_(callback) { | 150 : escape_callback_(callback), |
| 150 aura::Env::GetInstance()->AddPreTargetHandler(this); | 151 event_monitor_(views::EventMonitor::Create(this)) { |
| 151 } | |
| 152 | |
| 153 virtual ~EscapeTracker() { | |
| 154 aura::Env::GetInstance()->RemovePreTargetHandler(this); | |
| 155 } | 152 } |
| 156 | 153 |
| 157 private: | 154 private: |
| 158 // ui::EventHandler: | 155 // ui::EventHandler: |
| 159 virtual void OnKeyEvent(ui::KeyEvent* key) override { | 156 virtual void OnKeyEvent(ui::KeyEvent* key) override { |
| 160 if (key->type() == ui::ET_KEY_PRESSED && | 157 if (key->type() == ui::ET_KEY_PRESSED && |
| 161 key->key_code() == ui::VKEY_ESCAPE) { | 158 key->key_code() == ui::VKEY_ESCAPE) { |
| 162 escape_callback_.Run(); | 159 escape_callback_.Run(); |
| 163 } | 160 } |
| 164 } | 161 } |
| 165 | 162 |
| 166 base::Closure escape_callback_; | 163 base::Closure escape_callback_; |
| 164 scoped_ptr<views::EventMonitor> event_monitor_; |
| 167 | 165 |
| 168 DISALLOW_COPY_AND_ASSIGN(EscapeTracker); | 166 DISALLOW_COPY_AND_ASSIGN(EscapeTracker); |
| 169 }; | 167 }; |
| 170 | 168 |
| 171 } // namespace | 169 } // namespace |
| 172 | 170 |
| 173 TabDragController::TabDragData::TabDragData() | 171 TabDragController::TabDragData::TabDragData() |
| 174 : contents(NULL), | 172 : contents(NULL), |
| 175 source_model_index(-1), | 173 source_model_index(-1), |
| 176 attached_tab(NULL), | 174 attached_tab(NULL), |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 it != browser_list->end(); ++it) { | 1804 it != browser_list->end(); ++it) { |
| 1807 if ((*it)->tab_strip_model()->empty()) | 1805 if ((*it)->tab_strip_model()->empty()) |
| 1808 exclude.insert((*it)->window()->GetNativeWindow()); | 1806 exclude.insert((*it)->window()->GetNativeWindow()); |
| 1809 } | 1807 } |
| 1810 #endif | 1808 #endif |
| 1811 return GetLocalProcessWindowAtPoint(host_desktop_type_, | 1809 return GetLocalProcessWindowAtPoint(host_desktop_type_, |
| 1812 screen_point, | 1810 screen_point, |
| 1813 exclude); | 1811 exclude); |
| 1814 | 1812 |
| 1815 } | 1813 } |
| OLD | NEW |