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