OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
6 | 6 |
7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
8 #include "ash/shelf/shelf_util.h" | 8 #include "ash/shelf/shelf_util.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // ChromeLauncherController will fail in win7_aura. | 134 // ChromeLauncherController will fail in win7_aura. |
135 if (ash::Shell::HasInstance()) | 135 if (ash::Shell::HasInstance()) |
136 ash::Shell::GetInstance()->GetScreen()->RemoveObserver(this); | 136 ash::Shell::GetInstance()->GetScreen()->RemoveObserver(this); |
137 | 137 |
138 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( | 138 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( |
139 settings_window_observer_.get()); | 139 settings_window_observer_.get()); |
140 | 140 |
141 BrowserList::RemoveObserver(this); | 141 BrowserList::RemoveObserver(this); |
142 | 142 |
143 BrowserList* browser_list = | 143 BrowserList* browser_list = |
144 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 144 BrowserList::GetInstance(ui::HOST_DESKTOP_TYPE_ASH); |
145 for (BrowserList::const_iterator i = browser_list->begin(); | 145 for (BrowserList::const_iterator i = browser_list->begin(); |
146 i != browser_list->end(); ++i) { | 146 i != browser_list->end(); ++i) { |
147 OnBrowserRemoved(*i); | 147 OnBrowserRemoved(*i); |
148 } | 148 } |
149 | 149 |
150 STLDeleteContainerPairSecondPointers(webcontents_to_observer_map_.begin(), | 150 STLDeleteContainerPairSecondPointers(webcontents_to_observer_map_.begin(), |
151 webcontents_to_observer_map_.end()); | 151 webcontents_to_observer_map_.end()); |
152 } | 152 } |
153 | 153 |
154 void BrowserStatusMonitor::UpdateAppItemState( | 154 void BrowserStatusMonitor::UpdateAppItemState( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 | 206 |
207 void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) { | 207 void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) { |
208 // Remove RootWindow and its ActivationClient from observed list. | 208 // Remove RootWindow and its ActivationClient from observed list. |
209 observed_root_windows_.Remove(window); | 209 observed_root_windows_.Remove(window); |
210 observed_activation_clients_.Remove( | 210 observed_activation_clients_.Remove( |
211 aura::client::GetActivationClient(window)); | 211 aura::client::GetActivationClient(window)); |
212 } | 212 } |
213 | 213 |
214 void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) { | 214 void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) { |
215 if (browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 215 if (browser->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) |
216 return; | 216 return; |
217 | 217 |
218 if (browser->is_type_popup() && browser->is_app()) { | 218 if (browser->is_type_popup() && browser->is_app()) { |
219 // Note: A V1 application will set the tab strip observer when the app gets | 219 // Note: A V1 application will set the tab strip observer when the app gets |
220 // added to the shelf. This makes sure that in the multi user case we will | 220 // added to the shelf. This makes sure that in the multi user case we will |
221 // only set the observer while the app item exists in the shelf. | 221 // only set the observer while the app item exists in the shelf. |
222 AddV1AppToShelf(browser); | 222 AddV1AppToShelf(browser); |
223 } else { | 223 } else { |
224 browser->tab_strip_model()->AddObserver(this); | 224 browser->tab_strip_model()->AddObserver(this); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) { | 228 void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) { |
229 if (browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 229 if (browser->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) |
230 return; | 230 return; |
231 | 231 |
232 if (browser->is_type_popup() && browser->is_app()) | 232 if (browser->is_type_popup() && browser->is_app()) |
233 RemoveV1AppFromShelf(browser); | 233 RemoveV1AppFromShelf(browser); |
234 else | 234 else |
235 browser->tab_strip_model()->RemoveObserver(this); | 235 browser->tab_strip_model()->RemoveObserver(this); |
236 | 236 |
237 UpdateBrowserItemState(); | 237 UpdateBrowserItemState(); |
238 } | 238 } |
239 | 239 |
(...skipping 25 matching lines...) Expand all Loading... |
265 | 265 |
266 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, | 266 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, |
267 content::WebContents* new_contents, | 267 content::WebContents* new_contents, |
268 int index, | 268 int index, |
269 int reason) { | 269 int reason) { |
270 Browser* browser = NULL; | 270 Browser* browser = NULL; |
271 // Use |new_contents|. |old_contents| could be NULL. | 271 // Use |new_contents|. |old_contents| could be NULL. |
272 DCHECK(new_contents); | 272 DCHECK(new_contents); |
273 browser = chrome::FindBrowserWithWebContents(new_contents); | 273 browser = chrome::FindBrowserWithWebContents(new_contents); |
274 | 274 |
275 if (browser && browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 275 if (browser && browser->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) |
276 return; | 276 return; |
277 | 277 |
278 ChromeLauncherController::AppState state = | 278 ChromeLauncherController::AppState state = |
279 ChromeLauncherController::APP_STATE_INACTIVE; | 279 ChromeLauncherController::APP_STATE_INACTIVE; |
280 | 280 |
281 // Update immediately on a tab change. | 281 // Update immediately on a tab change. |
282 if (old_contents && | 282 if (old_contents && |
283 (TabStripModel::kNoTab != | 283 (TabStripModel::kNoTab != |
284 browser->tab_strip_model()->GetIndexOfWebContents(old_contents))) | 284 browser->tab_strip_model()->GetIndexOfWebContents(old_contents))) |
285 UpdateAppItemState(old_contents, state); | 285 UpdateAppItemState(old_contents, state); |
286 | 286 |
287 if (new_contents) { | 287 if (new_contents) { |
288 state = browser->window()->IsActive() ? | 288 state = browser->window()->IsActive() ? |
289 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : | 289 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : |
290 ChromeLauncherController::APP_STATE_ACTIVE; | 290 ChromeLauncherController::APP_STATE_ACTIVE; |
291 UpdateAppItemState(new_contents, state); | 291 UpdateAppItemState(new_contents, state); |
292 UpdateBrowserItemState(); | 292 UpdateBrowserItemState(); |
293 SetShelfIDForBrowserWindowContents(browser, new_contents); | 293 SetShelfIDForBrowserWindowContents(browser, new_contents); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 void BrowserStatusMonitor::TabReplacedAt(TabStripModel* tab_strip_model, | 297 void BrowserStatusMonitor::TabReplacedAt(TabStripModel* tab_strip_model, |
298 content::WebContents* old_contents, | 298 content::WebContents* old_contents, |
299 content::WebContents* new_contents, | 299 content::WebContents* new_contents, |
300 int index) { | 300 int index) { |
301 DCHECK(old_contents && new_contents); | 301 DCHECK(old_contents && new_contents); |
302 Browser* browser = chrome::FindBrowserWithWebContents(new_contents); | 302 Browser* browser = chrome::FindBrowserWithWebContents(new_contents); |
303 | 303 |
304 if (browser && browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 304 if (browser && browser->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) |
305 return; | 305 return; |
306 | 306 |
307 UpdateAppItemState(old_contents, | 307 UpdateAppItemState(old_contents, |
308 ChromeLauncherController::APP_STATE_REMOVED); | 308 ChromeLauncherController::APP_STATE_REMOVED); |
309 RemoveWebContentsObserver(old_contents); | 309 RemoveWebContentsObserver(old_contents); |
310 | 310 |
311 ChromeLauncherController::AppState state = | 311 ChromeLauncherController::AppState state = |
312 ChromeLauncherController::APP_STATE_ACTIVE; | 312 ChromeLauncherController::APP_STATE_ACTIVE; |
313 if (browser->window()->IsActive() && | 313 if (browser->window()->IsActive() && |
314 (tab_strip_model->GetActiveWebContents() == new_contents)) | 314 (tab_strip_model->GetActiveWebContents() == new_contents)) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 content::WebContents* contents) { | 395 content::WebContents* contents) { |
396 return launcher_controller_->GetShelfIDForWebContents(contents); | 396 return launcher_controller_->GetShelfIDForWebContents(contents); |
397 } | 397 } |
398 | 398 |
399 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 399 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
400 Browser* browser, | 400 Browser* browser, |
401 content::WebContents* web_contents) { | 401 content::WebContents* web_contents) { |
402 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 402 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
403 SetShelfIDForBrowserWindowContents(browser, web_contents); | 403 SetShelfIDForBrowserWindowContents(browser, web_contents); |
404 } | 404 } |
OLD | NEW |