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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Drag() is invoked as the mouse is dragged. If the mouse is dragged far enough | 42 // Drag() is invoked as the mouse is dragged. If the mouse is dragged far enough |
43 // TabDragController starts a drag session. The drag session is completed when | 43 // TabDragController starts a drag session. The drag session is completed when |
44 // EndDrag() is invoked (or the TabDragController is destroyed). | 44 // EndDrag() is invoked (or the TabDragController is destroyed). |
45 // | 45 // |
46 // While dragging within a tab strip TabDragController sets the bounds of the | 46 // While dragging within a tab strip TabDragController sets the bounds of the |
47 // tabs (this is referred to as attached). When the user drags far enough such | 47 // tabs (this is referred to as attached). When the user drags far enough such |
48 // that the tabs should be moved out of the tab strip two possible things | 48 // that the tabs should be moved out of the tab strip two possible things |
49 // can happen (this state is referred to as detached): | 49 // can happen (this state is referred to as detached): |
50 // . If |detach_into_browser_| is true then a new Browser is created and | 50 // . If |detach_into_browser_| is true then a new Browser is created and |
51 // RunMoveLoop() is invoked on the Widget to drag the browser around. This is | 51 // RunMoveLoop() is invoked on the Widget to drag the browser around. This is |
52 // the default on aura. | 52 // the default on aura except in Metro mode on Win 8. |
53 // . If |detach_into_browser_| is false a small representation of the active tab | 53 // . If |detach_into_browser_| is false a small representation of the active tab |
54 // is created and that is dragged around. This mode does not run a nested | 54 // is created and that is dragged around. This mode does not run a nested |
55 // message loop. | 55 // message loop. |
56 class TabDragController : public content::WebContentsDelegate, | 56 class TabDragController : public content::WebContentsDelegate, |
57 public content::NotificationObserver, | 57 public content::NotificationObserver, |
58 public base::MessageLoopForUI::Observer, | 58 public base::MessageLoopForUI::Observer, |
59 public views::WidgetObserver, | 59 public views::WidgetObserver, |
60 public TabStripModelObserver { | 60 public TabStripModelObserver { |
61 public: | 61 public: |
62 enum DetachBehavior { | 62 enum DetachBehavior { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Returns true if there is a drag underway and the drag is attached to | 108 // Returns true if there is a drag underway and the drag is attached to |
109 // |tab_strip|. | 109 // |tab_strip|. |
110 // NOTE: this returns false if the TabDragController is in the process of | 110 // NOTE: this returns false if the TabDragController is in the process of |
111 // finishing the drag. | 111 // finishing the drag. |
112 static bool IsAttachedTo(const TabStrip* tab_strip); | 112 static bool IsAttachedTo(const TabStrip* tab_strip); |
113 | 113 |
114 // Returns true if there is a drag underway. | 114 // Returns true if there is a drag underway. |
115 static bool IsActive(); | 115 static bool IsActive(); |
116 | 116 |
117 // Used to determine whether the tab drag controller detaches dragged tabs | |
118 // into new browser windows while the drag is in process. | |
119 static bool ShouldDetachIntoNewBrowser(); | |
120 | |
121 // Sets the move behavior. Has no effect if started_drag() is true. | 117 // Sets the move behavior. Has no effect if started_drag() is true. |
122 void SetMoveBehavior(MoveBehavior behavior); | 118 void SetMoveBehavior(MoveBehavior behavior); |
123 MoveBehavior move_behavior() const { return move_behavior_; } | 119 MoveBehavior move_behavior() const { return move_behavior_; } |
124 | 120 |
125 EventSource event_source() const { return event_source_; } | 121 EventSource event_source() const { return event_source_; } |
126 | 122 |
127 // See description above fields for details on these. | 123 // See description above fields for details on these. |
128 bool active() const { return active_; } | 124 bool active() const { return active_; } |
129 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; } | 125 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; } |
130 | 126 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // See comment around use for more details. | 651 // See comment around use for more details. |
656 int attach_x_; | 652 int attach_x_; |
657 int attach_index_; | 653 int attach_index_; |
658 | 654 |
659 base::WeakPtrFactory<TabDragController> weak_factory_; | 655 base::WeakPtrFactory<TabDragController> weak_factory_; |
660 | 656 |
661 DISALLOW_COPY_AND_ASSIGN(TabDragController); | 657 DISALLOW_COPY_AND_ASSIGN(TabDragController); |
662 }; | 658 }; |
663 | 659 |
664 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 660 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
OLD | NEW |