Chromium Code Reviews| Index: chrome/browser/ui/cocoa/history_menu_bridge.mm |
| diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm |
| index 82ac3853c6eb2becf5fd4f9750b4dc760498e5c8..f318fa77823a5c07149682fe17db7c21b0a0b3db 100644 |
| --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm |
| +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm |
| @@ -137,16 +137,15 @@ void HistoryMenuBridge::TabRestoreServiceChanged( |
| NSInteger index = [menu indexOfItemWithTag:kRecentlyClosedTitle] + 1; |
| NSUInteger added_count = 0; |
| - for (sessions::TabRestoreService::Entries::const_iterator it = |
| - entries.begin(); |
| - it != entries.end() && added_count < kRecentlyClosedCount; ++it) { |
| - sessions::TabRestoreService::Entry* entry = *it; |
| - |
| + for (const auto &entry : entries) { |
| + if (added_count >= kRecentlyClosedCount) { |
|
sky
2016/08/02 23:12:30
no {}
Sidney San Martín
2016/08/03 14:35:31
Done. Not used to this style yet :).
|
| + break; |
| + } |
| // If this is a window, create a submenu for all of its tabs. |
| - if (entry->type == sessions::TabRestoreService::WINDOW) { |
| - sessions::TabRestoreService::Window* entry_win = |
| - (sessions::TabRestoreService::Window*)entry; |
| - std::vector<sessions::TabRestoreService::Tab>& tabs = entry_win->tabs; |
| + if (entry->type() == sessions::TabRestoreService::WINDOW) { |
| + const auto& entry_win = |
| + static_cast<sessions::TabRestoreService::Window&>(*entry); |
| + const auto &tabs = entry_win.tabs; |
|
sky
2016/08/02 23:12:30
'auto &' -> 'auto&' that said, in this case I woul
Sidney San Martín
2016/08/03 14:35:31
Done. However, the full type name is a little long
|
| if (tabs.empty()) |
| continue; |
| @@ -155,7 +154,7 @@ void HistoryMenuBridge::TabRestoreServiceChanged( |
| // things like the NTP are filtered out, which is done when the tab items |
| // are actually created. |
| HistoryItem* item = new HistoryItem(); |
| - item->session_id = entry_win->id; |
| + item->session_id = entry_win.id; |
| // Create the submenu. |
| base::scoped_nsobject<NSMenu> submenu([[NSMenu alloc] init]); |
| @@ -178,9 +177,8 @@ void HistoryMenuBridge::TabRestoreServiceChanged( |
| // Loop over the window's tabs and add them to the submenu. |
| NSInteger subindex = [[submenu itemArray] count]; |
| - std::vector<sessions::TabRestoreService::Tab>::const_iterator it; |
| - for (it = tabs.begin(); it != tabs.end(); ++it) { |
| - HistoryItem* tab_item = HistoryItemForTab(*it); |
| + for (const auto &tab : tabs) { |
|
sky
2016/08/02 23:12:30
'auto &' -> 'auto&'
|
| + HistoryItem* tab_item = HistoryItemForTab(*tab); |
| if (tab_item) { |
| item->tabs.push_back(tab_item); |
| AddItemToMenu(tab_item, submenu.get(), kRecentlyClosed + 1, |
| @@ -202,10 +200,9 @@ void HistoryMenuBridge::TabRestoreServiceChanged( |
| [parent_item setSubmenu:submenu.get()]; |
| ++added_count; |
| } |
| - } else if (entry->type == sessions::TabRestoreService::TAB) { |
| - sessions::TabRestoreService::Tab* tab = |
| - static_cast<sessions::TabRestoreService::Tab*>(entry); |
| - HistoryItem* item = HistoryItemForTab(*tab); |
| + } else if (entry->type() == sessions::TabRestoreService::TAB) { |
| + const auto &tab = static_cast<sessions::TabRestoreService::Tab&>(*entry); |
|
sky
2016/08/02 23:12:30
'auto &' -> 'auto&'
|
| + HistoryItem* item = HistoryItemForTab(tab); |
| if (item) { |
| AddItemToMenu(item, menu, kRecentlyClosed, index++); |
| ++added_count; |