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.
5 #ifndef CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_
6 #define CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_
10 #include "base/basictypes.h"
16 class WebContentsDelegate
;
19 struct DraggedTabData
{
22 DraggedTabData(TabGtk
* tab
,
23 content::WebContents
* contents
,
24 content::WebContentsDelegate
* original_delegate
,
25 int source_model_index
,
30 // Resets the delegate of |contents_| to |original_delegate_|.
33 // The tab being dragged.
36 // The WebContents being dragged.
37 content::WebContents
* contents_
;
39 // The original content::WebContentsDelegate of |contents_|, before it was
40 // detached from the browser window. We store this so that we can forward
41 // certain delegate notifications back to it if we can't handle them locally.
42 content::WebContentsDelegate
* original_delegate_
;
44 // This is the index of |contents_| in |source_tabstrip_| when the drag
45 // began. This is used to restore the previous state if the drag is aborted.
46 int source_model_index_
;
55 // Holds information about all the dragged tabs. It also provides several
56 // convenience methods.
59 DragData(std::vector
<DraggedTabData
> drag_data
, int source_tab_index
);
62 // Returns all the |tab_| fields of the tabs in |drag_data_|.
63 std::vector
<TabGtk
*> GetDraggedTabs() const;
65 // Returns all the |contents_| fields of the tabs in |drag_data_|.
66 std::vector
<content::WebContents
*> GetDraggedTabsContents() const;
68 // Returns the correct add type for the tab in |drag_data_[i]|. See
69 // TabStripModel::AddTabTypes for available types.
70 int GetAddTypesForDraggedTabAt(size_t index
);
72 // Calculates the number of mini and non mini tabs from position |from|
73 // (included) up to position |to| (excluded) within |drag_data_| and
74 // populates |mini| and |non_mini| accordingly.
75 void GetNumberOfMiniNonMiniTabs(int from
, int to
, int* mini
,
78 // Convenience method for getting the number of the dragged tabs.
79 size_t size() const { return drag_data_
.size(); }
81 // Convenience method for getting the drag data associated with tab at |index|
82 // within |drag_data_|.
83 DraggedTabData
* get(size_t index
) { return &drag_data_
[index
]; }
85 int source_tab_index() const { return source_tab_index_
; }
86 int mini_tab_count() const { return mini_tab_count_
; }
87 int non_mini_tab_count() const { return non_mini_tab_count_
; }
89 // Convenience for |source_tab_drag_data()->contents_|.
90 content::WebContents
* GetSourceWebContents();
92 // Convenience for getting the DraggedTabData corresponding to the tab that
93 // was under the mouse pointer when the user started dragging.
94 DraggedTabData
* GetSourceTabData();
97 std::vector
<DraggedTabData
> drag_data_
;
99 // Index of the source tab in |drag_data_|.
100 int source_tab_index_
;
101 // Number of non mini tabs within |drag_data_|.
102 int non_mini_tab_count_
;
103 // Number of mini tabs within |drag_data_|.
106 DISALLOW_COPY_AND_ASSIGN(DragData
);
109 #endif // CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_