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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
// Copyright (c) 2010 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.
#include "base/metrics/nacl_histogram.h"
#include "chrome/browser/tabs/default_tab_handler.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/tabs/tab_strip_model.h"
////////////////////////////////////////////////////////////////////////////////
// DefaultTabHandler, public:
DefaultTabHandler::DefaultTabHandler(TabHandlerDelegate* delegate)
: delegate_(delegate),
ALLOW_THIS_IN_INITIALIZER_LIST(
model_(new TabStripModel(this, delegate->GetProfile()))) {
UmaNaclHistogramEnumeration(FIRST_TAB_NACL_BASELINE);
model_->AddObserver(this);
}
DefaultTabHandler::~DefaultTabHandler() {
// The tab strip should not have any tabs at this point.
DCHECK(model_->empty());
model_->RemoveObserver(this);
}
////////////////////////////////////////////////////////////////////////////////
// DefaultTabHandler, TabHandler implementation:
TabStripModel* DefaultTabHandler::GetTabStripModel() const {
return model_.get();
}
////////////////////////////////////////////////////////////////////////////////
// DefaultTabHandler, TabStripModelDelegate implementation:
TabContents* DefaultTabHandler::AddBlankTab(bool foreground) {
UmaNaclHistogramEnumeration(NEW_TAB_NACL_BASELINE);
return delegate_->AsBrowser()->AddBlankTab(foreground);
}
TabContents* DefaultTabHandler::AddBlankTabAt(int index, bool foreground) {
return delegate_->AsBrowser()->AddBlankTabAt(index, foreground);
}
Browser* DefaultTabHandler::CreateNewStripWithContents(
TabContents* detached_contents,
const gfx::Rect& window_bounds,
const DockInfo& dock_info,
bool maximize) {
return delegate_->AsBrowser()->CreateNewStripWithContents(detached_contents,
window_bounds,
dock_info,
maximize);
}
void DefaultTabHandler::ContinueDraggingDetachedTab(
TabContents* contents,
const gfx::Rect& window_bounds,
const gfx::Rect& tab_bounds) {
delegate_->AsBrowser()->ContinueDraggingDetachedTab(contents,
window_bounds,
tab_bounds);
}
int DefaultTabHandler::GetDragActions() const {
return delegate_->AsBrowser()->GetDragActions();
}
TabContents* DefaultTabHandler::CreateTabContentsForURL(
const GURL& url,
const GURL& referrer,
Profile* profile,
PageTransition::Type transition,
bool defer_load,
SiteInstance* instance) const {
return delegate_->AsBrowser()->CreateTabContentsForURL(url,
referrer,
profile,
transition,
defer_load,
instance);
}
bool DefaultTabHandler::CanDuplicateContentsAt(int index) {
return delegate_->AsBrowser()->CanDuplicateContentsAt(index);
}
void DefaultTabHandler::DuplicateContentsAt(int index) {
delegate_->AsBrowser()->DuplicateContentsAt(index);
}
void DefaultTabHandler::CloseFrameAfterDragSession() {
delegate_->AsBrowser()->CloseFrameAfterDragSession();
}
void DefaultTabHandler::CreateHistoricalTab(TabContents* contents) {
delegate_->AsBrowser()->CreateHistoricalTab(contents);
}
bool DefaultTabHandler::RunUnloadListenerBeforeClosing(TabContents* contents) {
return delegate_->AsBrowser()->RunUnloadListenerBeforeClosing(contents);
}
bool DefaultTabHandler::CanCloseContentsAt(int index) {
return delegate_->AsBrowser()->CanCloseContentsAt(index);
}
bool DefaultTabHandler::CanBookmarkAllTabs() const {
return delegate_->AsBrowser()->CanBookmarkAllTabs();
}
void DefaultTabHandler::BookmarkAllTabs() {
delegate_->AsBrowser()->BookmarkAllTabs();
}
bool DefaultTabHandler::CanCloseTab() const {
return delegate_->AsBrowser()->CanCloseTab();
}
void DefaultTabHandler::ToggleUseVerticalTabs() {
delegate_->AsBrowser()->ToggleUseVerticalTabs();
}
bool DefaultTabHandler::CanRestoreTab() {
return delegate_->AsBrowser()->CanRestoreTab();
}
void DefaultTabHandler::RestoreTab() {
delegate_->AsBrowser()->RestoreTab();
}
bool DefaultTabHandler::LargeIconsPermitted() const {
return delegate_->AsBrowser()->LargeIconsPermitted();
}
bool DefaultTabHandler::UseVerticalTabs() const {
return delegate_->AsBrowser()->UseVerticalTabs();
}
////////////////////////////////////////////////////////////////////////////////
// DefaultTabHandler, TabStripModelObserver implementation:
void DefaultTabHandler::TabInsertedAt(TabContents* contents,
int index,
bool foreground) {
delegate_->AsBrowser()->TabInsertedAt(contents, index, foreground);
}
void DefaultTabHandler::TabClosingAt(TabStripModel* tab_strip_model,
TabContents* contents,
int index) {
delegate_->AsBrowser()->TabClosingAt(tab_strip_model, contents, index);
}
void DefaultTabHandler::TabDetachedAt(TabContents* contents, int index) {
delegate_->AsBrowser()->TabDetachedAt(contents, index);
}
void DefaultTabHandler::TabDeselectedAt(TabContents* contents, int index) {
delegate_->AsBrowser()->TabDeselectedAt(contents, index);
}
void DefaultTabHandler::TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
bool user_gesture) {
delegate_->AsBrowser()->TabSelectedAt(old_contents,
new_contents,
index,
user_gesture);
}
void DefaultTabHandler::TabMoved(TabContents* contents,
int from_index,
int to_index) {
delegate_->AsBrowser()->TabMoved(contents, from_index, to_index);
}
void DefaultTabHandler::TabReplacedAt(TabContents* old_contents,
TabContents* new_contents,
int index) {
delegate_->AsBrowser()->TabReplacedAt(old_contents, new_contents, index);
}
void DefaultTabHandler::TabPinnedStateChanged(TabContents* contents,
int index) {
delegate_->AsBrowser()->TabPinnedStateChanged(contents, index);
}
void DefaultTabHandler::TabStripEmpty() {
delegate_->AsBrowser()->TabStripEmpty();
}
////////////////////////////////////////////////////////////////////////////////
// TabHandler, public:
// static
TabHandler* TabHandler::CreateTabHandler(TabHandlerDelegate* delegate) {
return new DefaultTabHandler(delegate);
}
|