| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/timer.h" | 11 #include "base/timer.h" |
| 12 #include "chrome/browser/dock_info.h" | 12 #include "chrome/browser/dock_info.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 13 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 14 #include "chrome/browser/tab_contents_wrapper.h" |
| 14 #include "chrome/common/notification_observer.h" | 15 #include "chrome/common/notification_observer.h" |
| 15 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
| 16 #include "gfx/rect.h" | 17 #include "gfx/rect.h" |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 class View; | 20 class View; |
| 20 } | 21 } |
| 21 class BaseTab; | 22 class BaseTab; |
| 22 class BaseTabStrip; | 23 class BaseTabStrip; |
| 23 class DraggedTabView; | 24 class DraggedTabView; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // sufficient distance before the mouse is released, a drag session is | 61 // sufficient distance before the mouse is released, a drag session is |
| 61 // initiated. | 62 // initiated. |
| 62 void Drag(); | 63 void Drag(); |
| 63 | 64 |
| 64 // Complete the current drag session. If the drag session was canceled | 65 // Complete the current drag session. If the drag session was canceled |
| 65 // because the user pressed Escape or something interrupted it, |canceled| | 66 // because the user pressed Escape or something interrupted it, |canceled| |
| 66 // is true so the helper can revert the state to the world before the drag | 67 // is true so the helper can revert the state to the world before the drag |
| 67 // begun. | 68 // begun. |
| 68 void EndDrag(bool canceled); | 69 void EndDrag(bool canceled); |
| 69 | 70 |
| 70 TabContents* dragged_contents() { return dragged_contents_; } | 71 TabContentsWrapper* dragged_contents() { return dragged_contents_; } |
| 71 | 72 |
| 72 // Returns true if a drag started. | 73 // Returns true if a drag started. |
| 73 bool started_drag() const { return started_drag_; } | 74 bool started_drag() const { return started_drag_; } |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 class DockDisplayer; | 77 class DockDisplayer; |
| 77 friend class DockDisplayer; | 78 friend class DockDisplayer; |
| 78 | 79 |
| 79 typedef std::set<gfx::NativeView> DockWindows; | 80 typedef std::set<gfx::NativeView> DockWindows; |
| 80 | 81 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Updates the window create point from |mouse_offset_|. | 135 // Updates the window create point from |mouse_offset_|. |
| 135 void UpdateWindowCreatePoint(); | 136 void UpdateWindowCreatePoint(); |
| 136 | 137 |
| 137 // Returns the point where a detached window should be created given the | 138 // Returns the point where a detached window should be created given the |
| 138 // current mouse position. | 139 // current mouse position. |
| 139 gfx::Point GetWindowCreatePoint() const; | 140 gfx::Point GetWindowCreatePoint() const; |
| 140 | 141 |
| 141 void UpdateDockInfo(const gfx::Point& screen_point); | 142 void UpdateDockInfo(const gfx::Point& screen_point); |
| 142 | 143 |
| 143 // Sets the TabContents being dragged with the specified |new_contents|. | 144 // Sets the TabContents being dragged with the specified |new_contents|. |
| 144 void SetDraggedContents(TabContents* new_contents); | 145 void SetDraggedContents(TabContentsWrapper* new_contents); |
| 145 | 146 |
| 146 // Saves focus in the window that the drag initiated from. Focus will be | 147 // Saves focus in the window that the drag initiated from. Focus will be |
| 147 // restored appropriately if the drag ends within this same window. | 148 // restored appropriately if the drag ends within this same window. |
| 148 void SaveFocus(); | 149 void SaveFocus(); |
| 149 | 150 |
| 150 // Restore focus to the View that had focus before the drag was started, if | 151 // Restore focus to the View that had focus before the drag was started, if |
| 151 // the drag ends within the same Window as it began. | 152 // the drag ends within the same Window as it began. |
| 152 void RestoreFocus(); | 153 void RestoreFocus(); |
| 153 | 154 |
| 154 // Tests whether the position of the mouse is past a minimum elasticity | 155 // Tests whether the position of the mouse is past a minimum elasticity |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void DockDisplayerDestroyed(DockDisplayer* controller); | 235 void DockDisplayerDestroyed(DockDisplayer* controller); |
| 235 | 236 |
| 236 void BringWindowUnderMouseToFront(); | 237 void BringWindowUnderMouseToFront(); |
| 237 | 238 |
| 238 // Returns the TabStripModel for the specified tabstrip. | 239 // Returns the TabStripModel for the specified tabstrip. |
| 239 TabStripModel* GetModel(BaseTabStrip* tabstrip) const; | 240 TabStripModel* GetModel(BaseTabStrip* tabstrip) const; |
| 240 | 241 |
| 241 // Handles registering for notifications. | 242 // Handles registering for notifications. |
| 242 NotificationRegistrar registrar_; | 243 NotificationRegistrar registrar_; |
| 243 | 244 |
| 244 // The TabContents being dragged. | 245 // The TabContentsWrapper being dragged. |
| 245 TabContents* dragged_contents_; | 246 TabContentsWrapper* dragged_contents_; |
| 246 | 247 |
| 247 // The original TabContentsDelegate of |dragged_contents_|, before it was | 248 // The original TabContentsDelegate of |dragged_contents_|, before it was |
| 248 // detached from the browser window. We store this so that we can forward | 249 // detached from the browser window. We store this so that we can forward |
| 249 // certain delegate notifications back to it if we can't handle them locally. | 250 // certain delegate notifications back to it if we can't handle them locally. |
| 250 TabContentsDelegate* original_delegate_; | 251 TabContentsDelegate* original_delegate_; |
| 251 | 252 |
| 252 // The TabStrip |source_tab_| originated from. | 253 // The TabStrip |source_tab_| originated from. |
| 253 BaseTabStrip* source_tabstrip_; | 254 BaseTabStrip* source_tabstrip_; |
| 254 | 255 |
| 255 // This is the index of the |source_tab_| in |source_tabstrip_| when the drag | 256 // This is the index of the |source_tab_| in |source_tabstrip_| when the drag |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // Did the mouse move enough that we started a drag? | 331 // Did the mouse move enough that we started a drag? |
| 331 bool started_drag_; | 332 bool started_drag_; |
| 332 | 333 |
| 333 // Is the drag active? | 334 // Is the drag active? |
| 334 bool active_; | 335 bool active_; |
| 335 | 336 |
| 336 DISALLOW_COPY_AND_ASSIGN(DraggedTabController); | 337 DISALLOW_COPY_AND_ASSIGN(DraggedTabController); |
| 337 }; | 338 }; |
| 338 | 339 |
| 339 #endif // CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ | 340 #endif // CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_CONTROLLER_H_ |
| OLD | NEW |