| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_shortcut_launcher_item_controll
er.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/common/shelf/shelf_delegate.h" |
| 9 #include "ash/common/shelf/shelf_model.h" | 10 #include "ash/common/shelf/shelf_model.h" |
| 10 #include "ash/shelf/shelf_delegate.h" | 11 #include "ash/common/wm_shell.h" |
| 11 #include "ash/shelf/shelf_util.h" | 12 #include "ash/shelf/shelf_util.h" |
| 12 #include "ash/shell.h" | |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" | 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" |
| 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 20 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 20 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 : LauncherItemController(TYPE_SHORTCUT, | 65 : LauncherItemController(TYPE_SHORTCUT, |
| 66 extension_misc::kChromeAppId, | 66 extension_misc::kChromeAppId, |
| 67 launcher_controller), | 67 launcher_controller), |
| 68 shelf_model_(shelf_model) {} | 68 shelf_model_(shelf_model) {} |
| 69 | 69 |
| 70 BrowserShortcutLauncherItemController:: | 70 BrowserShortcutLauncherItemController:: |
| 71 ~BrowserShortcutLauncherItemController() { | 71 ~BrowserShortcutLauncherItemController() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { | 74 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { |
| 75 // The shell will not be available for win7_aura unittests like | |
| 76 // ChromeLauncherControllerTest.BrowserMenuGeneration. | |
| 77 if (!ash::Shell::HasInstance()) | |
| 78 return; | |
| 79 | |
| 80 // Determine the new browser's active state and change if necessary. | 75 // Determine the new browser's active state and change if necessary. |
| 81 int browser_index = | 76 int browser_index = |
| 82 shelf_model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); | 77 shelf_model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); |
| 83 DCHECK_GE(browser_index, 0); | 78 DCHECK_GE(browser_index, 0); |
| 84 ash::ShelfItem browser_item = shelf_model_->items()[browser_index]; | 79 ash::ShelfItem browser_item = shelf_model_->items()[browser_index]; |
| 85 ash::ShelfItemStatus browser_status = ash::STATUS_CLOSED; | 80 ash::ShelfItemStatus browser_status = ash::STATUS_CLOSED; |
| 86 | 81 |
| 87 aura::Window* window = ash::wm::GetActiveWindow(); | 82 aura::Window* window = ash::wm::GetActiveWindow(); |
| 88 if (window) { | 83 if (window) { |
| 89 // Check if the active browser / tab is a browser which is not an app, | 84 // Check if the active browser / tab is a browser which is not an app, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return kExistingWindowActivated; | 326 return kExistingWindowActivated; |
| 332 } | 327 } |
| 333 | 328 |
| 334 bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList( | 329 bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList( |
| 335 Browser* browser) { | 330 Browser* browser) { |
| 336 // Only Ash desktop browser windows for the active user are represented. | 331 // Only Ash desktop browser windows for the active user are represented. |
| 337 if (!browser || !IsBrowserFromActiveUser(browser)) | 332 if (!browser || !IsBrowserFromActiveUser(browser)) |
| 338 return false; | 333 return false; |
| 339 | 334 |
| 340 // v1 App popup windows with a valid app id have their own icon. | 335 // v1 App popup windows with a valid app id have their own icon. |
| 341 if (browser->is_app() && | 336 if (browser->is_app() && browser->is_type_popup() && |
| 342 browser->is_type_popup() && | 337 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppID( |
| 343 ash::Shell::GetInstance()->GetShelfDelegate()->GetShelfIDForAppID( | |
| 344 web_app::GetExtensionIdFromApplicationName(browser->app_name())) > 0) | 338 web_app::GetExtensionIdFromApplicationName(browser->app_name())) > 0) |
| 345 return false; | 339 return false; |
| 346 | 340 |
| 347 // Settings browsers have their own icon. | 341 // Settings browsers have their own icon. |
| 348 if (IsSettingsBrowser(browser)) | 342 if (IsSettingsBrowser(browser)) |
| 349 return false; | 343 return false; |
| 350 | 344 |
| 351 // Tabbed browser and other popup windows are all represented. | 345 // Tabbed browser and other popup windows are all represented. |
| 352 return true; | 346 return true; |
| 353 } | 347 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 364 !browser->window()->IsMinimized()) { | 358 !browser->window()->IsMinimized()) { |
| 365 continue; | 359 continue; |
| 366 } | 360 } |
| 367 if (!IsBrowserRepresentedInBrowserList(browser) && | 361 if (!IsBrowserRepresentedInBrowserList(browser) && |
| 368 !browser->is_type_tabbed()) | 362 !browser->is_type_tabbed()) |
| 369 continue; | 363 continue; |
| 370 active_browsers.push_back(browser); | 364 active_browsers.push_back(browser); |
| 371 } | 365 } |
| 372 return active_browsers; | 366 return active_browsers; |
| 373 } | 367 } |
| OLD | NEW |