blob: 68d0caf6be782ecaddebc07006c6470a7a8a5000 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_
#define CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
class TabContentsWrapper;
class TabGtk;
namespace content {
class WebContents;
class WebContentsDelegate;
}
struct DraggedTabData {
public:
DraggedTabData();
DraggedTabData(TabGtk* tab,
TabContentsWrapper* contents,
content::WebContentsDelegate* original_delegate,
int source_model_index,
bool pinned,
bool mini);
~DraggedTabData();
// Resetting the delegate of |contents_->web_contents()| to
// |original_delegate_|.
void ResetDelegate();
// The tab being dragged.
TabGtk* tab_;
// The TabContents being dragged.
TabContentsWrapper* contents_;
// The original content::WebContentsDelegate of |contents|, before it was
// detached from the browser window. We store this so that we can forward
// certain delegate notifications back to it if we can't handle them locally.
content::WebContentsDelegate* original_delegate_;
// This is the index of |contents| in |source_tabstrip_| when the drag
// began. This is used to restore the previous state if the drag is aborted.
int source_model_index_;
// Is the tab pinned?
bool pinned_;
// Is the tab mini?
bool mini_;
};
// Holds information about all the dragged tabs. It also provides several
// convenience methods.
class DragData {
public:
DragData(std::vector<DraggedTabData> drag_data, int source_tab_index);
~DragData();
// Returns all the |tab_| fields of the tabs in |drag_data_|.
std::vector<TabGtk*> GetDraggedTabs() const;
// Returns all the |contents_| fields of the tabs in |drag_data_|.
std::vector<content::WebContents*> GetDraggedTabsContents() const;
// Returns the correct add type for the tab in |drag_data_[i]|. See
// TabStripModel::AddTabTypes for available types.
int GetAddTypesForDraggedTabAt(size_t index);
// Calculates the number of mini and non mini tabs from position |from|
// (included) up to position |to| (excluded) within |drag_data_| and
// populates |mini| and |non_mini| accordingly.
void GetNumberOfMiniNonMiniTabs(int from, int to, int* mini,
int* non_mini) const;
// Convenience method for getting the number of the dragged tabs.
size_t size() const { return drag_data_.size(); }
// Convenience method for getting the drag data associated with tab at |index|
// within |drag_data_|.
DraggedTabData* get(size_t index) { return &drag_data_[index]; }
int source_tab_index() const { return source_tab_index_; }
int mini_tab_count() const { return mini_tab_count_; }
int non_mini_tab_count() const { return non_mini_tab_count_; }
// Convenience for |source_tab_drag_data()->contents_|.
TabContentsWrapper* GetSourceTabContentsWrapper();
// Convenience for |source_tab_drag_data()->contents_->web_contents()|.
content::WebContents* GetSourceWebContents();
// Convenience for getting the DraggedTabData corresponding to the tab that
// was under the mouse pointer when the user started dragging.
DraggedTabData* GetSourceTabData();
private:
std::vector<DraggedTabData> drag_data_;
// Index of the source tab in |drag_data_|.
int source_tab_index_;
// Number of non mini tabs within |drag_data_|.
int non_mini_tab_count_;
// Number of mini tabs within |drag_data_|.
int mini_tab_count_;
DISALLOW_COPY_AND_ASSIGN(DragData);
};
#endif // CHROME_BROWSER_UI_GTK_TABS_DRAG_DATA_H_
|