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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) { | 206 void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) { |
207 // Remove RootWindow and its ActivationClient from observed list. | 207 // Remove RootWindow and its ActivationClient from observed list. |
208 observed_root_windows_.Remove(window); | 208 observed_root_windows_.Remove(window); |
209 observed_activation_clients_.Remove( | 209 observed_activation_clients_.Remove( |
210 aura::client::GetActivationClient(window)); | 210 aura::client::GetActivationClient(window)); |
211 } | 211 } |
212 | 212 |
213 bool BrowserStatusMonitor::ShouldTrackBrowser(Browser* browser) { | 213 bool BrowserStatusMonitor::ShouldTrackBrowser(Browser* browser) { |
214 return browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH; | 214 return true; |
215 } | 215 } |
216 | 216 |
217 void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) { | 217 void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) { |
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 } | 223 } |
224 } | 224 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, | 259 void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents, |
260 content::WebContents* new_contents, | 260 content::WebContents* new_contents, |
261 int index, | 261 int index, |
262 int reason) { | 262 int reason) { |
263 Browser* browser = NULL; | 263 Browser* browser = NULL; |
264 // Use |new_contents|. |old_contents| could be NULL. | 264 // Use |new_contents|. |old_contents| could be NULL. |
265 DCHECK(new_contents); | 265 DCHECK(new_contents); |
266 browser = chrome::FindBrowserWithWebContents(new_contents); | 266 browser = chrome::FindBrowserWithWebContents(new_contents); |
267 | 267 |
268 if (browser && browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | |
269 return; | |
270 | |
271 ChromeLauncherController::AppState state = | 268 ChromeLauncherController::AppState state = |
272 ChromeLauncherController::APP_STATE_INACTIVE; | 269 ChromeLauncherController::APP_STATE_INACTIVE; |
273 | 270 |
274 // Update immediately on a tab change. | 271 // Update immediately on a tab change. |
275 if (old_contents && | 272 if (old_contents && |
276 (TabStripModel::kNoTab != | 273 (TabStripModel::kNoTab != |
277 browser->tab_strip_model()->GetIndexOfWebContents(old_contents))) | 274 browser->tab_strip_model()->GetIndexOfWebContents(old_contents))) |
278 UpdateAppItemState(old_contents, state); | 275 UpdateAppItemState(old_contents, state); |
279 | 276 |
280 if (new_contents) { | 277 if (new_contents) { |
281 state = browser->window()->IsActive() ? | 278 state = browser->window()->IsActive() ? |
282 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : | 279 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : |
283 ChromeLauncherController::APP_STATE_ACTIVE; | 280 ChromeLauncherController::APP_STATE_ACTIVE; |
284 UpdateAppItemState(new_contents, state); | 281 UpdateAppItemState(new_contents, state); |
285 UpdateBrowserItemState(); | 282 UpdateBrowserItemState(); |
286 SetShelfIDForBrowserWindowContents(browser, new_contents); | 283 SetShelfIDForBrowserWindowContents(browser, new_contents); |
287 } | 284 } |
288 } | 285 } |
289 | 286 |
290 void BrowserStatusMonitor::TabReplacedAt(TabStripModel* tab_strip_model, | 287 void BrowserStatusMonitor::TabReplacedAt(TabStripModel* tab_strip_model, |
291 content::WebContents* old_contents, | 288 content::WebContents* old_contents, |
292 content::WebContents* new_contents, | 289 content::WebContents* new_contents, |
293 int index) { | 290 int index) { |
294 DCHECK(old_contents && new_contents); | 291 DCHECK(old_contents && new_contents); |
295 Browser* browser = chrome::FindBrowserWithWebContents(new_contents); | 292 Browser* browser = chrome::FindBrowserWithWebContents(new_contents); |
296 | 293 |
297 if (browser && browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | |
298 return; | |
299 | |
300 UpdateAppItemState(old_contents, | 294 UpdateAppItemState(old_contents, |
301 ChromeLauncherController::APP_STATE_REMOVED); | 295 ChromeLauncherController::APP_STATE_REMOVED); |
302 RemoveWebContentsObserver(old_contents); | 296 RemoveWebContentsObserver(old_contents); |
303 | 297 |
304 ChromeLauncherController::AppState state = | 298 ChromeLauncherController::AppState state = |
305 ChromeLauncherController::APP_STATE_ACTIVE; | 299 ChromeLauncherController::APP_STATE_ACTIVE; |
306 if (browser->window()->IsActive() && | 300 if (browser->window()->IsActive() && |
307 (tab_strip_model->GetActiveWebContents() == new_contents)) | 301 (tab_strip_model->GetActiveWebContents() == new_contents)) |
308 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; | 302 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; |
309 UpdateAppItemState(new_contents, state); | 303 UpdateAppItemState(new_contents, state); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 content::WebContents* contents) { | 378 content::WebContents* contents) { |
385 return launcher_controller_->GetShelfIDForWebContents(contents); | 379 return launcher_controller_->GetShelfIDForWebContents(contents); |
386 } | 380 } |
387 | 381 |
388 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 382 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
389 Browser* browser, | 383 Browser* browser, |
390 content::WebContents* web_contents) { | 384 content::WebContents* web_contents) { |
391 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 385 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
392 SetShelfIDForBrowserWindowContents(browser, web_contents); | 386 SetShelfIDForBrowserWindowContents(browser, web_contents); |
393 } | 387 } |
OLD | NEW |