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