tab_drag_controller.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/message_loop.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/timer.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/tabs/dock_info.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/tabs/tab_strip_types.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents_delegate.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/models/list_selection_model.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/widget/widget_observer.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace gfx {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Screen;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ui {
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ListSelectionModel;
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace views {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class View;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DraggedTabView;
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Tab;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct TabRendererData;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStrip;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStripModel;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TabDragController is responsible for managing the tab dragging session. When
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the user presses the mouse on a tab a new TabDragController is created and
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Drag() is invoked as the mouse is dragged. If the mouse is dragged far enough
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TabDragController starts a drag session. The drag session is completed when
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// EndDrag() is invoked (or the TabDragController is destroyed).
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// While dragging within a tab strip TabDragController sets the bounds of the
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// tabs (this is referred to as attached). When the user drags far enough such
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that the tabs should be moved out of the tab strip two possible things
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// can happen (this state is referred to as detached):
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// . If |detach_into_browser_| is true then a new Browser is created and
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   RunMoveLoop() is invoked on the Widget to drag the browser around. This is
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   the default on chromeos and can be enabled on windows with a flag.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// . If |detach_into_browser_| is false a small representation of the active tab
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   is created and that is dragged around. This mode does not run a nested
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   message loop.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabDragController : public content::WebContentsDelegate,
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public content::NotificationObserver,
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public MessageLoopForUI::Observer,
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public views::WidgetObserver,
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          public TabStripModelObserver {
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum DetachBehavior {
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DETACHABLE,
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    NOT_DETACHABLE
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // What should happen as the mouse is dragged within the tabstrip.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum MoveBehavior {
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Only the set of visible tabs should change. This is only applicable when
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // using touch layout.
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    MOVE_VISIBILE_TABS,
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Typical behavior where tabs are dragged around.
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    REORDER
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Indicates the event source that initiated the drag.
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum EventSource {
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EVENT_SOURCE_MOUSE,
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EVENT_SOURCE_TOUCH,
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Amount above or below the tabstrip the user has to drag before detaching.
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int kTouchVerticalDetachMagnetism;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int kVerticalDetachMagnetism;
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabDragController();
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~TabDragController();
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initializes TabDragController to drag the tabs in |tabs| originating
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // from |source_tabstrip|. |source_tab| is the tab that initiated the drag and
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is contained in |tabs|.  |mouse_offset| is the distance of the mouse
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // pointer from the origin of the first tab in |tabs| and |source_tab_offset|
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the offset from |source_tab|. |source_tab_offset| is the horizontal distant
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for a horizontal tab strip, and the vertical distance for a vertical tab
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // strip. |initial_selection_model| is the selection model before the drag
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // started and is only non-empty if |source_tab| was not initially selected.
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Init(TabStrip* source_tabstrip,
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            Tab* source_tab,
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            const std::vector<Tab*>& tabs,
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            const gfx::Point& mouse_offset,
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            int source_tab_offset,
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            const ui::ListSelectionModel& initial_selection_model,
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            DetachBehavior detach_behavior,
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            MoveBehavior move_behavior,
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            EventSource event_source);
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if there is a drag underway and the drag is attached to
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |tab_strip|.
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: this returns false if the TabDragController is in the process of
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // finishing the drag.
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool IsAttachedTo(TabStrip* tab_strip);
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if there is a drag underway.
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool IsActive();
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the move behavior. Has no effect if started_drag() is true.
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetMoveBehavior(MoveBehavior behavior);
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  MoveBehavior move_behavior() const { return move_behavior_; }
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EventSource event_source() const { return event_source_; }
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See description above fields for details on these.
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool active() const { return active_; }
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const TabStrip* attached_tabstrip() const { return attached_tabstrip_; }
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if a drag started.
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool started_drag() const { return started_drag_; }
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if mutating the TabStripModel.
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_mutating() const { return is_mutating_; }
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if we've detached from a tabstrip and are running a nested
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // move message loop.
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_dragging_window() const { return is_dragging_window_; }
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked to drag to the new location, in screen coordinates.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Drag(const gfx::Point& point_in_screen);
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Complete the current drag session.
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void EndDrag(EndDragReason reason);
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class DockDisplayer;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class DockDisplayer;
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef std::set<gfx::NativeView> DockWindows;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to indicate the direction the mouse has moved when attached.
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int kMovedMouseLeft  = 1 << 0;
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int kMovedMouseRight = 1 << 1;
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Enumeration of the ways a drag session can end.
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum EndDragType {
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Drag session exited normally: the user released the mouse.
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    NORMAL,
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The drag session was canceled (alt-tab during drag, escape ...)
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CANCELED,
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The tab (NavigationController) was destroyed during the drag.
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    TAB_DESTROYED
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether Detach() should release capture or not.
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum ReleaseCapture {
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    RELEASE_CAPTURE,
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DONT_RELEASE_CAPTURE,
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Specifies what should happen when RunMoveLoop completes.
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum EndRunLoopBehavior {
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Indicates the drag should end.
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    END_RUN_LOOP_STOP_DRAGGING,
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Indicates the drag should continue.
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    END_RUN_LOOP_CONTINUE_DRAGGING
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Enumeration of the possible positions the detached tab may detach from.
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum DetachPosition {
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DETACH_BEFORE,
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DETACH_AFTER,
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DETACH_ABOVE_OR_BELOW
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates what should happen after invoking DragBrowserToNewTabStrip().
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum DragBrowserResultType {
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The caller should return immediately. This return value is used if a
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // nested message loop was created or we're in a nested message loop and
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // need to exit it.
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DRAG_BROWSER_RESULT_STOP,
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The caller should continue.
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DRAG_BROWSER_RESULT_CONTINUE,
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Stores the date associated with a single tab that is being dragged.
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct TabDragData {
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    TabDragData();
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ~TabDragData();
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // The WebContents being dragged.
2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    content::WebContents* contents;
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The original content::WebContentsDelegate of |contents|, before it was
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // detached from the browser window. We store this so that we can forward
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // certain delegate notifications back to it if we can't handle them
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // locally.
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    content::WebContentsDelegate* original_delegate;
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // This is the index of the tab in |source_tabstrip_| when the drag
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // began. This is used to restore the previous state if the drag is aborted.
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    int source_model_index;
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // If attached this is the tab in |attached_tabstrip_|.
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Tab* attached_tab;
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Is the tab pinned?
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool pinned;
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef std::vector<TabDragData> DragData;
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets |drag_data| from |tab|. This also registers for necessary
2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // notifications and resets the delegate of the WebContents.
2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void InitTabDragData(Tab* tab, TabDragData* drag_data);
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from content::WebContentsDelegate:
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual content::WebContents* OpenURLFromTab(
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::WebContents* source,
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const content::OpenURLParams& params) OVERRIDE;
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NavigationStateChanged(const content::WebContents* source,
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      unsigned changed_flags) OVERRIDE;
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AddNewContents(content::WebContents* source,
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              content::WebContents* new_contents,
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              WindowOpenDisposition disposition,
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const gfx::Rect& initial_pos,
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              bool user_gesture,
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              bool* was_blocked) OVERRIDE;
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldSuppressDialogs() OVERRIDE;
2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual content::JavaScriptDialogManager*
2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      GetJavaScriptDialogManager() OVERRIDE;
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from content::NotificationObserver:
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Observe(int type,
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationSource& source,
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationDetails& details) OVERRIDE;
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from MessageLoop::Observer:
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual base::EventStatus WillProcessEvent(
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const base::NativeEvent& event) OVERRIDE;
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overriden from views::WidgetObserver:
2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnWidgetBoundsChanged(views::Widget* widget,
2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                     const gfx::Rect& new_bounds) OVERRIDE;
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overriden from TabStripModelObserver:
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void TabStripEmpty() OVERRIDE;
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initialize the offset used to calculate the position to create windows
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in |GetWindowCreatePoint|. This should only be invoked from |Init|.
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InitWindowCreatePoint();
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the point where a detached window should be created given the
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // current mouse position |origin|.
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point GetWindowCreatePoint(const gfx::Point& origin) const;
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateDockInfo(const gfx::Point& point_in_screen);
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Saves focus in the window that the drag initiated from. Focus will be
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // restored appropriately if the drag ends within this same window.
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SaveFocus();
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Restore focus to the View that had focus before the drag was started, if
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the drag ends within the same Window as it began.
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RestoreFocus();
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tests whether |point_in_screen| is past a minimum elasticity threshold
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // required to start a drag.
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool CanStartDrag(const gfx::Point& point_in_screen) const;
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Move the DraggedTabView according to the current mouse screen position,
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // potentially updating the source and other TabStrips.
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ContinueDragging(const gfx::Point& point_in_screen);
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Transitions dragging from |attached_tabstrip_| to |target_tabstrip|.
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |target_tabstrip| is NULL if the mouse is not over a valid tab strip.  See
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // DragBrowserResultType for details of the return type.
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DragBrowserResultType DragBrowserToNewTabStrip(
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      TabStrip* target_tabstrip,
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& point_in_screen);
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // actually reorder the tabs in anyway, just changes what's visible.
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DragActiveTabStacked(const gfx::Point& point_in_screen);
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Moves the active tab to the next/previous tab. Used when the next/previous
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab is stacked.
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MoveAttachedToNextStackedIndex(const gfx::Point& point_in_screen);
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MoveAttachedToPreviousStackedIndex(const gfx::Point& point_in_screen);
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles dragging tabs while the tabs are attached.
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MoveAttached(const gfx::Point& point_in_screen);
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles dragging while the tabs are detached.
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MoveDetached(const gfx::Point& point_in_screen);
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If necessary starts the |move_stacked_timer_|. The timer is started if
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // close enough to an edge with stacked tabs.
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StartMoveStackedTimerIfNecessary(
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& point_in_screen,
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int delay_ms);
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the TabStrip for the specified window, or NULL if one doesn't exist
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // or isn't compatible.
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStrip* GetTabStripForWindow(gfx::NativeWindow window);
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the compatible TabStrip to drag to at the specified point (screen
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinates), or NULL if there is none.
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStrip* GetTargetTabStripForPoint(const gfx::Point& point_in_screen);
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |tabstrip| contains the specified point in screen
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinates.
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool DoesTabStripContain(TabStrip* tabstrip,
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const gfx::Point& point_in_screen) const;
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the DetachPosition given the specified location in screen
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinates.
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DetachPosition GetDetachPosition(const gfx::Point& point_in_screen);
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DockInfo GetDockInfoAtPoint(const gfx::Point& point_in_screen);
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Attach the dragged Tab to the specified TabStrip.
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Attach(TabStrip* attached_tabstrip, const gfx::Point& point_in_screen);
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Detach the dragged Tab from the current TabStrip.
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Detach(ReleaseCapture release_capture);
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Detaches the tabs being dragged, creates a new Browser to contain them and
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // runs a nested move loop.
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DetachIntoNewBrowserAndRunMoveLoop(const gfx::Point& point_in_screen);
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Runs a nested message loop that handles moving the current
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Browser. |drag_offset| is the offset from the window origin and is used in
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // calculating the location of the window offset from the cursor while
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // dragging.
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RunMoveLoop(const gfx::Vector2d& drag_offset);
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Determines the index to insert tabs at. |dragged_bounds| is the bounds of
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the tabs being dragged, |start| the index of the tab to start looking from
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and |delta| the amount to increment (1 or -1).
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetInsertionIndexFrom(const gfx::Rect& dragged_bounds,
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int start,
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int delta) const;
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the index where the dragged WebContents should be inserted into
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinates relative to |attached_tabstrip_| and has had the mirroring
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // transformation applied.
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: this is invoked from |Attach| before the tabs have been inserted.
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const;
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |dragged_bounds| is close enough to the next stacked tab
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // so that the active tab should be dragged there.
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ShouldDragToNextStackedTab(const gfx::Rect& dragged_bounds,
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  int index) const;
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |dragged_bounds| is close enough to the previous stacked
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab so that the active tab should be dragged there.
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ShouldDragToPreviousStackedTab(const gfx::Rect& dragged_bounds,
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      int index) const;
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked.
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetInsertionIndexForDraggedBoundsStacked(
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Rect& dragged_bounds) const;
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Retrieve the bounds of the DraggedTabView relative to the attached
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // system.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetDraggedViewTabStripBounds(const gfx::Point& tab_strip_point);
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get the position of the dragged tab view relative to the attached tab
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // strip with the mirroring transform applied.
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point GetAttachedDragPoint(const gfx::Point& point_in_screen);
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finds the Tabs within the specified TabStrip that corresponds to the
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WebContents of the dragged tabs. Returns an empty vector if not attached.
3902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::vector<Tab*> GetTabsMatchingDraggedContents(TabStrip* tabstrip);
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds for the tabs based on the attached tab strip. The
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // x-coordinate of each tab is offset by |x_offset|.
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<gfx::Rect> CalculateBoundsForDraggedTabs(int x_offset);
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Does the work for EndDrag. If we actually started a drag and |how_end| is
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not TAB_DESTROYED then one of EndDrag or RevertDrag is invoked.
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void EndDragImpl(EndDragType how_end);
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Reverts a cancelled drag operation.
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RevertDrag();
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Reverts the tab at |drag_index| in |drag_data_|.
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RevertDragAt(size_t drag_index);
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Selects the dragged tabs in |model|. Does nothing if there are no longer
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // any dragged contents (as happens when a WebContents is deleted out from
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // under us).
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ResetSelection(TabStripModel* model);
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finishes a succesful drag operation.
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CompleteDrag();
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Resets the delegates of the WebContents.
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ResetDelegates();
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Create the DraggedTabView.
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CreateDraggedView(const std::vector<TabRendererData>& data,
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::vector<gfx::Rect>& renderer_bounds);
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds (in screen coordinates) of the specified View.
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetViewScreenBounds(views::View* tabstrip) const;
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Hides the frame for the window that contains the TabStrip the current
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // drag session was initiated from.
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void HideFrame();
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Closes a hidden frame at the end of a drag session.
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CleanUpHiddenFrame();
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DockDisplayerDestroyed(DockDisplayer* controller);
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void BringWindowUnderPointToFront(const gfx::Point& point_in_screen);
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience for getting the TabDragData corresponding to the tab the user
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // started dragging.
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabDragData* source_tab_drag_data() {
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return &(drag_data_[source_tab_index_]);
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience for |source_tab_drag_data()->contents|.
4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::WebContents* source_dragged_contents() {
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return source_tab_drag_data()->contents;
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the Widget of the currently attached TabStrip's BrowserView.
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  views::Widget* GetAttachedBrowserWidget();
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the tabs were originality one after the other in
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |source_tabstrip_|.
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool AreTabsConsecutive();
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates and returns a new Browser to handle the drag.
4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Browser* CreateBrowserForDrag(TabStrip* source,
4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const gfx::Point& point_in_screen,
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                gfx::Vector2d* drag_offset,
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                std::vector<gfx::Rect>* drag_bounds);
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the TabStripModel for the specified tabstrip.
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStripModel* GetModel(TabStrip* tabstrip) const;
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the location of the cursor. This is either the location of the
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // mouse or the location of the current touch point.
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point GetCursorScreenPoint();
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the offset from the top left corner of the window to
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |point_in_screen|.
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Vector2d GetWindowOffset(const gfx::Point& point_in_screen);
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if moving the mouse only changes the visible tabs.
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool move_only() const {
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return (move_behavior_ == MOVE_VISIBILE_TABS) != 0;
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If true Detaching creates a new browser and enters a nested message loop.
4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool detach_into_browser_;
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles registering for notifications.
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  content::NotificationRegistrar registrar_;
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EventSource event_source_;
4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The TabStrip the drag originated from.
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStrip* source_tabstrip_;
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The TabStrip the dragged Tab is currently attached to, or NULL if the
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // dragged Tab is detached.
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStrip* attached_tabstrip_;
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The screen that this drag is associated with. Cached, because other UI
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // elements are NULLd at various points during the lifetime of this object.
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Screen* screen_;
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The desktop type that this drag is associated with. Cached, because other
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // UI elements are NULLd at various points during the lifetime of this
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // object.
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  chrome::HostDesktopType host_desktop_type_;
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The visual representation of the dragged Tab.
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<DraggedTabView> view_;
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The position of the mouse (in screen coordinates) at the start of the drag
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // operation. This is used to calculate minimum elasticity before a
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // DraggedTabView is constructed.
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point start_point_in_screen_;
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the offset of the mouse from the top left of the Tab where
5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // dragging begun. This is used to ensure that the dragged view is always
5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // positioned at the correct location during the drag, and to ensure that the
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // detached window is created at the right location.
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point mouse_offset_;
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Ratio of the x-coordinate of the |source_tab_offset| to the width of the
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab. Not used for vertical tabs.
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  float offset_to_width_ratio_;
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A hint to use when positioning new windows created by detaching Tabs. This
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is the distance of the mouse from the top left of the dragged tab as if it
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // were the distance of the mouse from the top left of the first tab in the
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // attached TabStrip from the top left of the window.
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point window_create_point_;
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Location of the first tab in the source tabstrip in screen coordinates.
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is used to calculate window_create_point_.
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point first_source_tab_point_;
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The bounds of the browser window before the last Tab was detached. When
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the last Tab is detached, rather than destroying the frame (which would
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // abort the drag session), the frame is moved off-screen. If the drag is
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // aborted (e.g. by the user pressing Esc, or capture being lost), the Tab is
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // attached to the hidden frame and the frame moved back to these bounds.
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect restore_bounds_;
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The last view that had focus in the window containing |source_tab_|. This
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is saved so that focus can be restored properly when a drag begins and
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ends within this same window.
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  views::View* old_focused_view_;
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The position along the major axis of the mouse cursor in screen coordinates
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // at the time of the last re-order event.
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int last_move_screen_loc_;
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DockInfo dock_info_;
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DockWindows dock_windows_;
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<DockDisplayer*> dock_controllers_;
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Timer used to bring the window under the cursor to front. If the user
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // stops moving the mouse for a brief time over a browser window, it is
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // brought to front.
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::OneShotTimer<TabDragController> bring_to_front_timer_;
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Timer used to move the stacked tabs. See comment aboue
5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // StartMoveStackedTimerIfNecessary().
5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::OneShotTimer<TabDragController> move_stacked_timer_;
5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Did the mouse move enough that we started a drag?
5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool started_drag_;
5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Is the drag active?
5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool active_;
5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DragData drag_data_;
5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Index of the source tab in drag_data_.
5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  size_t source_tab_index_;
5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True until |MoveAttached| is invoked once.
5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool initial_move_;
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The selection model before the drag started. See comment above Init() for
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // details.
5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ui::ListSelectionModel initial_selection_model_;
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The selection model of |attached_tabstrip_| before the tabs were attached.
5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ui::ListSelectionModel selection_model_before_attach_;
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initial x-coordinates of the tabs when the drag started. Only used for
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // touch mode.
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<int> initial_tab_positions_;
5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DetachBehavior detach_behavior_;
5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  MoveBehavior move_behavior_;
5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Updated as the mouse is moved when attached. Indicates whether the mouse
5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // has ever moved to the left or right. If the tabs are ever detached this
5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is set to kMovedMouseRight | kMovedMouseLeft.
5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int mouse_move_direction_;
5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Last location used in screen coordinates.
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point last_point_in_screen_;
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The following are needed when detaching into a browser
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (|detach_into_browser_| is true).
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See description above getter.
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_dragging_window_;
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EndRunLoopBehavior end_run_loop_behavior_;
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If true, we're waiting for a move loop to complete.
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool waiting_for_run_loop_to_exit_;
6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The TabStrip to attach to after the move loop completes.
6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TabStrip* tab_strip_to_attach_to_after_exit_;
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Non-null for the duration of RunMoveLoop.
6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  views::Widget* move_loop_widget_;
6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If non-null set to true from destructor.
6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool* destroyed_;
6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See description above getter.
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_mutating_;
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TabDragController);
6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
621