OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/toolbar/recent_tabs_sub_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 auto& tab = | 457 auto& tab = |
458 static_cast<const sessions::TabRestoreService::Tab&>(*entry); | 458 static_cast<const sessions::TabRestoreService::Tab&>(*entry); |
459 const sessions::SerializedNavigationEntry& current_navigation = | 459 const sessions::SerializedNavigationEntry& current_navigation = |
460 tab.navigations.at(tab.current_navigation_index); | 460 tab.navigations.at(tab.current_navigation_index); |
461 BuildLocalTabItem(entry->id, current_navigation.title(), | 461 BuildLocalTabItem(entry->id, current_navigation.title(), |
462 current_navigation.virtual_url(), | 462 current_navigation.virtual_url(), |
463 ++last_local_model_index_); | 463 ++last_local_model_index_); |
464 break; | 464 break; |
465 } | 465 } |
466 case sessions::TabRestoreService::WINDOW: { | 466 case sessions::TabRestoreService::WINDOW: { |
467 BuildLocalWindowItem( | 467 auto& window = |
468 entry->id, | 468 static_cast<const sessions::TabRestoreService::Window&>(*entry); |
469 static_cast<const sessions::TabRestoreService::Window&>(*entry) | 469 // Generate a window entry if the window contained more than 1 tab. |
470 .tabs.size(), | 470 if (window.tabs.size() > 1) { |
sky
2017/05/08 22:51:36
We shouldn't need the special case here. Whether y
chrisha
2017/05/09 15:44:54
Moved this discussion to the bug, as it's slightly
| |
471 ++last_local_model_index_); | 471 BuildLocalWindowItem(entry->id, window.tabs.size(), |
472 ++last_local_model_index_); | |
473 } else { | |
474 // Otherwise, generate a tab entry. This fixes | |
475 // http://crbug.com/56744. | |
476 auto& tab = *window.tabs[0]; | |
477 const sessions::SerializedNavigationEntry& current_navigation = | |
478 tab.navigations.at(tab.current_navigation_index); | |
479 BuildLocalTabItem(entry->id, current_navigation.title(), | |
480 current_navigation.virtual_url(), | |
481 ++last_local_model_index_); | |
482 } | |
472 break; | 483 break; |
473 } | 484 } |
474 } | 485 } |
475 ++added_count; | 486 ++added_count; |
476 } | 487 } |
477 } | 488 } |
478 DCHECK_GE(last_local_model_index_, 0); | 489 DCHECK_GE(last_local_model_index_, 0); |
479 } | 490 } |
480 | 491 |
481 void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() { | 492 void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 void RecentTabsSubMenuModel::OnForeignSessionUpdated( | 772 void RecentTabsSubMenuModel::OnForeignSessionUpdated( |
762 syncer::SyncService* sync) { | 773 syncer::SyncService* sync) { |
763 ClearTabsFromOtherDevices(); | 774 ClearTabsFromOtherDevices(); |
764 | 775 |
765 BuildTabsFromOtherDevices(); | 776 BuildTabsFromOtherDevices(); |
766 | 777 |
767 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); | 778 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); |
768 if (menu_model_delegate) | 779 if (menu_model_delegate) |
769 menu_model_delegate->OnMenuStructureChanged(); | 780 menu_model_delegate->OnMenuStructureChanged(); |
770 } | 781 } |
OLD | NEW |