Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / tabs / tab_drag_controller.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
7
8 #include <vector>
9
10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/timer/timer.h"
13 #include "chrome/browser/ui/host_desktop.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
15 #include "chrome/browser/ui/views/tabs/tab_strip_types.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/web_contents_delegate.h"
19 #include "ui/base/models/list_selection_model.h"
20 #include "ui/gfx/rect.h"
21 #include "ui/views/widget/widget_observer.h"
22
23 namespace gfx {
24 class Screen;
25 }
26 namespace ui {
27 class EventHandler;
28 class ListSelectionModel;
29 }
30 namespace views {
31 class View;
32 }
33 class Browser;
34 class Tab;
35 struct TabRendererData;
36 class TabStrip;
37 class TabStripModel;
38
39 // TabDragController is responsible for managing the tab dragging session. When
40 // the user presses the mouse on a tab a new TabDragController is created and
41 // Drag() is invoked as the mouse is dragged. If the mouse is dragged far enough
42 // TabDragController starts a drag session. The drag session is completed when
43 // EndDrag() is invoked (or the TabDragController is destroyed).
44 //
45 // While dragging within a tab strip TabDragController sets the bounds of the
46 // tabs (this is referred to as attached). When the user drags far enough such
47 // that the tabs should be moved out of the tab strip a new Browser is created
48 // and RunMoveLoop() is invoked on the Widget to drag the browser around. This
49 // is the default on aura.
50 class TabDragController : public content::WebContentsDelegate,
51                           public content::NotificationObserver,
52                           public views::WidgetObserver,
53                           public TabStripModelObserver {
54  public:
55   enum DetachBehavior {
56     DETACHABLE,
57     NOT_DETACHABLE
58   };
59
60   // What should happen as the mouse is dragged within the tabstrip.
61   enum MoveBehavior {
62     // Only the set of visible tabs should change. This is only applicable when
63     // using touch layout.
64     MOVE_VISIBILE_TABS,
65
66     // Typical behavior where tabs are dragged around.
67     REORDER
68   };
69
70   // Indicates the event source that initiated the drag.
71   enum EventSource {
72     EVENT_SOURCE_MOUSE,
73     EVENT_SOURCE_TOUCH,
74   };
75
76   // Amount above or below the tabstrip the user has to drag before detaching.
77   static const int kTouchVerticalDetachMagnetism;
78   static const int kVerticalDetachMagnetism;
79
80   TabDragController();
81   virtual ~TabDragController();
82
83   // Initializes TabDragController to drag the tabs in |tabs| originating from
84   // |source_tabstrip|. |source_tab| is the tab that initiated the drag and is
85   // contained in |tabs|.  |mouse_offset| is the distance of the mouse pointer
86   // from the origin of the first tab in |tabs| and |source_tab_offset| the
87   // offset from |source_tab|. |source_tab_offset| is the horizontal offset of
88   // |mouse_offset| relative to |source_tab|. |initial_selection_model| is the
89   // selection model before the drag started and is only non-empty if
90   // |source_tab| was not initially selected.
91   void Init(TabStrip* source_tabstrip,
92             Tab* source_tab,
93             const std::vector<Tab*>& tabs,
94             const gfx::Point& mouse_offset,
95             int source_tab_offset,
96             const ui::ListSelectionModel& initial_selection_model,
97             DetachBehavior detach_behavior,
98             MoveBehavior move_behavior,
99             EventSource event_source);
100
101   // Returns true if there is a drag underway and the drag is attached to
102   // |tab_strip|.
103   // NOTE: this returns false if the TabDragController is in the process of
104   // finishing the drag.
105   static bool IsAttachedTo(const TabStrip* tab_strip);
106
107   // Returns true if there is a drag underway.
108   static bool IsActive();
109
110   // Sets the move behavior. Has no effect if started_drag() is true.
111   void SetMoveBehavior(MoveBehavior behavior);
112   MoveBehavior move_behavior() const { return move_behavior_; }
113
114   EventSource event_source() const { return event_source_; }
115
116   // See description above fields for details on these.
117   bool active() const { return active_; }
118   const TabStrip* attached_tabstrip() const { return attached_tabstrip_; }
119
120   // Returns true if a drag started.
121   bool started_drag() const { return started_drag_; }
122
123   // Returns true if mutating the TabStripModel.
124   bool is_mutating() const { return is_mutating_; }
125
126   // Returns true if we've detached from a tabstrip and are running a nested
127   // move message loop.
128   bool is_dragging_window() const { return is_dragging_window_; }
129
130   // Invoked to drag to the new location, in screen coordinates.
131   void Drag(const gfx::Point& point_in_screen);
132
133   // Complete the current drag session.
134   void EndDrag(EndDragReason reason);
135
136  private:
137   // Used to indicate the direction the mouse has moved when attached.
138   static const int kMovedMouseLeft  = 1 << 0;
139   static const int kMovedMouseRight = 1 << 1;
140
141   // Enumeration of the ways a drag session can end.
142   enum EndDragType {
143     // Drag session exited normally: the user released the mouse.
144     NORMAL,
145
146     // The drag session was canceled (alt-tab during drag, escape ...)
147     CANCELED,
148
149     // The tab (NavigationController) was destroyed during the drag.
150     TAB_DESTROYED
151   };
152
153   // Whether Detach() should release capture or not.
154   enum ReleaseCapture {
155     RELEASE_CAPTURE,
156     DONT_RELEASE_CAPTURE,
157   };
158
159   // Specifies what should happen when RunMoveLoop completes.
160   enum EndRunLoopBehavior {
161     // Indicates the drag should end.
162     END_RUN_LOOP_STOP_DRAGGING,
163
164     // Indicates the drag should continue.
165     END_RUN_LOOP_CONTINUE_DRAGGING
166   };
167
168   // Enumeration of the possible positions the detached tab may detach from.
169   enum DetachPosition {
170     DETACH_BEFORE,
171     DETACH_AFTER,
172     DETACH_ABOVE_OR_BELOW
173   };
174
175   // Indicates what should happen after invoking DragBrowserToNewTabStrip().
176   enum DragBrowserResultType {
177     // The caller should return immediately. This return value is used if a
178     // nested message loop was created or we're in a nested message loop and
179     // need to exit it.
180     DRAG_BROWSER_RESULT_STOP,
181
182     // The caller should continue.
183     DRAG_BROWSER_RESULT_CONTINUE,
184   };
185
186   // Stores the date associated with a single tab that is being dragged.
187   struct TabDragData {
188     TabDragData();
189     ~TabDragData();
190
191     // The WebContents being dragged.
192     content::WebContents* contents;
193
194     // content::WebContentsDelegate for |contents| before it was detached from
195     // the browser window. We store this so that we can forward certain delegate
196     // notifications back to it if we can't handle them locally.
197     content::WebContentsDelegate* original_delegate;
198
199     // This is the index of the tab in |source_tabstrip_| when the drag
200     // began. This is used to restore the previous state if the drag is aborted.
201     int source_model_index;
202
203     // If attached this is the tab in |attached_tabstrip_|.
204     Tab* attached_tab;
205
206     // Is the tab pinned?
207     bool pinned;
208   };
209
210   typedef std::vector<TabDragData> DragData;
211
212   // Sets |drag_data| from |tab|. This also registers for necessary
213   // notifications and resets the delegate of the WebContents.
214   void InitTabDragData(Tab* tab, TabDragData* drag_data);
215
216   // Overridden from content::WebContentsDelegate:
217   virtual content::WebContents* OpenURLFromTab(
218       content::WebContents* source,
219       const content::OpenURLParams& params) OVERRIDE;
220   virtual void NavigationStateChanged(const content::WebContents* source,
221                                       unsigned changed_flags) OVERRIDE;
222   virtual void AddNewContents(content::WebContents* source,
223                               content::WebContents* new_contents,
224                               WindowOpenDisposition disposition,
225                               const gfx::Rect& initial_pos,
226                               bool user_gesture,
227                               bool* was_blocked) OVERRIDE;
228   virtual bool ShouldSuppressDialogs() OVERRIDE;
229   virtual content::JavaScriptDialogManager*
230       GetJavaScriptDialogManager() OVERRIDE;
231   virtual void RequestMediaAccessPermission(
232       content::WebContents* web_contents,
233       const content::MediaStreamRequest& request,
234       const content::MediaResponseCallback& callback) OVERRIDE;
235
236   // Overridden from content::NotificationObserver:
237   virtual void Observe(int type,
238                        const content::NotificationSource& source,
239                        const content::NotificationDetails& details) OVERRIDE;
240
241   // Overriden from views::WidgetObserver:
242   virtual void OnWidgetBoundsChanged(views::Widget* widget,
243                                      const gfx::Rect& new_bounds) OVERRIDE;
244
245   // Overriden from TabStripModelObserver:
246   virtual void TabStripEmpty() OVERRIDE;
247
248   // Initialize the offset used to calculate the position to create windows
249   // in |GetWindowCreatePoint|. This should only be invoked from |Init|.
250   void InitWindowCreatePoint();
251
252   // Returns the point where a detached window should be created given the
253   // current mouse position |origin|.
254   gfx::Point GetWindowCreatePoint(const gfx::Point& origin) const;
255
256   void UpdateDockInfo(const gfx::Point& point_in_screen);
257
258   // Saves focus in the window that the drag initiated from. Focus will be
259   // restored appropriately if the drag ends within this same window.
260   void SaveFocus();
261
262   // Restore focus to the View that had focus before the drag was started, if
263   // the drag ends within the same Window as it began.
264   void RestoreFocus();
265
266   // Tests whether |point_in_screen| is past a minimum elasticity threshold
267   // required to start a drag.
268   bool CanStartDrag(const gfx::Point& point_in_screen) const;
269
270   // Invoked once a drag has started to determine the appropriate tabstrip to
271   // drag to (which may be the currently attached one).
272   void ContinueDragging(const gfx::Point& point_in_screen);
273
274   // Transitions dragging from |attached_tabstrip_| to |target_tabstrip|.
275   // |target_tabstrip| is NULL if the mouse is not over a valid tab strip.  See
276   // DragBrowserResultType for details of the return type.
277   DragBrowserResultType DragBrowserToNewTabStrip(
278       TabStrip* target_tabstrip,
279       const gfx::Point& point_in_screen);
280
281   // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't
282   // actually reorder the tabs in anyway, just changes what's visible.
283   void DragActiveTabStacked(const gfx::Point& point_in_screen);
284
285   // Moves the active tab to the next/previous tab. Used when the next/previous
286   // tab is stacked.
287   void MoveAttachedToNextStackedIndex(const gfx::Point& point_in_screen);
288   void MoveAttachedToPreviousStackedIndex(const gfx::Point& point_in_screen);
289
290   // Handles dragging tabs while the tabs are attached.
291   void MoveAttached(const gfx::Point& point_in_screen);
292
293   // If necessary starts the |move_stacked_timer_|. The timer is started if
294   // close enough to an edge with stacked tabs.
295   void StartMoveStackedTimerIfNecessary(
296       const gfx::Point& point_in_screen,
297       int delay_ms);
298
299   // Returns the TabStrip for the specified window, or NULL if one doesn't exist
300   // or isn't compatible.
301   TabStrip* GetTabStripForWindow(gfx::NativeWindow window);
302
303   // Returns the compatible TabStrip to drag to at the specified point (screen
304   // coordinates), or NULL if there is none.
305   TabStrip* GetTargetTabStripForPoint(const gfx::Point& point_in_screen);
306
307   // Returns true if |tabstrip| contains the specified point in screen
308   // coordinates.
309   bool DoesTabStripContain(TabStrip* tabstrip,
310                            const gfx::Point& point_in_screen) const;
311
312   // Returns the DetachPosition given the specified location in screen
313   // coordinates.
314   DetachPosition GetDetachPosition(const gfx::Point& point_in_screen);
315
316   // Attach the dragged Tab to the specified TabStrip.
317   void Attach(TabStrip* attached_tabstrip, const gfx::Point& point_in_screen);
318
319   // Detach the dragged Tab from the current TabStrip.
320   void Detach(ReleaseCapture release_capture);
321
322   // Detaches the tabs being dragged, creates a new Browser to contain them and
323   // runs a nested move loop.
324   void DetachIntoNewBrowserAndRunMoveLoop(const gfx::Point& point_in_screen);
325
326   // Runs a nested message loop that handles moving the current
327   // Browser. |drag_offset| is the offset from the window origin and is used in
328   // calculating the location of the window offset from the cursor while
329   // dragging.
330   void RunMoveLoop(const gfx::Vector2d& drag_offset);
331
332   // Determines the index to insert tabs at. |dragged_bounds| is the bounds of
333   // the tabs being dragged, |start| the index of the tab to start looking from
334   // and |delta| the amount to increment (1 or -1).
335   int GetInsertionIndexFrom(const gfx::Rect& dragged_bounds,
336                             int start,
337                             int delta) const;
338
339   // Returns the index where the dragged WebContents should be inserted into
340   // |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in
341   // coordinates relative to |attached_tabstrip_| and has had the mirroring
342   // transformation applied.
343   // NOTE: this is invoked from Attach() before the tabs have been inserted.
344   int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const;
345
346   // Returns true if |dragged_bounds| is close enough to the next stacked tab
347   // so that the active tab should be dragged there.
348   bool ShouldDragToNextStackedTab(const gfx::Rect& dragged_bounds,
349                                   int index) const;
350
351   // Returns true if |dragged_bounds| is close enough to the previous stacked
352   // tab so that the active tab should be dragged there.
353   bool ShouldDragToPreviousStackedTab(const gfx::Rect& dragged_bounds,
354                                       int index) const;
355
356   // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked.
357   int GetInsertionIndexForDraggedBoundsStacked(
358       const gfx::Rect& dragged_bounds) const;
359
360   // Retrieve the bounds of the DraggedTabView relative to the attached
361   // TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate
362   // system.
363   gfx::Rect GetDraggedViewTabStripBounds(const gfx::Point& tab_strip_point);
364
365   // Get the position of the dragged tab view relative to the attached tab
366   // strip with the mirroring transform applied.
367   gfx::Point GetAttachedDragPoint(const gfx::Point& point_in_screen);
368
369   // Finds the Tabs within the specified TabStrip that corresponds to the
370   // WebContents of the dragged tabs. Returns an empty vector if not attached.
371   std::vector<Tab*> GetTabsMatchingDraggedContents(TabStrip* tabstrip);
372
373   // Returns the bounds for the tabs based on the attached tab strip.
374   std::vector<gfx::Rect> CalculateBoundsForDraggedTabs();
375
376   // Does the work for EndDrag(). If we actually started a drag and |how_end| is
377   // not TAB_DESTROYED then one of EndDrag() or RevertDrag() is invoked.
378   void EndDragImpl(EndDragType how_end);
379
380   // Reverts a cancelled drag operation.
381   void RevertDrag();
382
383   // Reverts the tab at |drag_index| in |drag_data_|.
384   void RevertDragAt(size_t drag_index);
385
386   // Selects the dragged tabs in |model|. Does nothing if there are no longer
387   // any dragged contents (as happens when a WebContents is deleted out from
388   // under us).
389   void ResetSelection(TabStripModel* model);
390
391   // Restores |initial_selection_model_| to the |source_tabstrip_|.
392   void RestoreInitialSelection();
393
394   // Finishes a succesful drag operation.
395   void CompleteDrag();
396
397   // Maximizes the attached window.
398   void MaximizeAttachedWindow();
399
400   // Resets the delegates of the WebContents.
401   void ResetDelegates();
402
403   // Returns the bounds (in screen coordinates) of the specified View.
404   gfx::Rect GetViewScreenBounds(views::View* tabstrip) const;
405
406   // Hides the frame for the window that contains the TabStrip the current
407   // drag session was initiated from.
408   void HideFrame();
409
410   // Closes a hidden frame at the end of a drag session.
411   void CleanUpHiddenFrame();
412
413   void BringWindowUnderPointToFront(const gfx::Point& point_in_screen);
414
415   // Convenience for getting the TabDragData corresponding to the tab the user
416   // started dragging.
417   TabDragData* source_tab_drag_data() {
418     return &(drag_data_[source_tab_index_]);
419   }
420
421   // Convenience for |source_tab_drag_data()->contents|.
422   content::WebContents* source_dragged_contents() {
423     return source_tab_drag_data()->contents;
424   }
425
426   // Returns the Widget of the currently attached TabStrip's BrowserView.
427   views::Widget* GetAttachedBrowserWidget();
428
429   // Returns true if the tabs were originality one after the other in
430   // |source_tabstrip_|.
431   bool AreTabsConsecutive();
432
433   // Calculates and returns new bounds for the dragged browser window.
434   // Takes into consideration current and restore bounds of |source| tab strip
435   // preventing the dragged size from being too small. Positions the new bounds
436   // such that the tab that was dragged remains under the |point_in_screen|.
437   // Offsets |drag_bounds| if necessary when dragging to the right from the
438   // source browser.
439   gfx::Rect CalculateDraggedBrowserBounds(TabStrip* source,
440                                           const gfx::Point& point_in_screen,
441                                           std::vector<gfx::Rect>* drag_bounds);
442
443   // Calculates scaled |drag_bounds| for dragged tabs and sets the tabs bounds.
444   // Layout of the tabstrip is performed and a new tabstrip width calculated.
445   // When |last_tabstrip_width| is larger than the new tabstrip width the tabs
446   // in attached tabstrip are scaled and the attached browser is positioned such
447   // that the tab that was dragged remains under the |point_in_screen|.
448   void AdjustBrowserAndTabBoundsForDrag(int last_tabstrip_width,
449                                         const gfx::Point& point_in_screen,
450                                         std::vector<gfx::Rect>* drag_bounds);
451
452   // Creates and returns a new Browser to handle the drag.
453   Browser* CreateBrowserForDrag(TabStrip* source,
454                                 const gfx::Point& point_in_screen,
455                                 gfx::Vector2d* drag_offset,
456                                 std::vector<gfx::Rect>* drag_bounds);
457
458   // Returns the TabStripModel for the specified tabstrip.
459   TabStripModel* GetModel(TabStrip* tabstrip) const;
460
461   // Returns the location of the cursor. This is either the location of the
462   // mouse or the location of the current touch point.
463   gfx::Point GetCursorScreenPoint();
464
465   // Returns the offset from the top left corner of the window to
466   // |point_in_screen|.
467   gfx::Vector2d GetWindowOffset(const gfx::Point& point_in_screen);
468
469   // Returns true if moving the mouse only changes the visible tabs.
470   bool move_only() const {
471     return (move_behavior_ == MOVE_VISIBILE_TABS) != 0;
472   }
473
474   // Returns the NativeWindow at the specified point. If |exclude_dragged_view|
475   // is true, then the dragged view is not considered.
476   gfx::NativeWindow GetLocalProcessWindow(const gfx::Point& screen_point,
477                                           bool exclude_dragged_view);
478
479   // If true detaching creates a new browser and enters a nested message loop.
480   bool detach_into_browser_;
481
482   // Handles registering for notifications.
483   content::NotificationRegistrar registrar_;
484
485   EventSource event_source_;
486
487   // The TabStrip the drag originated from.
488   TabStrip* source_tabstrip_;
489
490   // The TabStrip the dragged Tab is currently attached to, or NULL if the
491   // dragged Tab is detached.
492   TabStrip* attached_tabstrip_;
493
494   // The screen that this drag is associated with. Cached, because other UI
495   // elements are NULLd at various points during the lifetime of this object.
496   gfx::Screen* screen_;
497
498   // The desktop type that this drag is associated with. Cached, because other
499   // UI elements are NULLd at various points during the lifetime of this
500   // object.
501   chrome::HostDesktopType host_desktop_type_;
502
503   // Aura mouse capture and release is used on Ash platforms as well as on
504   // Linux to ensure that pointer grab is not released prematurely.
505   bool use_aura_capture_policy_;
506
507   // The position of the mouse (in screen coordinates) at the start of the drag
508   // operation. This is used to calculate minimum elasticity before a
509   // DraggedTabView is constructed.
510   gfx::Point start_point_in_screen_;
511
512   // This is the offset of the mouse from the top left of the first Tab where
513   // dragging began. This is used to ensure that the dragged view is always
514   // positioned at the correct location during the drag, and to ensure that the
515   // detached window is created at the right location.
516   gfx::Point mouse_offset_;
517
518   // Ratio of the x-coordinate of the |source_tab_offset| to the width of the
519   // tab.
520   float offset_to_width_ratio_;
521
522   // A hint to use when positioning new windows created by detaching Tabs. This
523   // is the distance of the mouse from the top left of the dragged tab as if it
524   // were the distance of the mouse from the top left of the first tab in the
525   // attached TabStrip from the top left of the window.
526   gfx::Point window_create_point_;
527
528   // Location of the first tab in the source tabstrip in screen coordinates.
529   // This is used to calculate |window_create_point_|.
530   gfx::Point first_source_tab_point_;
531
532   // The bounds of the browser window before the last Tab was detached. When
533   // the last Tab is detached, rather than destroying the frame (which would
534   // abort the drag session), the frame is moved off-screen. If the drag is
535   // aborted (e.g. by the user pressing Esc, or capture being lost), the Tab is
536   // attached to the hidden frame and the frame moved back to these bounds.
537   gfx::Rect restore_bounds_;
538
539   // Storage ID in ViewStorage where the last view that had focus in the window
540   // containing |source_tab_| is saved. This is saved so that focus can be
541   // restored properly when a drag begins and ends within this same window.
542   const int old_focused_view_id_;
543
544   // The horizontal position of the mouse cursor in screen coordinates at the
545   // time of the last re-order event.
546   int last_move_screen_loc_;
547
548   // Timer used to bring the window under the cursor to front. If the user
549   // stops moving the mouse for a brief time over a browser window, it is
550   // brought to front.
551   base::OneShotTimer<TabDragController> bring_to_front_timer_;
552
553   // Timer used to move the stacked tabs. See comment aboue
554   // StartMoveStackedTimerIfNecessary().
555   base::OneShotTimer<TabDragController> move_stacked_timer_;
556
557   // Did the mouse move enough that we started a drag?
558   bool started_drag_;
559
560   // Is the drag active?
561   bool active_;
562
563   DragData drag_data_;
564
565   // Index of the source tab in |drag_data_|.
566   size_t source_tab_index_;
567
568   // True until MoveAttached() is first invoked.
569   bool initial_move_;
570
571   // The selection model before the drag started. See comment above Init() for
572   // details.
573   ui::ListSelectionModel initial_selection_model_;
574
575   // The selection model of |attached_tabstrip_| before the tabs were attached.
576   ui::ListSelectionModel selection_model_before_attach_;
577
578   // Initial x-coordinates of the tabs when the drag started. Only used for
579   // touch mode.
580   std::vector<int> initial_tab_positions_;
581
582   DetachBehavior detach_behavior_;
583   MoveBehavior move_behavior_;
584
585   // Updated as the mouse is moved when attached. Indicates whether the mouse
586   // has ever moved to the left or right. If the tabs are ever detached this
587   // is set to kMovedMouseRight | kMovedMouseLeft.
588   int mouse_move_direction_;
589
590   // Last location used in screen coordinates.
591   gfx::Point last_point_in_screen_;
592
593   // The following are needed when detaching into a browser
594   // (|detach_into_browser_| is true).
595
596   // See description above getter.
597   bool is_dragging_window_;
598
599   // True if |attached_tabstrip_| is in a browser specifically created for
600   // the drag.
601   bool is_dragging_new_browser_;
602
603   // True if |source_tabstrip_| was maximized before the drag.
604   bool was_source_maximized_;
605
606   // True if |source_tabstrip_| was in immersive fullscreen before the drag.
607   bool was_source_fullscreen_;
608
609   // True if the initial drag resulted in restoring the window (because it was
610   // maximized).
611   bool did_restore_window_;
612
613   EndRunLoopBehavior end_run_loop_behavior_;
614
615   // If true, we're waiting for a move loop to complete.
616   bool waiting_for_run_loop_to_exit_;
617
618   // The TabStrip to attach to after the move loop completes.
619   TabStrip* tab_strip_to_attach_to_after_exit_;
620
621   // Non-null for the duration of RunMoveLoop.
622   views::Widget* move_loop_widget_;
623
624   // See description above getter.
625   bool is_mutating_;
626
627   // |attach_x_| and |attach_index_| are set to the x-coordinate of the mouse
628   // (in terms of the tabstrip) and the insertion index at the time tabs are
629   // dragged into a new browser (attached). They are used to ensure we don't
630   // shift the tabs around in the wrong direction. The two are only valid if
631   // |attach_index_| is not -1.
632   // See comment around use for more details.
633   int attach_x_;
634   int attach_index_;
635
636   scoped_ptr<ui::EventHandler> escape_tracker_;
637
638   base::WeakPtrFactory<TabDragController> weak_factory_;
639
640   DISALLOW_COPY_AND_ASSIGN(TabDragController);
641 };
642
643 #endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_