OLD | NEW |
| (Empty) |
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_GTK_TABS_DRAG_DATA_H_ | |
6 #define CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 | |
12 class TabGtk; | |
13 | |
14 namespace content { | |
15 class WebContents; | |
16 class WebContentsDelegate; | |
17 } | |
18 | |
19 struct DraggedTabData { | |
20 public: | |
21 DraggedTabData(); | |
22 DraggedTabData(TabGtk* tab, | |
23 content::WebContents* contents, | |
24 content::WebContentsDelegate* original_delegate, | |
25 int source_model_index, | |
26 bool pinned, | |
27 bool mini); | |
28 ~DraggedTabData(); | |
29 | |
30 // Resets the delegate of |contents_| to |original_delegate_|. | |
31 void ResetDelegate(); | |
32 | |
33 // The tab being dragged. | |
34 TabGtk* tab_; | |
35 | |
36 // The WebContents being dragged. | |
37 content::WebContents* contents_; | |
38 | |
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_; | |
43 | |
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_; | |
47 | |
48 // Is the tab pinned? | |
49 bool pinned_; | |
50 | |
51 // Is the tab mini? | |
52 bool mini_; | |
53 }; | |
54 | |
55 // Holds information about all the dragged tabs. It also provides several | |
56 // convenience methods. | |
57 class DragData { | |
58 public: | |
59 DragData(std::vector<DraggedTabData> drag_data, int source_tab_index); | |
60 ~DragData(); | |
61 | |
62 // Returns all the |tab_| fields of the tabs in |drag_data_|. | |
63 std::vector<TabGtk*> GetDraggedTabs() const; | |
64 | |
65 // Returns all the |contents_| fields of the tabs in |drag_data_|. | |
66 std::vector<content::WebContents*> GetDraggedTabsContents() const; | |
67 | |
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); | |
71 | |
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, | |
76 int* non_mini) const; | |
77 | |
78 // Convenience method for getting the number of the dragged tabs. | |
79 size_t size() const { return drag_data_.size(); } | |
80 | |
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]; } | |
84 | |
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_; } | |
88 | |
89 // Convenience for |source_tab_drag_data()->contents_|. | |
90 content::WebContents* GetSourceWebContents(); | |
91 | |
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(); | |
95 | |
96 private: | |
97 std::vector<DraggedTabData> drag_data_; | |
98 | |
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_|. | |
104 int mini_tab_count_; | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(DragData); | |
107 }; | |
108 | |
109 #endif // CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_ | |
OLD | NEW |