Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/ui/gtk/tabs/drag_data.cc

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "chrome/browser/ui/gtk/tabs/drag_data.h"
6
7 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_delegate.h"
11
12 using content::WebContents;
13
14 DraggedTabData::DraggedTabData()
15 : tab_(NULL),
16 contents_(NULL),
17 original_delegate_(NULL),
18 source_model_index_(-1),
19 pinned_(false),
20 mini_(false) {
21 }
22
23 DraggedTabData::DraggedTabData(TabGtk* tab,
24 WebContents* contents,
25 content::WebContentsDelegate* original_delegate,
26 int source_model_index,
27 bool pinned,
28 bool mini)
29 : tab_(tab),
30 contents_(contents),
31 original_delegate_(original_delegate),
32 source_model_index_(source_model_index),
33 pinned_(pinned),
34 mini_(mini) {
35 }
36
37 DraggedTabData::~DraggedTabData() {
38 }
39
40 void DraggedTabData::ResetDelegate() {
41 contents_->SetDelegate(original_delegate_);
42 }
43
44 DragData::DragData(std::vector<DraggedTabData> drag_data, int source_tab_index)
45 : drag_data_(drag_data),
46 source_tab_index_(source_tab_index),
47 non_mini_tab_count_(0),
48 mini_tab_count_(0) {
49 GetNumberOfMiniNonMiniTabs(0, drag_data_.size(),
50 &mini_tab_count_, &non_mini_tab_count_);
51 }
52
53 DragData::~DragData() {
54 }
55
56 std::vector<TabGtk*> DragData::GetDraggedTabs() const {
57 std::vector<TabGtk*> tabs;
58 for (size_t i = 0; i < drag_data_.size(); ++i) {
59 if (drag_data_[i].tab_)
60 tabs.push_back(drag_data_[i].tab_);
61 }
62 return tabs;
63 }
64
65 std::vector<WebContents*> DragData::GetDraggedTabsContents() const {
66 std::vector<WebContents*> web_contentses;
67 for (size_t i = 0; i < drag_data_.size(); ++i) {
68 if (drag_data_[i].contents_)
69 web_contentses.push_back(drag_data_[i].contents_);
70 }
71 return web_contentses;
72 }
73
74 void DragData::GetNumberOfMiniNonMiniTabs(
75 int from, int to, int* mini, int* non_mini) const {
76 DCHECK(to <= static_cast<int>(drag_data_.size()));
77
78 *mini = 0;
79 *non_mini = 0;
80 for (int i = from; i < to; ++i) {
81 if (drag_data_[i].mini_)
82 (*mini)++;
83 else
84 (*non_mini)++;
85 }
86 }
87
88 int DragData::GetAddTypesForDraggedTabAt(size_t index) {
89 int add_types = TabStripModel::ADD_NONE;
90 if (get(index)->pinned_)
91 add_types |= TabStripModel::ADD_PINNED;
92 if (static_cast<int>(index) == source_tab_index_)
93 add_types |= TabStripModel::ADD_ACTIVE;
94 return add_types;
95 }
96
97 WebContents* DragData::GetSourceWebContents() {
98 return GetSourceTabData()->contents_;
99 }
100
101 DraggedTabData* DragData::GetSourceTabData() {
102 return get(source_tab_index_);
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698