| 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 <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 browser->window()->Activate(); | 351 browser->window()->Activate(); |
| 352 return ash::SHELF_ACTION_WINDOW_ACTIVATED; | 352 return ash::SHELF_ACTION_WINDOW_ACTIVATED; |
| 353 } | 353 } |
| 354 | 354 |
| 355 bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList( | 355 bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList( |
| 356 Browser* browser) { | 356 Browser* browser) { |
| 357 // Only Ash desktop browser windows for the active user are represented. | 357 // Only Ash desktop browser windows for the active user are represented. |
| 358 if (!browser || !IsBrowserFromActiveUser(browser)) | 358 if (!browser || !IsBrowserFromActiveUser(browser)) |
| 359 return false; | 359 return false; |
| 360 | 360 |
| 361 // v1 App popup windows with a valid app id have their own icon. | 361 // V1 App popup windows may have their own item. |
| 362 if (browser->is_app() && browser->is_type_popup() && | 362 if (browser->is_app() && browser->is_type_popup()) { |
| 363 !shelf_model_ | 363 ash::ShelfID id( |
| 364 ->GetShelfIDForAppID( | 364 web_app::GetExtensionIdFromApplicationName(browser->app_name())); |
| 365 web_app::GetExtensionIdFromApplicationName(browser->app_name())) | 365 if (ChromeLauncherController::instance()->GetItem(id) != nullptr) |
| 366 .IsNull()) { | 366 return false; |
| 367 return false; | |
| 368 } | 367 } |
| 369 | 368 |
| 370 // Settings browsers have their own icon. | 369 // Settings browsers have their own item; all others should be represented. |
| 371 if (IsSettingsBrowser(browser)) | 370 return !IsSettingsBrowser(browser); |
| 372 return false; | |
| 373 | |
| 374 // Tabbed browser and other popup windows are all represented. | |
| 375 return true; | |
| 376 } | 371 } |
| 377 | 372 |
| 378 BrowserList::BrowserVector | 373 BrowserList::BrowserVector |
| 379 BrowserShortcutLauncherItemController::GetListOfActiveBrowsers() { | 374 BrowserShortcutLauncherItemController::GetListOfActiveBrowsers() { |
| 380 BrowserList::BrowserVector active_browsers; | 375 BrowserList::BrowserVector active_browsers; |
| 381 for (auto* browser : *BrowserList::GetInstance()) { | 376 for (auto* browser : *BrowserList::GetInstance()) { |
| 382 // Make sure that the browser is from the current user, has a proper window, | 377 // Make sure that the browser is from the current user, has a proper window, |
| 383 // and the window was already shown. | 378 // and the window was already shown. |
| 384 if (!IsBrowserFromActiveUser(browser)) | 379 if (!IsBrowserFromActiveUser(browser)) |
| 385 continue; | 380 continue; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 403 Browser* browser = content::Source<Browser>(source).ptr(); | 398 Browser* browser = content::Source<Browser>(source).ptr(); |
| 404 DCHECK(browser); | 399 DCHECK(browser); |
| 405 BrowserList::BrowserVector::iterator item = std::find( | 400 BrowserList::BrowserVector::iterator item = std::find( |
| 406 browser_menu_items_.begin(), browser_menu_items_.end(), browser); | 401 browser_menu_items_.begin(), browser_menu_items_.end(), browser); |
| 407 DCHECK(item != browser_menu_items_.end()); | 402 DCHECK(item != browser_menu_items_.end()); |
| 408 // Clear the entry for the closed browser and leave other indices intact. | 403 // Clear the entry for the closed browser and leave other indices intact. |
| 409 *item = nullptr; | 404 *item = nullptr; |
| 410 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 405 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
| 411 content::Source<Browser>(browser)); | 406 content::Source<Browser>(browser)); |
| 412 } | 407 } |
| OLD | NEW |