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) 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.
#ifndef CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_
#define CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_
#include "base/scoped_ptr.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/tabs/tab_strip_controller.h"
#include "chrome/common/notification_registrar.h"
class BaseTab;
class BaseTabStrip;
struct TabRendererData;
// An implementation of TabStripController that sources data from the
// TabContentses in a TabStripModel.
class BrowserTabStripController : public TabStripController,
public TabStripModelObserver,
public NotificationObserver {
public:
explicit BrowserTabStripController(TabStripModel* model);
virtual ~BrowserTabStripController();
void InitFromModel(BaseTabStrip* tabstrip);
TabStripModel* model() const { return model_; }
bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id,
BaseTab* tab) const;
bool IsCommandCheckedForTab(TabStripModel::ContextMenuCommand command_id,
BaseTab* tab) const;
void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id,
BaseTab* tab);
bool IsTabPinned(BaseTab* tab);
// TabStripController implementation:
virtual int GetCount() const;
virtual bool IsValidIndex(int model_index) const;
virtual int GetSelectedIndex() const;
virtual bool IsTabSelected(int model_index) const;
virtual bool IsTabPinned(int model_index) const;
virtual bool IsTabCloseable(int model_index) const;
virtual bool IsNewTabPage(int model_index) const;
virtual void SelectTab(int model_index);
virtual void CloseTab(int model_index);
virtual void ShowContextMenu(BaseTab* tab, const gfx::Point& p);
virtual void UpdateLoadingAnimations();
virtual int HasAvailableDragActions() const;
virtual void PerformDrop(bool drop_before, int index, const GURL& url);
virtual bool IsCompatibleWith(BaseTabStrip* other) const;
virtual void CreateNewTab();
// TabStripModelObserver implementation:
virtual void TabInsertedAt(TabContents* contents,
int model_index,
bool foreground);
virtual void TabDetachedAt(TabContents* contents, int model_index);
virtual void TabSelectedAt(TabContents* old_contents,
TabContents* contents,
int model_index,
bool user_gesture);
virtual void TabMoved(TabContents* contents,
int from_model_index,
int to_model_index);
virtual void TabChangedAt(TabContents* contents,
int model_index,
TabChangeType change_type);
virtual void TabReplacedAt(TabContents* old_contents,
TabContents* new_contents,
int model_index);
virtual void TabPinnedStateChanged(TabContents* contents, int model_index);
virtual void TabMiniStateChanged(TabContents* contents, int model_index);
virtual void TabBlockedStateChanged(TabContents* contents, int model_index);
// NotificationObserver implementation:
virtual void Observe(NotificationType type, const NotificationSource& source,
const NotificationDetails& details);
private:
class TabContextMenuContents;
// Invokes tabstrip_->SetTabData.
void SetTabDataAt(TabContents* contents, int model_index);
// Sets the TabRendererData from the TabStripModel.
void SetTabRendererDataFromModel(TabContents* contents,
int model_index,
TabRendererData* data);
void StartHighlightTabsForCommand(
TabStripModel::ContextMenuCommand command_id,
BaseTab* tab);
void StopHighlightTabsForCommand(
TabStripModel::ContextMenuCommand command_id,
BaseTab* tab);
Profile* profile() const { return model_->profile(); }
TabStripModel* model_;
BaseTabStrip* tabstrip_;
// If non-NULL it means we're showing a menu for the tab.
scoped_ptr<TabContextMenuContents> context_menu_contents_;
NotificationRegistrar notification_registrar_;
DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController);
};
#endif // CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_
|