| 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/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
| 10 #include "ash/shelf/shelf_model.h" | 10 #include "ash/shelf/shelf_model.h" |
| 11 #include "ash/shelf/shelf_model_util.h" | |
| 12 #include "ash/shelf/shelf_util.h" | 11 #include "ash/shelf/shelf_util.h" |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #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" |
| 17 #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
" |
| 18 #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" |
| 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 20 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 19 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 20 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 53 |
| 55 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { | 54 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { |
| 56 // The shell will not be available for win7_aura unittests like | 55 // The shell will not be available for win7_aura unittests like |
| 57 // ChromeLauncherControllerTest.BrowserMenuGeneration. | 56 // ChromeLauncherControllerTest.BrowserMenuGeneration. |
| 58 if (!ash::Shell::HasInstance()) | 57 if (!ash::Shell::HasInstance()) |
| 59 return; | 58 return; |
| 60 | 59 |
| 61 ash::ShelfModel* model = launcher_controller()->model(); | 60 ash::ShelfModel* model = launcher_controller()->model(); |
| 62 | 61 |
| 63 // Determine the new browser's active state and change if necessary. | 62 // Determine the new browser's active state and change if necessary. |
| 64 int browser_index = | 63 int browser_index = model->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); |
| 65 ash::GetShelfItemIndexForType(ash::TYPE_BROWSER_SHORTCUT, *model); | |
| 66 DCHECK_GE(browser_index, 0); | 64 DCHECK_GE(browser_index, 0); |
| 67 ash::LauncherItem browser_item = model->items()[browser_index]; | 65 ash::LauncherItem browser_item = model->items()[browser_index]; |
| 68 ash::LauncherItemStatus browser_status = ash::STATUS_CLOSED; | 66 ash::LauncherItemStatus browser_status = ash::STATUS_CLOSED; |
| 69 | 67 |
| 70 aura::Window* window = ash::wm::GetActiveWindow(); | 68 aura::Window* window = ash::wm::GetActiveWindow(); |
| 71 if (window) { | 69 if (window) { |
| 72 // Check if the active browser / tab is a browser which is not an app, | 70 // Check if the active browser / tab is a browser which is not an app, |
| 73 // a windowed app, a popup or any other item which is not a browser of | 71 // a windowed app, a popup or any other item which is not a browser of |
| 74 // interest. | 72 // interest. |
| 75 Browser* browser = chrome::FindBrowserWithWindow(window); | 73 Browser* browser = chrome::FindBrowserWithWindow(window); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return (browser && | 328 return (browser && |
| 331 launcher_controller()->IsBrowserFromActiveUser(browser) && | 329 launcher_controller()->IsBrowserFromActiveUser(browser) && |
| 332 browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | 330 browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && |
| 333 (browser->is_type_tabbed() || | 331 (browser->is_type_tabbed() || |
| 334 !browser->is_app() || | 332 !browser->is_app() || |
| 335 !browser->is_type_popup() || | 333 !browser->is_type_popup() || |
| 336 launcher_controller()-> | 334 launcher_controller()-> |
| 337 GetLauncherIDForAppID(web_app::GetExtensionIdFromApplicationName( | 335 GetLauncherIDForAppID(web_app::GetExtensionIdFromApplicationName( |
| 338 browser->app_name())) <= 0)); | 336 browser->app_name())) <= 0)); |
| 339 } | 337 } |
| OLD | NEW |