tab_drag_controller.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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) 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/memory/weak_ptr.h" 119ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch#include "base/message_loop/message_loop.h" 12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/timer/timer.h" 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.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; 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Tab; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct TabRendererData; 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStrip; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStripModel; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TabDragController is responsible for managing the tab dragging session. When 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the user presses the mouse on a tab a new TabDragController is created and 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Drag() is invoked as the mouse is dragged. If the mouse is dragged far enough 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TabDragController starts a drag session. The drag session is completed when 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// EndDrag() is invoked (or the TabDragController is destroyed). 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// While dragging within a tab strip TabDragController sets the bounds of the 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// tabs (this is referred to as attached). When the user drags far enough such 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// that the tabs should be moved out of the tab strip a new Browser is created 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// and RunMoveLoop() is invoked on the Widget to drag the browser around. This 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// is the default on aura. 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabDragController : public content::WebContentsDelegate, 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public content::NotificationObserver, 51b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public base::MessageLoopForUI::Observer, 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public views::WidgetObserver, 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public TabStripModelObserver { 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum DetachBehavior { 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DETACHABLE, 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOT_DETACHABLE 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // What should happen as the mouse is dragged within the tabstrip. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum MoveBehavior { 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Only the set of visible tabs should change. This is only applicable when 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // using touch layout. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MOVE_VISIBILE_TABS, 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Typical behavior where tabs are dragged around. 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) REORDER 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Indicates the event source that initiated the drag. 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) enum EventSource { 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EVENT_SOURCE_MOUSE, 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EVENT_SOURCE_TOUCH, 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }; 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Amount above or below the tabstrip the user has to drag before detaching. 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kTouchVerticalDetachMagnetism; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kVerticalDetachMagnetism; 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabDragController(); 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~TabDragController(); 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Initializes TabDragController to drag the tabs in |tabs| originating from 844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // |source_tabstrip|. |source_tab| is the tab that initiated the drag and is 854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // contained in |tabs|. |mouse_offset| is the distance of the mouse pointer 864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // from the origin of the first tab in |tabs| and |source_tab_offset| the 874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // offset from |source_tab|. |source_tab_offset| is the horizontal offset of 884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // |mouse_offset| relative to |source_tab|. |initial_selection_model| is the 894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // selection model before the drag started and is only non-empty if 904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // |source_tab| was not initially selected. 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Init(TabStrip* source_tabstrip, 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Tab* source_tab, 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const std::vector<Tab*>& tabs, 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Point& mouse_offset, 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int source_tab_offset, 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const ui::ListSelectionModel& initial_selection_model, 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DetachBehavior detach_behavior, 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) MoveBehavior move_behavior, 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EventSource event_source); 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if there is a drag underway and the drag is attached to 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |tab_strip|. 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: this returns false if the TabDragController is in the process of 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // finishing the drag. 1051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static bool IsAttachedTo(const TabStrip* tab_strip); 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if there is a drag underway. 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool IsActive(); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the move behavior. Has no effect if started_drag() is true. 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetMoveBehavior(MoveBehavior behavior); 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MoveBehavior move_behavior() const { return move_behavior_; } 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EventSource event_source() const { return event_source_; } 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See description above fields for details on these. 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool active() const { return active_; } 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const TabStrip* attached_tabstrip() const { return attached_tabstrip_; } 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if a drag started. 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool started_drag() const { return started_drag_; } 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if mutating the TabStripModel. 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_mutating() const { return is_mutating_; } 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if we've detached from a tabstrip and are running a nested 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // move message loop. 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_dragging_window() const { return is_dragging_window_; } 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Invoked to drag to the new location, in screen coordinates. 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Drag(const gfx::Point& point_in_screen); 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Complete the current drag session. 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void EndDrag(EndDragReason reason); 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used to indicate the direction the mouse has moved when attached. 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kMovedMouseLeft = 1 << 0; 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kMovedMouseRight = 1 << 1; 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Enumeration of the ways a drag session can end. 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum EndDragType { 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Drag session exited normally: the user released the mouse. 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NORMAL, 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The drag session was canceled (alt-tab during drag, escape ...) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CANCELED, 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The tab (NavigationController) was destroyed during the drag. 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TAB_DESTROYED 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether Detach() should release capture or not. 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum ReleaseCapture { 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RELEASE_CAPTURE, 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DONT_RELEASE_CAPTURE, 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Specifies what should happen when RunMoveLoop completes. 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum EndRunLoopBehavior { 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates the drag should end. 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) END_RUN_LOOP_STOP_DRAGGING, 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates the drag should continue. 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) END_RUN_LOOP_CONTINUE_DRAGGING 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Enumeration of the possible positions the detached tab may detach from. 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum DetachPosition { 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DETACH_BEFORE, 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DETACH_AFTER, 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DETACH_ABOVE_OR_BELOW 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates what should happen after invoking DragBrowserToNewTabStrip(). 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum DragBrowserResultType { 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The caller should return immediately. This return value is used if a 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // nested message loop was created or we're in a nested message loop and 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // need to exit it. 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DRAG_BROWSER_RESULT_STOP, 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The caller should continue. 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DRAG_BROWSER_RESULT_CONTINUE, 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the date associated with a single tab that is being dragged. 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct TabDragData { 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabDragData(); 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~TabDragData(); 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The WebContents being dragged. 1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* contents; 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // content::WebContentsDelegate for |contents| before it was detached from 1954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // the browser window. We store this so that we can forward certain delegate 1964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // notifications back to it if we can't handle them locally. 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::WebContentsDelegate* original_delegate; 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the index of the tab in |source_tabstrip_| when the drag 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // began. This is used to restore the previous state if the drag is aborted. 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int source_model_index; 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If attached this is the tab in |attached_tabstrip_|. 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Tab* attached_tab; 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Is the tab pinned? 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool pinned; 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef std::vector<TabDragData> DragData; 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets |drag_data| from |tab|. This also registers for necessary 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // notifications and resets the delegate of the WebContents. 2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void InitTabDragData(Tab* tab, TabDragData* drag_data); 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from content::WebContentsDelegate: 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual content::WebContents* OpenURLFromTab( 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::WebContents* source, 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::OpenURLParams& params) OVERRIDE; 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void NavigationStateChanged(const content::WebContents* source, 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) unsigned changed_flags) OVERRIDE; 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void AddNewContents(content::WebContents* source, 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::WebContents* new_contents, 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WindowOpenDisposition disposition, 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& initial_pos, 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool user_gesture, 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool* was_blocked) OVERRIDE; 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool ShouldSuppressDialogs() OVERRIDE; 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual content::JavaScriptDialogManager* 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetJavaScriptDialogManager() OVERRIDE; 231d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual void RequestMediaAccessPermission( 232d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) content::WebContents* web_contents, 233d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const content::MediaStreamRequest& request, 234d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const content::MediaResponseCallback& callback) OVERRIDE; 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from content::NotificationObserver: 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Observe(int type, 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) OVERRIDE; 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from MessageLoop::Observer: 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual base::EventStatus WillProcessEvent( 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const base::NativeEvent& event) OVERRIDE; 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overriden from views::WidgetObserver: 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnWidgetBoundsChanged(views::Widget* widget, 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Rect& new_bounds) OVERRIDE; 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overriden from TabStripModelObserver: 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void TabStripEmpty() OVERRIDE; 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initialize the offset used to calculate the position to create windows 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in |GetWindowCreatePoint|. This should only be invoked from |Init|. 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InitWindowCreatePoint(); 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the point where a detached window should be created given the 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // current mouse position |origin|. 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point GetWindowCreatePoint(const gfx::Point& origin) const; 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateDockInfo(const gfx::Point& point_in_screen); 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Saves focus in the window that the drag initiated from. Focus will be 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // restored appropriately if the drag ends within this same window. 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SaveFocus(); 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Restore focus to the View that had focus before the drag was started, if 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the drag ends within the same Window as it began. 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RestoreFocus(); 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tests whether |point_in_screen| is past a minimum elasticity threshold 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // required to start a drag. 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool CanStartDrag(const gfx::Point& point_in_screen) const; 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Invoked once a drag has started to determine the appropriate tabstrip to 2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // drag to (which may be the currently attached one). 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ContinueDragging(const gfx::Point& point_in_screen); 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Transitions dragging from |attached_tabstrip_| to |target_tabstrip|. 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |target_tabstrip| is NULL if the mouse is not over a valid tab strip. See 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // DragBrowserResultType for details of the return type. 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DragBrowserResultType DragBrowserToNewTabStrip( 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* target_tabstrip, 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Point& point_in_screen); 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // actually reorder the tabs in anyway, just changes what's visible. 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DragActiveTabStacked(const gfx::Point& point_in_screen); 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Moves the active tab to the next/previous tab. Used when the next/previous 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tab is stacked. 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void MoveAttachedToNextStackedIndex(const gfx::Point& point_in_screen); 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void MoveAttachedToPreviousStackedIndex(const gfx::Point& point_in_screen); 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Handles dragging tabs while the tabs are attached. 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void MoveAttached(const gfx::Point& point_in_screen); 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If necessary starts the |move_stacked_timer_|. The timer is started if 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // close enough to an edge with stacked tabs. 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StartMoveStackedTimerIfNecessary( 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Point& point_in_screen, 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int delay_ms); 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the TabStrip for the specified window, or NULL if one doesn't exist 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // or isn't compatible. 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* GetTabStripForWindow(gfx::NativeWindow window); 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the compatible TabStrip to drag to at the specified point (screen 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // coordinates), or NULL if there is none. 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* GetTargetTabStripForPoint(const gfx::Point& point_in_screen); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if |tabstrip| contains the specified point in screen 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // coordinates. 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DoesTabStripContain(TabStrip* tabstrip, 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Point& point_in_screen) const; 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the DetachPosition given the specified location in screen 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // coordinates. 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DetachPosition GetDetachPosition(const gfx::Point& point_in_screen); 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Attach the dragged Tab to the specified TabStrip. 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Attach(TabStrip* attached_tabstrip, const gfx::Point& point_in_screen); 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Detach the dragged Tab from the current TabStrip. 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Detach(ReleaseCapture release_capture); 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Detaches the tabs being dragged, creates a new Browser to contain them and 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // runs a nested move loop. 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DetachIntoNewBrowserAndRunMoveLoop(const gfx::Point& point_in_screen); 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Runs a nested message loop that handles moving the current 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser. |drag_offset| is the offset from the window origin and is used in 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // calculating the location of the window offset from the cursor while 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // dragging. 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RunMoveLoop(const gfx::Vector2d& drag_offset); 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Determines the index to insert tabs at. |dragged_bounds| is the bounds of 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the tabs being dragged, |start| the index of the tab to start looking from 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and |delta| the amount to increment (1 or -1). 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetInsertionIndexFrom(const gfx::Rect& dragged_bounds, 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int start, 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int delta) const; 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the index where the dragged WebContents should be inserted into 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // coordinates relative to |attached_tabstrip_| and has had the mirroring 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // transformation applied. 3484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // NOTE: this is invoked from Attach() before the tabs have been inserted. 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const; 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if |dragged_bounds| is close enough to the next stacked tab 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // so that the active tab should be dragged there. 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldDragToNextStackedTab(const gfx::Rect& dragged_bounds, 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int index) const; 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if |dragged_bounds| is close enough to the previous stacked 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tab so that the active tab should be dragged there. 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldDragToPreviousStackedTab(const gfx::Rect& dragged_bounds, 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int index) const; 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked. 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetInsertionIndexForDraggedBoundsStacked( 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& dragged_bounds) const; 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Retrieve the bounds of the DraggedTabView relative to the attached 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // system. 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect GetDraggedViewTabStripBounds(const gfx::Point& tab_strip_point); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get the position of the dragged tab view relative to the attached tab 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // strip with the mirroring transform applied. 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point GetAttachedDragPoint(const gfx::Point& point_in_screen); 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finds the Tabs within the specified TabStrip that corresponds to the 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // WebContents of the dragged tabs. Returns an empty vector if not attached. 3762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::vector<Tab*> GetTabsMatchingDraggedContents(TabStrip* tabstrip); 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Returns the bounds for the tabs based on the attached tab strip. 3794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) std::vector<gfx::Rect> CalculateBoundsForDraggedTabs(); 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3814e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Does the work for EndDrag(). If we actually started a drag and |how_end| is 3824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // not TAB_DESTROYED then one of EndDrag() or RevertDrag() is invoked. 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void EndDragImpl(EndDragType how_end); 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reverts a cancelled drag operation. 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RevertDrag(); 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reverts the tab at |drag_index| in |drag_data_|. 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RevertDragAt(size_t drag_index); 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Selects the dragged tabs in |model|. Does nothing if there are no longer 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // any dragged contents (as happens when a WebContents is deleted out from 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // under us). 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ResetSelection(TabStripModel* model); 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Restores |initial_selection_model_| to the |source_tabstrip_|. 3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void RestoreInitialSelection(); 3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finishes a succesful drag operation. 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CompleteDrag(); 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximizes the attached window. 4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MaximizeAttachedWindow(); 4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Resets the delegates of the WebContents. 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ResetDelegates(); 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the bounds (in screen coordinates) of the specified View. 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect GetViewScreenBounds(views::View* tabstrip) const; 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hides the frame for the window that contains the TabStrip the current 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // drag session was initiated from. 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HideFrame(); 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Closes a hidden frame at the end of a drag session. 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CleanUpHiddenFrame(); 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void BringWindowUnderPointToFront(const gfx::Point& point_in_screen); 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Convenience for getting the TabDragData corresponding to the tab the user 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // started dragging. 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabDragData* source_tab_drag_data() { 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return &(drag_data_[source_tab_index_]); 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Convenience for |source_tab_drag_data()->contents|. 4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* source_dragged_contents() { 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return source_tab_drag_data()->contents; 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the Widget of the currently attached TabStrip's BrowserView. 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::Widget* GetAttachedBrowserWidget(); 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the tabs were originality one after the other in 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |source_tabstrip_|. 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool AreTabsConsecutive(); 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 438a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Calculates and returns new bounds for the dragged browser window. 439a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Takes into consideration current and restore bounds of |source| tab strip 440a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // preventing the dragged size from being too small. Positions the new bounds 441a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // such that the tab that was dragged remains under the |point_in_screen|. 442a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Offsets |drag_bounds| if necessary when dragging to the right from the 443a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // source browser. 444a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Rect CalculateDraggedBrowserBounds(TabStrip* source, 445a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const gfx::Point& point_in_screen, 446a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::vector<gfx::Rect>* drag_bounds); 447a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 448a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Calculates scaled |drag_bounds| for dragged tabs and sets the tabs bounds. 449a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Layout of the tabstrip is performed and a new tabstrip width calculated. 450a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // When |last_tabstrip_width| is larger than the new tabstrip width the tabs 451a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // in attached tabstrip are scaled and the attached browser is positioned such 452a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // that the tab that was dragged remains under the |point_in_screen|. 453a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void AdjustBrowserAndTabBoundsForDrag(int last_tabstrip_width, 454a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const gfx::Point& point_in_screen, 455a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::vector<gfx::Rect>* drag_bounds); 456a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates and returns a new Browser to handle the drag. 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser* CreateBrowserForDrag(TabStrip* source, 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Point& point_in_screen, 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Vector2d* drag_offset, 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<gfx::Rect>* drag_bounds); 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the TabStripModel for the specified tabstrip. 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStripModel* GetModel(TabStrip* tabstrip) const; 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the location of the cursor. This is either the location of the 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // mouse or the location of the current touch point. 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point GetCursorScreenPoint(); 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the offset from the top left corner of the window to 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |point_in_screen|. 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Vector2d GetWindowOffset(const gfx::Point& point_in_screen); 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if moving the mouse only changes the visible tabs. 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool move_only() const { 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return (move_behavior_ == MOVE_VISIBILE_TABS) != 0; 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 479a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the NativeWindow at the specified point. If |exclude_dragged_view| 480a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // is true, then the dragged view is not considered. 481a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::NativeWindow GetLocalProcessWindow(const gfx::Point& screen_point, 482a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool exclude_dragged_view); 483a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 4844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // If true detaching creates a new browser and enters a nested message loop. 4852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool detach_into_browser_; 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Handles registering for notifications. 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationRegistrar registrar_; 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EventSource event_source_; 4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The TabStrip the drag originated from. 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* source_tabstrip_; 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The TabStrip the dragged Tab is currently attached to, or NULL if the 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // dragged Tab is detached. 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* attached_tabstrip_; 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The screen that this drag is associated with. Cached, because other UI 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // elements are NULLd at various points during the lifetime of this object. 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Screen* screen_; 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The desktop type that this drag is associated with. Cached, because other 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UI elements are NULLd at various points during the lifetime of this 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // object. 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome::HostDesktopType host_desktop_type_; 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 508a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Aura mouse capture and release is used on Ash platforms as well as on 509a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Linux to ensure that pointer grab is not released prematurely. 510a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool use_aura_capture_policy_; 511a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The position of the mouse (in screen coordinates) at the start of the drag 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // operation. This is used to calculate minimum elasticity before a 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // DraggedTabView is constructed. 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point start_point_in_screen_; 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // This is the offset of the mouse from the top left of the first Tab where 5184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // dragging began. This is used to ensure that the dragged view is always 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // positioned at the correct location during the drag, and to ensure that the 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // detached window is created at the right location. 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point mouse_offset_; 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Ratio of the x-coordinate of the |source_tab_offset| to the width of the 5244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // tab. 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float offset_to_width_ratio_; 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A hint to use when positioning new windows created by detaching Tabs. This 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is the distance of the mouse from the top left of the dragged tab as if it 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // were the distance of the mouse from the top left of the first tab in the 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // attached TabStrip from the top left of the window. 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point window_create_point_; 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Location of the first tab in the source tabstrip in screen coordinates. 5344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // This is used to calculate |window_create_point_|. 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point first_source_tab_point_; 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The bounds of the browser window before the last Tab was detached. When 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the last Tab is detached, rather than destroying the frame (which would 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // abort the drag session), the frame is moved off-screen. If the drag is 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // aborted (e.g. by the user pressing Esc, or capture being lost), the Tab is 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // attached to the hidden frame and the frame moved back to these bounds. 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect restore_bounds_; 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 544f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Storage ID in ViewStorage where the last view that had focus in the window 545f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // containing |source_tab_| is saved. This is saved so that focus can be 546f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // restored properly when a drag begins and ends within this same window. 54758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const int old_focused_view_id_; 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // The horizontal position of the mouse cursor in screen coordinates at the 5504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // time of the last re-order event. 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int last_move_screen_loc_; 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Timer used to bring the window under the cursor to front. If the user 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // stops moving the mouse for a brief time over a browser window, it is 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // brought to front. 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::OneShotTimer<TabDragController> bring_to_front_timer_; 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Timer used to move the stacked tabs. See comment aboue 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // StartMoveStackedTimerIfNecessary(). 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::OneShotTimer<TabDragController> move_stacked_timer_; 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Did the mouse move enough that we started a drag? 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool started_drag_; 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Is the drag active? 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool active_; 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DragData drag_data_; 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Index of the source tab in |drag_data_|. 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t source_tab_index_; 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // True until MoveAttached() is first invoked. 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool initial_move_; 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The selection model before the drag started. See comment above Init() for 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // details. 5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ui::ListSelectionModel initial_selection_model_; 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The selection model of |attached_tabstrip_| before the tabs were attached. 5812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ui::ListSelectionModel selection_model_before_attach_; 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initial x-coordinates of the tabs when the drag started. Only used for 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // touch mode. 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<int> initial_tab_positions_; 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DetachBehavior detach_behavior_; 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MoveBehavior move_behavior_; 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updated as the mouse is moved when attached. Indicates whether the mouse 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // has ever moved to the left or right. If the tabs are ever detached this 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is set to kMovedMouseRight | kMovedMouseLeft. 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int mouse_move_direction_; 5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Last location used in screen coordinates. 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point last_point_in_screen_; 5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The following are needed when detaching into a browser 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (|detach_into_browser_| is true). 6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See description above getter. 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_dragging_window_; 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 60468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // True if |attached_tabstrip_| is in a browser specifically created for 60568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // the drag. 60668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) bool is_dragging_new_browser_; 60768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 60868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // True if |source_tabstrip_| was maximized before the drag. 60968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) bool was_source_maximized_; 61068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 61168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // True if |source_tabstrip_| was in immersive fullscreen before the drag. 61268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) bool was_source_fullscreen_; 61368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 6145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // True if the initial drag resulted in restoring the window (because it was 6155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // maximized). 6165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool did_restore_window_; 6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EndRunLoopBehavior end_run_loop_behavior_; 6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If true, we're waiting for a move loop to complete. 6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool waiting_for_run_loop_to_exit_; 6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The TabStrip to attach to after the move loop completes. 6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStrip* tab_strip_to_attach_to_after_exit_; 6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Non-null for the duration of RunMoveLoop. 6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::Widget* move_loop_widget_; 6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See description above getter. 6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_mutating_; 6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // |attach_x_| and |attach_index_| are set to the x-coordinate of the mouse 6334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // (in terms of the tabstrip) and the insertion index at the time tabs are 6344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // dragged into a new browser (attached). They are used to ensure we don't 6354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // shift the tabs around in the wrong direction. The two are only valid if 6364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // |attach_index_| is not -1. 6374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // See comment around use for more details. 6384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) int attach_x_; 6394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) int attach_index_; 6404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 641d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) base::WeakPtrFactory<TabDragController> weak_factory_; 642d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TabDragController); 6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ 647