OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_launcher_controller_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
10 #include "ash/launcher/launcher_util.h" | 10 #include "ash/launcher/launcher_util.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 id_to_item_controller_map_[id] = controller; | 293 id_to_item_controller_map_[id] = controller; |
294 controller->set_launcher_id(id); | 294 controller->set_launcher_id(id); |
295 return id; | 295 return id; |
296 } | 296 } |
297 | 297 |
298 ash::LauncherID ChromeLauncherControllerPerApp::CreateAppLauncherItem( | 298 ash::LauncherID ChromeLauncherControllerPerApp::CreateAppLauncherItem( |
299 LauncherItemController* controller, | 299 LauncherItemController* controller, |
300 const std::string& app_id, | 300 const std::string& app_id, |
301 ash::LauncherItemStatus status) { | 301 ash::LauncherItemStatus status) { |
302 DCHECK(controller); | 302 DCHECK(controller); |
303 return InsertAppLauncherItem(controller, app_id, status, | 303 return InsertAppLauncherItem(controller, |
304 model_->item_count()); | 304 app_id, |
| 305 status, |
| 306 model_->item_count(), |
| 307 controller->GetLauncherItemType()); |
305 } | 308 } |
306 | 309 |
307 void ChromeLauncherControllerPerApp::SetItemStatus( | 310 void ChromeLauncherControllerPerApp::SetItemStatus( |
308 ash::LauncherID id, | 311 ash::LauncherID id, |
309 ash::LauncherItemStatus status) { | 312 ash::LauncherItemStatus status) { |
310 int index = model_->ItemIndexByID(id); | 313 int index = model_->ItemIndexByID(id); |
311 // Since ordinary browser windows are not registered, we might get a negative | 314 // Since ordinary browser windows are not registered, we might get a negative |
312 // index here. | 315 // index here. |
313 if (index >= 0) { | 316 if (index >= 0) { |
314 ash::LauncherItem item = model_->items()[index]; | 317 ash::LauncherItem item = model_->items()[index]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 350 } |
348 | 351 |
349 void ChromeLauncherControllerPerApp::Pin(ash::LauncherID id) { | 352 void ChromeLauncherControllerPerApp::Pin(ash::LauncherID id) { |
350 DCHECK(HasItemController(id)); | 353 DCHECK(HasItemController(id)); |
351 | 354 |
352 int index = model_->ItemIndexByID(id); | 355 int index = model_->ItemIndexByID(id); |
353 DCHECK_GE(index, 0); | 356 DCHECK_GE(index, 0); |
354 | 357 |
355 ash::LauncherItem item = model_->items()[index]; | 358 ash::LauncherItem item = model_->items()[index]; |
356 | 359 |
357 if (item.type != ash::TYPE_PLATFORM_APP) | 360 if (item.type == ash::TYPE_PLATFORM_APP || |
| 361 item.type == ash::TYPE_WINDOWED_APP) { |
| 362 item.type = ash::TYPE_APP_SHORTCUT; |
| 363 model_->Set(index, item); |
| 364 } else if (item.type != ash::TYPE_APP_SHORTCUT) { |
358 return; | 365 return; |
359 | 366 } |
360 item.type = ash::TYPE_APP_SHORTCUT; | |
361 model_->Set(index, item); | |
362 | 367 |
363 if (CanPin()) | 368 if (CanPin()) |
364 PersistPinnedState(); | 369 PersistPinnedState(); |
365 } | 370 } |
366 | 371 |
367 void ChromeLauncherControllerPerApp::Unpin(ash::LauncherID id) { | 372 void ChromeLauncherControllerPerApp::Unpin(ash::LauncherID id) { |
368 DCHECK(HasItemController(id)); | 373 DCHECK(HasItemController(id)); |
369 | 374 |
370 LauncherItemController* controller = id_to_item_controller_map_[id]; | 375 LauncherItemController* controller = id_to_item_controller_map_[id]; |
371 if (controller->type() == LauncherItemController::TYPE_APP) { | 376 if (controller->type() == LauncherItemController::TYPE_APP) { |
372 int index = model_->ItemIndexByID(id); | 377 int index = model_->ItemIndexByID(id); |
373 DCHECK_GE(index, 0); | 378 DCHECK_GE(index, 0); |
374 ash::LauncherItem item = model_->items()[index]; | 379 ash::LauncherItem item = model_->items()[index]; |
375 item.type = ash::TYPE_PLATFORM_APP; | 380 item.type = ash::TYPE_PLATFORM_APP; |
376 model_->Set(index, item); | 381 model_->Set(index, item); |
377 } else { | 382 } else { |
378 LauncherItemClosed(id); | 383 // Prevent the removal of items upon unpin if it is locked by a running |
| 384 // windowed V1 app. |
| 385 if (!controller->locked()) { |
| 386 LauncherItemClosed(id); |
| 387 } else { |
| 388 int index = model_->ItemIndexByID(id); |
| 389 DCHECK_GE(index, 0); |
| 390 ash::LauncherItem item = model_->items()[index]; |
| 391 item.type = ash::TYPE_WINDOWED_APP; |
| 392 model_->Set(index, item); |
| 393 } |
379 } | 394 } |
380 if (CanPin()) | 395 if (CanPin()) |
381 PersistPinnedState(); | 396 PersistPinnedState(); |
382 } | 397 } |
383 | 398 |
384 bool ChromeLauncherControllerPerApp::IsPinned(ash::LauncherID id) { | 399 bool ChromeLauncherControllerPerApp::IsPinned(ash::LauncherID id) { |
385 int index = model_->ItemIndexByID(id); | 400 int index = model_->ItemIndexByID(id); |
386 if (index < 0) | 401 if (index < 0) |
387 return false; | 402 return false; |
388 ash::LauncherItemType type = model_->items()[index].type; | 403 ash::LauncherItemType type = model_->items()[index].type; |
389 return type == ash::TYPE_APP_SHORTCUT; | 404 return type == ash::TYPE_APP_SHORTCUT; |
390 } | 405 } |
391 | 406 |
392 void ChromeLauncherControllerPerApp::TogglePinned(ash::LauncherID id) { | 407 void ChromeLauncherControllerPerApp::TogglePinned(ash::LauncherID id) { |
393 if (!HasItemController(id)) | 408 if (!HasItemController(id)) |
394 return; // May happen if item closed with menu open. | 409 return; // May happen if item closed with menu open. |
395 | 410 |
396 if (IsPinned(id)) | 411 if (IsPinned(id)) |
397 Unpin(id); | 412 Unpin(id); |
398 else | 413 else |
399 Pin(id); | 414 Pin(id); |
400 } | 415 } |
401 | 416 |
402 bool ChromeLauncherControllerPerApp::IsPinnable(ash::LauncherID id) const { | 417 bool ChromeLauncherControllerPerApp::IsPinnable(ash::LauncherID id) const { |
403 int index = model_->ItemIndexByID(id); | 418 int index = model_->ItemIndexByID(id); |
404 if (index == -1) | 419 if (index == -1) |
405 return false; | 420 return false; |
406 | 421 |
407 ash::LauncherItemType type = model_->items()[index].type; | 422 ash::LauncherItemType type = model_->items()[index].type; |
408 return ((type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_PLATFORM_APP) && | 423 return ((type == ash::TYPE_APP_SHORTCUT || |
| 424 type == ash::TYPE_PLATFORM_APP || |
| 425 type == ash::TYPE_WINDOWED_APP) && |
409 CanPin()); | 426 CanPin()); |
410 } | 427 } |
411 | 428 |
| 429 void ChromeLauncherControllerPerApp::LockV1AppWithID( |
| 430 const std::string& app_id) { |
| 431 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
| 432 if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) { |
| 433 CreateAppShortcutLauncherItemWithType(app_id, |
| 434 model_->item_count(), |
| 435 ash::TYPE_WINDOWED_APP); |
| 436 id = GetLauncherIDForAppID(app_id); |
| 437 } |
| 438 DCHECK(id); |
| 439 id_to_item_controller_map_[id]->lock(); |
| 440 } |
| 441 |
| 442 void ChromeLauncherControllerPerApp::UnlockV1AppWithID( |
| 443 const std::string& app_id) { |
| 444 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
| 445 DCHECK(IsPinned(id) || IsWindowedAppInLauncher(app_id)); |
| 446 DCHECK(id); |
| 447 LauncherItemController* controller = id_to_item_controller_map_[id]; |
| 448 controller->unlock(); |
| 449 if (!controller->locked() && !IsPinned(id)) |
| 450 CloseLauncherItem(id); |
| 451 } |
| 452 |
412 void ChromeLauncherControllerPerApp::Launch(ash::LauncherID id, | 453 void ChromeLauncherControllerPerApp::Launch(ash::LauncherID id, |
413 int event_flags) { | 454 int event_flags) { |
414 if (!HasItemController(id)) | 455 if (!HasItemController(id)) |
415 return; // In case invoked from menu and item closed while menu up. | 456 return; // In case invoked from menu and item closed while menu up. |
416 id_to_item_controller_map_[id]->Launch(event_flags); | 457 id_to_item_controller_map_[id]->Launch(event_flags); |
417 } | 458 } |
418 | 459 |
419 void ChromeLauncherControllerPerApp::Close(ash::LauncherID id) { | 460 void ChromeLauncherControllerPerApp::Close(ash::LauncherID id) { |
420 if (!HasItemController(id)) | 461 if (!HasItemController(id)) |
421 return; // May happen if menu closed. | 462 return; // May happen if menu closed. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 bool ChromeLauncherControllerPerApp::IsAppPinned(const std::string& app_id) { | 606 bool ChromeLauncherControllerPerApp::IsAppPinned(const std::string& app_id) { |
566 for (IDToItemControllerMap::const_iterator i = | 607 for (IDToItemControllerMap::const_iterator i = |
567 id_to_item_controller_map_.begin(); | 608 id_to_item_controller_map_.begin(); |
568 i != id_to_item_controller_map_.end(); ++i) { | 609 i != id_to_item_controller_map_.end(); ++i) { |
569 if (IsPinned(i->first) && i->second->app_id() == app_id) | 610 if (IsPinned(i->first) && i->second->app_id() == app_id) |
570 return true; | 611 return true; |
571 } | 612 } |
572 return false; | 613 return false; |
573 } | 614 } |
574 | 615 |
| 616 bool ChromeLauncherControllerPerApp::IsWindowedAppInLauncher( |
| 617 const std::string& app_id) { |
| 618 int index = model_->ItemIndexByID(GetLauncherIDForAppID(app_id)); |
| 619 if (index < 0) |
| 620 return false; |
| 621 |
| 622 ash::LauncherItemType type = model_->items()[index].type; |
| 623 return type == ash::TYPE_WINDOWED_APP; |
| 624 } |
| 625 |
575 void ChromeLauncherControllerPerApp::PinAppWithID(const std::string& app_id) { | 626 void ChromeLauncherControllerPerApp::PinAppWithID(const std::string& app_id) { |
576 if (CanPin()) | 627 if (CanPin()) |
577 DoPinAppWithID(app_id); | 628 DoPinAppWithID(app_id); |
578 else | 629 else |
579 NOTREACHED(); | 630 NOTREACHED(); |
580 } | 631 } |
581 | 632 |
582 void ChromeLauncherControllerPerApp::SetLaunchType( | 633 void ChromeLauncherControllerPerApp::SetLaunchType( |
583 ash::LauncherID id, | 634 ash::LauncherID id, |
584 extensions::ExtensionPrefs::LaunchType launch_type) { | 635 extensions::ExtensionPrefs::LaunchType launch_type) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 DCHECK(HasItemController(id)); | 824 DCHECK(HasItemController(id)); |
774 LauncherItemController* controller = id_to_item_controller_map_[id]; | 825 LauncherItemController* controller = id_to_item_controller_map_[id]; |
775 | 826 |
776 int index = model_->ItemIndexByID(id); | 827 int index = model_->ItemIndexByID(id); |
777 if (index == -1) { | 828 if (index == -1) { |
778 NOTREACHED() << "Invalid launcher id"; | 829 NOTREACHED() << "Invalid launcher id"; |
779 return; | 830 return; |
780 } | 831 } |
781 | 832 |
782 ash::LauncherItemType type = model_->items()[index].type; | 833 ash::LauncherItemType type = model_->items()[index].type; |
783 if (type == ash::TYPE_APP_SHORTCUT) { | 834 if (type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_WINDOWED_APP) { |
784 AppShortcutLauncherItemController* app_controller = | 835 AppShortcutLauncherItemController* app_controller = |
785 static_cast<AppShortcutLauncherItemController*>(controller); | 836 static_cast<AppShortcutLauncherItemController*>(controller); |
786 app_controller->set_refocus_url(url); | 837 app_controller->set_refocus_url(url); |
787 } else { | 838 } else { |
788 NOTREACHED() << "Invalid launcher type"; | 839 NOTREACHED() << "Invalid launcher type"; |
789 } | 840 } |
790 } | 841 } |
791 | 842 |
792 const Extension* ChromeLauncherControllerPerApp::GetExtensionForAppID( | 843 const Extension* ChromeLauncherControllerPerApp::GetExtensionForAppID( |
793 const std::string& app_id) { | 844 const std::string& app_id) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 } | 908 } |
858 // Coming here we are looking for the associated browser item as the default. | 909 // Coming here we are looking for the associated browser item as the default. |
859 int browser_index = ash::launcher::GetBrowserItemIndex(*model_); | 910 int browser_index = ash::launcher::GetBrowserItemIndex(*model_); |
860 // Note that there should always be a browser item in the launcher. | 911 // Note that there should always be a browser item in the launcher. |
861 DCHECK_GE(browser_index, 0); | 912 DCHECK_GE(browser_index, 0); |
862 return model_->items()[browser_index].id; | 913 return model_->items()[browser_index].id; |
863 } | 914 } |
864 | 915 |
865 bool ChromeLauncherControllerPerApp::IsDraggable( | 916 bool ChromeLauncherControllerPerApp::IsDraggable( |
866 const ash::LauncherItem& item) { | 917 const ash::LauncherItem& item) { |
867 return item.type == ash::TYPE_APP_SHORTCUT ? CanPin() : true; | 918 return (item.type == ash::TYPE_APP_SHORTCUT || |
| 919 item.type == ash::TYPE_WINDOWED_APP) ? CanPin() : true; |
868 } | 920 } |
869 | 921 |
870 void ChromeLauncherControllerPerApp::LauncherItemAdded(int index) { | 922 void ChromeLauncherControllerPerApp::LauncherItemAdded(int index) { |
871 } | 923 } |
872 | 924 |
873 void ChromeLauncherControllerPerApp::LauncherItemRemoved( | 925 void ChromeLauncherControllerPerApp::LauncherItemRemoved( |
874 int index, | 926 int index, |
875 ash::LauncherID id) { | 927 ash::LauncherID id) { |
876 } | 928 } |
877 | 929 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 void ChromeLauncherControllerPerApp::OnBrowserRemoved(Browser* browser) { | 1112 void ChromeLauncherControllerPerApp::OnBrowserRemoved(Browser* browser) { |
1061 // When called by a unit test it is possible that there is no shell. | 1113 // When called by a unit test it is possible that there is no shell. |
1062 // In that case, the following function should not get called. | 1114 // In that case, the following function should not get called. |
1063 if (ash::Shell::HasInstance()) | 1115 if (ash::Shell::HasInstance()) |
1064 UpdateBrowserItemStatus(); | 1116 UpdateBrowserItemStatus(); |
1065 } | 1117 } |
1066 | 1118 |
1067 ash::LauncherID ChromeLauncherControllerPerApp::CreateAppShortcutLauncherItem( | 1119 ash::LauncherID ChromeLauncherControllerPerApp::CreateAppShortcutLauncherItem( |
1068 const std::string& app_id, | 1120 const std::string& app_id, |
1069 int index) { | 1121 int index) { |
1070 AppShortcutLauncherItemController* controller = | 1122 return CreateAppShortcutLauncherItemWithType(app_id, |
1071 new AppShortcutLauncherItemController(app_id, this); | 1123 index, |
1072 ash::LauncherID launcher_id = InsertAppLauncherItem( | 1124 ash::TYPE_APP_SHORTCUT); |
1073 controller, app_id, ash::STATUS_CLOSED, index); | |
1074 return launcher_id; | |
1075 } | 1125 } |
1076 | 1126 |
1077 void ChromeLauncherControllerPerApp::SetAppTabHelperForTest( | 1127 void ChromeLauncherControllerPerApp::SetAppTabHelperForTest( |
1078 AppTabHelper* helper) { | 1128 AppTabHelper* helper) { |
1079 app_tab_helper_.reset(helper); | 1129 app_tab_helper_.reset(helper); |
1080 } | 1130 } |
1081 | 1131 |
1082 void ChromeLauncherControllerPerApp::SetAppIconLoaderForTest( | 1132 void ChromeLauncherControllerPerApp::SetAppIconLoaderForTest( |
1083 ash::AppIconLoader* loader) { | 1133 ash::AppIconLoader* loader) { |
1084 app_icon_loader_.reset(loader); | 1134 app_icon_loader_.reset(loader); |
1085 } | 1135 } |
1086 | 1136 |
1087 const std::string& | 1137 const std::string& |
1088 ChromeLauncherControllerPerApp::GetAppIdFromLauncherIdForTest( | 1138 ChromeLauncherControllerPerApp::GetAppIdFromLauncherIdForTest( |
1089 ash::LauncherID id) { | 1139 ash::LauncherID id) { |
1090 return id_to_item_controller_map_[id]->app_id(); | 1140 return id_to_item_controller_map_[id]->app_id(); |
1091 } | 1141 } |
1092 | 1142 |
| 1143 ash::LauncherID |
| 1144 ChromeLauncherControllerPerApp::CreateAppShortcutLauncherItemWithType( |
| 1145 const std::string& app_id, |
| 1146 int index, |
| 1147 ash::LauncherItemType launcher_item_type) { |
| 1148 AppShortcutLauncherItemController* controller = |
| 1149 new AppShortcutLauncherItemController(app_id, this); |
| 1150 ash::LauncherID launcher_id = InsertAppLauncherItem( |
| 1151 controller, app_id, ash::STATUS_CLOSED, index, launcher_item_type); |
| 1152 return launcher_id; |
| 1153 } |
| 1154 |
1093 void ChromeLauncherControllerPerApp::UpdateBrowserItemStatus() { | 1155 void ChromeLauncherControllerPerApp::UpdateBrowserItemStatus() { |
1094 // Determine the new browser's active state and change if necessary. | 1156 // Determine the new browser's active state and change if necessary. |
1095 int browser_index = ash::launcher::GetBrowserItemIndex(*model_); | 1157 int browser_index = ash::launcher::GetBrowserItemIndex(*model_); |
1096 DCHECK(browser_index >= 0); | 1158 DCHECK(browser_index >= 0); |
1097 ash::LauncherItem browser_item = model_->items()[browser_index]; | 1159 ash::LauncherItem browser_item = model_->items()[browser_index]; |
1098 ash::LauncherItemStatus browser_status = browser_item.status; | 1160 ash::LauncherItemStatus browser_status = browser_item.status; |
1099 // See if the active window is a browser. | 1161 // See if the active window is a browser. |
1100 aura::Window* window = ash::wm::GetActiveWindow(); | 1162 aura::Window* window = ash::wm::GetActiveWindow(); |
1101 if (window && chrome::FindBrowserWithWindow(window)) { | 1163 if (window && chrome::FindBrowserWithWindow(window)) { |
1102 browser_status = ash::STATUS_ACTIVE; | 1164 browser_status = ash::STATUS_ACTIVE; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 if (i == app_id_to_web_contents_list_.end()) | 1372 if (i == app_id_to_web_contents_list_.end()) |
1311 return NULL; | 1373 return NULL; |
1312 DCHECK_GT(i->second.size(), 0u); | 1374 DCHECK_GT(i->second.size(), 0u); |
1313 return *i->second.begin(); | 1375 return *i->second.begin(); |
1314 } | 1376 } |
1315 | 1377 |
1316 ash::LauncherID ChromeLauncherControllerPerApp::InsertAppLauncherItem( | 1378 ash::LauncherID ChromeLauncherControllerPerApp::InsertAppLauncherItem( |
1317 LauncherItemController* controller, | 1379 LauncherItemController* controller, |
1318 const std::string& app_id, | 1380 const std::string& app_id, |
1319 ash::LauncherItemStatus status, | 1381 ash::LauncherItemStatus status, |
1320 int index) { | 1382 int index, |
| 1383 ash::LauncherItemType launcher_item_type) { |
1321 ash::LauncherID id = model_->next_id(); | 1384 ash::LauncherID id = model_->next_id(); |
1322 DCHECK(!HasItemController(id)); | 1385 DCHECK(!HasItemController(id)); |
1323 DCHECK(controller); | 1386 DCHECK(controller); |
1324 id_to_item_controller_map_[id] = controller; | 1387 id_to_item_controller_map_[id] = controller; |
1325 controller->set_launcher_id(id); | 1388 controller->set_launcher_id(id); |
1326 | 1389 |
1327 ash::LauncherItem item; | 1390 ash::LauncherItem item; |
1328 item.type = controller->GetLauncherItemType(); | 1391 item.type = launcher_item_type; |
1329 item.is_incognito = false; | 1392 item.is_incognito = false; |
1330 item.image = Extension::GetDefaultIcon(true); | 1393 item.image = Extension::GetDefaultIcon(true); |
1331 | 1394 |
1332 WebContents* active_tab = GetLastActiveWebContents(app_id); | 1395 WebContents* active_tab = GetLastActiveWebContents(app_id); |
1333 if (active_tab) { | 1396 if (active_tab) { |
1334 Browser* browser = chrome::FindBrowserWithWebContents(active_tab); | 1397 Browser* browser = chrome::FindBrowserWithWebContents(active_tab); |
1335 DCHECK(browser); | 1398 DCHECK(browser); |
1336 if (browser->window()->IsActive()) | 1399 if (browser->window()->IsActive()) |
1337 status = ash::STATUS_ACTIVE; | 1400 status = ash::STATUS_ACTIVE; |
1338 else | 1401 else |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), NULL)); | 1436 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), NULL)); |
1374 const chrome::BrowserListImpl* ash_browser_list = | 1437 const chrome::BrowserListImpl* ash_browser_list = |
1375 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 1438 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
1376 int index = 1; | 1439 int index = 1; |
1377 for (chrome::BrowserListImpl::const_reverse_iterator it = | 1440 for (chrome::BrowserListImpl::const_reverse_iterator it = |
1378 ash_browser_list->begin_last_active(); | 1441 ash_browser_list->begin_last_active(); |
1379 it != ash_browser_list->end_last_active(); ++it, ++index) { | 1442 it != ash_browser_list->end_last_active(); ++it, ++index) { |
1380 Browser* browser = *it; | 1443 Browser* browser = *it; |
1381 if (browser->is_type_tabbed()) | 1444 if (browser->is_type_tabbed()) |
1382 found_tabbed_browser = true; | 1445 found_tabbed_browser = true; |
| 1446 else if (browser->is_app() && |
| 1447 browser->is_type_popup() && |
| 1448 GetLauncherIDForAppID(web_app::GetExtensionIdFromApplicationName( |
| 1449 browser->app_name())) > 0) |
| 1450 continue; |
1383 TabStripModel* tab_strip = browser->tab_strip_model(); | 1451 TabStripModel* tab_strip = browser->tab_strip_model(); |
1384 WebContents* web_contents = | 1452 WebContents* web_contents = |
1385 tab_strip->GetWebContentsAt(tab_strip->active_index()); | 1453 tab_strip->GetWebContentsAt(tab_strip->active_index()); |
1386 gfx::Image app_icon = GetAppListIcon(web_contents); | 1454 gfx::Image app_icon = GetAppListIcon(web_contents); |
1387 items.push_back(new ChromeLauncherAppMenuItemBrowser( | 1455 items.push_back(new ChromeLauncherAppMenuItemBrowser( |
1388 web_contents->GetTitle(), | 1456 web_contents->GetTitle(), |
1389 app_icon.IsEmpty() ? NULL : &app_icon, | 1457 app_icon.IsEmpty() ? NULL : &app_icon, |
1390 browser)); | 1458 browser)); |
1391 } | 1459 } |
1392 // If only windowed applications are open, we return an empty list to | 1460 // If only windowed applications are open, we return an empty list to |
1393 // enforce the creation of a new browser. | 1461 // enforce the creation of a new browser. |
1394 if (!found_tabbed_browser) | 1462 if (!found_tabbed_browser) |
1395 items.clear(); | 1463 items.clear(); |
1396 return items.Pass(); | 1464 return items.Pass(); |
1397 } | 1465 } |
OLD | NEW |