| 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/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
| 10 #include "ash/shelf/shelf_util.h" | 10 #include "ash/shelf/shelf_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // of settings browsers (which will not be valid during chrome::Navigate | 51 // of settings browsers (which will not be valid during chrome::Navigate |
| 52 // which is why we still need the above test). | 52 // which is why we still need the above test). |
| 53 if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(browser)) | 53 if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(browser)) |
| 54 return true; | 54 return true; |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController( | 60 BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController( |
| 61 ChromeLauncherController* launcher_controller) | 61 ChromeLauncherController* launcher_controller, |
| 62 ash::ShelfModel* shelf_model) |
| 62 : LauncherItemController(TYPE_SHORTCUT, | 63 : LauncherItemController(TYPE_SHORTCUT, |
| 63 extension_misc::kChromeAppId, | 64 extension_misc::kChromeAppId, |
| 64 launcher_controller) { | 65 launcher_controller), |
| 65 } | 66 shelf_model_(shelf_model) {} |
| 66 | 67 |
| 67 BrowserShortcutLauncherItemController:: | 68 BrowserShortcutLauncherItemController:: |
| 68 ~BrowserShortcutLauncherItemController() { | 69 ~BrowserShortcutLauncherItemController() { |
| 69 } | 70 } |
| 70 | 71 |
| 71 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { | 72 void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { |
| 72 // The shell will not be available for win7_aura unittests like | 73 // The shell will not be available for win7_aura unittests like |
| 73 // ChromeLauncherControllerTest.BrowserMenuGeneration. | 74 // ChromeLauncherControllerTest.BrowserMenuGeneration. |
| 74 if (!ash::Shell::HasInstance()) | 75 if (!ash::Shell::HasInstance()) |
| 75 return; | 76 return; |
| 76 | 77 |
| 77 ash::ShelfModel* model = launcher_controller()->model(); | |
| 78 | |
| 79 // Determine the new browser's active state and change if necessary. | 78 // Determine the new browser's active state and change if necessary. |
| 80 int browser_index = model->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); | 79 int browser_index = |
| 80 shelf_model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); |
| 81 DCHECK_GE(browser_index, 0); | 81 DCHECK_GE(browser_index, 0); |
| 82 ash::ShelfItem browser_item = model->items()[browser_index]; | 82 ash::ShelfItem browser_item = shelf_model_->items()[browser_index]; |
| 83 ash::ShelfItemStatus browser_status = ash::STATUS_CLOSED; | 83 ash::ShelfItemStatus browser_status = ash::STATUS_CLOSED; |
| 84 | 84 |
| 85 aura::Window* window = ash::wm::GetActiveWindow(); | 85 aura::Window* window = ash::wm::GetActiveWindow(); |
| 86 if (window) { | 86 if (window) { |
| 87 // Check if the active browser / tab is a browser which is not an app, | 87 // Check if the active browser / tab is a browser which is not an app, |
| 88 // a windowed app, a popup or any other item which is not a browser of | 88 // a windowed app, a popup or any other item which is not a browser of |
| 89 // interest. | 89 // interest. |
| 90 Browser* browser = chrome::FindBrowserWithWindow(window); | 90 Browser* browser = chrome::FindBrowserWithWindow(window); |
| 91 if (IsBrowserRepresentedInBrowserList(browser)) { | 91 if (IsBrowserRepresentedInBrowserList(browser)) { |
| 92 browser_status = ash::STATUS_ACTIVE; | 92 browser_status = ash::STATUS_ACTIVE; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 108 it != browser_list->end_last_active() && | 108 it != browser_list->end_last_active() && |
| 109 browser_status == ash::STATUS_CLOSED; | 109 browser_status == ash::STATUS_CLOSED; |
| 110 ++it) { | 110 ++it) { |
| 111 if (IsBrowserRepresentedInBrowserList(*it)) | 111 if (IsBrowserRepresentedInBrowserList(*it)) |
| 112 browser_status = ash::STATUS_RUNNING; | 112 browser_status = ash::STATUS_RUNNING; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (browser_status != browser_item.status) { | 116 if (browser_status != browser_item.status) { |
| 117 browser_item.status = browser_status; | 117 browser_item.status = browser_status; |
| 118 model->Set(browser_index, browser_item); | 118 shelf_model_->Set(browser_index, browser_item); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents( | 122 void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents( |
| 123 Browser* browser, | 123 Browser* browser, |
| 124 content::WebContents* web_contents) { | 124 content::WebContents* web_contents) { |
| 125 // We need to call SetShelfIDForWindow for V1 applications since they are | 125 // We need to call SetShelfIDForWindow for V1 applications since they are |
| 126 // content which might change and as such change the application type. | 126 // content which might change and as such change the application type. |
| 127 if (!browser || !launcher_controller()->IsBrowserFromActiveUser(browser) || | 127 if (!browser || !launcher_controller()->IsBrowserFromActiveUser(browser) || |
| 128 IsSettingsBrowser(browser)) | 128 IsSettingsBrowser(browser)) |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 !browser->window()->IsMinimized()) { | 365 !browser->window()->IsMinimized()) { |
| 366 continue; | 366 continue; |
| 367 } | 367 } |
| 368 if (!IsBrowserRepresentedInBrowserList(browser) && | 368 if (!IsBrowserRepresentedInBrowserList(browser) && |
| 369 !browser->is_type_tabbed()) | 369 !browser->is_type_tabbed()) |
| 370 continue; | 370 continue; |
| 371 active_browsers.push_back(browser); | 371 active_browsers.push_back(browser); |
| 372 } | 372 } |
| 373 return active_browsers; | 373 return active_browsers; |
| 374 } | 374 } |
| OLD | NEW |