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

Side by Side Diff: chrome/browser/ui/views/ash/launcher/launcher_updater.h

Issue 9689047: Added notion of currently active app / browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review issues Created 8 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_
6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 namespace aura { 27 namespace aura {
28 class Window; 28 class Window;
29 } 29 }
30 30
31 // LauncherUpdater is responsible for keeping the launcher representation of a 31 // LauncherUpdater is responsible for keeping the launcher representation of a
32 // window up to date as the tab strip changes. 32 // window up to date as the tab strip changes.
33 class LauncherUpdater : public TabStripModelObserver { 33 class LauncherUpdater : public TabStripModelObserver {
34 public: 34 public:
35 // This API is to be used as part of testing only.
36 explicit class TestApi {
37 public:
38 TestApi(LauncherUpdater* launcher_updater)
39 : launcher_updater_(launcher_updater) {}
40 virtual ~TestApi() {}
41
42 // Returns the launcher id for |tab| if it's an app otherwise returns the
43 // id for the browser itself.
44 ash::LauncherID GetLauncherID(TabContentsWrapper* tab) {
45 return launcher_updater_->GetLauncherID(tab);
46 }
47
48 // Returns the launcher id for the browser window.
49 ash::LauncherID item_id() const { return launcher_updater_->item_id_; }
50
51 private:
52 LauncherUpdater* launcher_updater_;
53 };
54
35 enum Type { 55 enum Type {
36 TYPE_APP, 56 TYPE_APP,
37 TYPE_PANEL, 57 TYPE_PANEL,
38 TYPE_TABBED 58 TYPE_TABBED
39 }; 59 };
40 60
41 LauncherUpdater(aura::Window* window, 61 LauncherUpdater(aura::Window* window,
42 TabStripModel* tab_model, 62 TabStripModel* tab_model,
43 ChromeLauncherDelegate* launcher_delegate, 63 ChromeLauncherDelegate* launcher_delegate,
44 Type type, 64 Type type,
45 const std::string& app_id); 65 const std::string& app_id);
46 virtual ~LauncherUpdater(); 66 virtual ~LauncherUpdater();
47 67
48 // Sets up this LauncherUpdater. 68 // Sets up this LauncherUpdater.
49 void Init(); 69 void Init();
50 70
51 // Creates and returns a new LauncherUpdater for |browser|. This returns 71 // Creates and returns a new LauncherUpdater for |browser|. This returns
52 // NULL if a LauncherUpdater is not needed for the specified browser. 72 // NULL if a LauncherUpdater is not needed for the specified browser.
53 static LauncherUpdater* Create(Browser* browser); 73 static LauncherUpdater* Create(Browser* browser);
54 74
55 aura::Window* window() { return window_; } 75 aura::Window* window() { return window_; }
56 76
57 TabStripModel* tab_model() { return tab_model_; } 77 TabStripModel* tab_model() { return tab_model_; }
58 78
59 Type type() const { return type_; } 79 Type type() const { return type_; }
60 80
61 TabContentsWrapper* GetTab(ash::LauncherID id); 81 TabContentsWrapper* GetTab(ash::LauncherID id);
62 82
83 // Call to indicate that the window the tabcontents are in has changed its
84 // activation state.
85 void BrowserActivationStateChanged();
86
63 // TabStripModel overrides: 87 // TabStripModel overrides:
64 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, 88 virtual void ActiveTabChanged(TabContentsWrapper* old_contents,
65 TabContentsWrapper* new_contents, 89 TabContentsWrapper* new_contents,
66 int index, 90 int index,
67 bool user_gesture) OVERRIDE; 91 bool user_gesture) OVERRIDE;
68 virtual void TabChangedAt( 92 virtual void TabChangedAt(
69 TabContentsWrapper* tab, 93 TabContentsWrapper* tab,
70 int index, 94 int index,
71 TabStripModelObserver::TabChangeType change_type) OVERRIDE; 95 TabStripModelObserver::TabChangeType change_type) OVERRIDE;
72 virtual void TabInsertedAt(TabContentsWrapper* contents, 96 virtual void TabInsertedAt(TabContentsWrapper* contents,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab); 137 void RegisterAppItem(ash::LauncherID id, TabContentsWrapper* tab);
114 138
115 // Creates a tabbed launcher item. 139 // Creates a tabbed launcher item.
116 void CreateTabbedItem(); 140 void CreateTabbedItem();
117 141
118 // Returns true if this LauncherUpdater created the launcher item with the 142 // Returns true if this LauncherUpdater created the launcher item with the
119 // specified id. Returns true if it did. If the id corresponds to an app tab, 143 // specified id. Returns true if it did. If the id corresponds to an app tab,
120 // |tab| is set to the TabContentsWrapper for the app tab. 144 // |tab| is set to the TabContentsWrapper for the app tab.
121 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab); 145 bool ContainsID(ash::LauncherID id, TabContentsWrapper** tab);
122 146
147 // Returns the launcher id for |tab| if it's an app otherwise returns the
148 // id for the browser itself.
149 ash::LauncherID GetLauncherID(TabContentsWrapper* tab);
150
151 // Retrieves the running status of |tab|.
152 ash::LauncherItemStatus GetStatusForTab(TabContentsWrapper* tab);
153
123 ash::LauncherModel* launcher_model(); 154 ash::LauncherModel* launcher_model();
124 155
125 // Browser window we're in. 156 // Browser window we're in.
126 aura::Window* window_; 157 aura::Window* window_;
127 158
128 TabStripModel* tab_model_; 159 TabStripModel* tab_model_;
129 160
130 ChromeLauncherDelegate* launcher_delegate_; 161 ChromeLauncherDelegate* launcher_delegate_;
131 162
132 // Whether this corresponds to an app or tabbed browser. 163 // Whether this corresponds to an app or tabbed browser.
133 const Type type_; 164 const Type type_;
134 165
135 const std::string app_id_; 166 const std::string app_id_;
136 167
137 // This is one of three possible values: 168 // This is one of three possible values:
138 // . If type_ == TYPE_APP, this is the ID of the app item. 169 // . If type_ == TYPE_APP, this is the ID of the app item.
139 // . If type_ == TYPE_TABBED and all the tabs are app tabs this is -1. 170 // . If type_ == TYPE_TABBED and all the tabs are app tabs this is -1.
140 // . Otherwise this is the id of the TYPE_TABBED item. 171 // . Otherwise this is the id of the TYPE_TABBED item.
141 ash::LauncherID item_id_; 172 ash::LauncherID item_id_;
142 173
143 // Used for any app tabs. 174 // Used for any app tabs.
144 AppTabMap app_map_; 175 AppTabMap app_map_;
145 176
146 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater); 177 DISALLOW_COPY_AND_ASSIGN(LauncherUpdater);
147 }; 178 };
148 179
149 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_ 180 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_UPDATER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698