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
|
// 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 "chrome/browser/views/tabs/browser_tab_strip_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/tabs/side_tab_strip.h"
////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, public:
BrowserTabStripController::BrowserTabStripController(TabStripModel* model,
SideTabStrip* tabstrip)
: model_(model),
tabstrip_(tabstrip) {
model_->AddObserver(this);
}
BrowserTabStripController::~BrowserTabStripController() {
}
////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, SideTabStripModel implementation:
SkBitmap BrowserTabStripController::GetIcon(int index) const {
return model_->GetTabContentsAt(index)->GetFavIcon();
}
string16 BrowserTabStripController::GetTitle(int index) const {
return model_->GetTabContentsAt(index)->GetTitle();
}
bool BrowserTabStripController::IsSelected(int index) const {
return model_->selected_index() == index;
}
SideTabStripModel::NetworkState
BrowserTabStripController::GetNetworkState(int index) const {
TabContents* contents = model_->GetTabContentsAt(index);
if (!contents || !contents->is_loading())
return NetworkState_None;
if (contents->waiting_for_response())
return NetworkState_Waiting;
return NetworkState_Loading;
}
void BrowserTabStripController::SelectTab(int index) {
model_->SelectTabContentsAt(index, true);
}
void BrowserTabStripController::CloseTab(int index) {
model_->CloseTabContentsAt(index);
}
////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, TabStripModelObserver implementation:
void BrowserTabStripController::TabInsertedAt(TabContents* contents, int index,
bool foreground) {
tabstrip_->AddTabAt(index);
}
void BrowserTabStripController::TabDetachedAt(TabContents* contents,
int index) {
tabstrip_->RemoveTabAt(index);
}
void BrowserTabStripController::TabSelectedAt(TabContents* old_contents,
TabContents* contents, int index,
bool user_gesture) {
tabstrip_->SelectTabAt(index);
}
void BrowserTabStripController::TabMoved(TabContents* contents, int from_index,
int to_index) {
}
void BrowserTabStripController::TabChangedAt(TabContents* contents, int index,
TabChangeType change_type) {
tabstrip_->UpdateTabAt(index);
}
void BrowserTabStripController::TabReplacedAt(TabContents* old_contents,
TabContents* new_contents,
int index) {
}
void BrowserTabStripController::TabPinnedStateChanged(TabContents* contents,
int index) {
}
void BrowserTabStripController::TabBlockedStateChanged(TabContents* contents,
int index) {
}
|