| Index: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
|
| diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
|
| index d8d5204575afe9a1a9644f67fa4f559b63d30c57..b886d531fdc9409f2c89a60e77d1c6da718fb10d 100644
|
| --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
|
| +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
|
| @@ -149,6 +149,8 @@ bool RecentTabsSubMenuModel::IsCommandIdEnabled(int command_id) const {
|
| if (command_id == kDisabledCommandId ||
|
| command_id == IDC_RECENT_TABS_NO_DEVICE_TABS) {
|
| return false;
|
| + } else if (command_id == IDC_RECENT_TABS_MORE_DEVICES) {
|
| + return true;
|
| }
|
| int model_index = CommandIdToModelIndex(command_id);
|
| return model_index >= 0 && model_index < static_cast<int>(model_.size());
|
| @@ -188,6 +190,11 @@ void RecentTabsSubMenuModel::ExecuteCommand(int command_id, int event_flags) {
|
| chrome::ExecuteCommandWithDisposition(browser_, command_id,
|
| ui::DispositionFromEventFlags(event_flags));
|
| return;
|
| + } else if (command_id == IDC_RECENT_TABS_MORE_DEVICES) {
|
| + // We show all "other devices" on the history page.
|
| + chrome::ExecuteCommandWithDisposition(browser_, IDC_SHOW_HISTORY,
|
| + ui::DispositionFromEventFlags(event_flags));
|
| + return;
|
| }
|
|
|
| DCHECK_NE(kDisabledCommandId, command_id);
|
| @@ -267,11 +274,11 @@ void RecentTabsSubMenuModel::BuildDevices() {
|
| // Sort sessions from most recent to least recent.
|
| std::sort(sessions.begin(), sessions.end(), SortSessionsByRecency);
|
|
|
| + bool show_more = false;
|
| const size_t kMaxSessionsToShow = 3;
|
| size_t num_sessions_added = 0;
|
| - for (size_t i = 0;
|
| - i < sessions.size() && num_sessions_added < kMaxSessionsToShow;
|
| - ++i) {
|
| + size_t i = 0;
|
| + for (; i < sessions.size() && num_sessions_added < kMaxSessionsToShow; ++i) {
|
| const browser_sync::SyncedSession* session = sessions[i];
|
| const std::string& session_tag = session->session_tag;
|
|
|
| @@ -319,9 +326,23 @@ void RecentTabsSubMenuModel::BuildDevices() {
|
| ++k) {
|
| BuildForeignTabItem(session_tag, *tabs_in_session[k]);
|
| } // for all tabs in one session
|
| + if (tabs_in_session.size() > kMaxTabsPerSessionToShow)
|
| + show_more = true;
|
|
|
| ++num_sessions_added;
|
| } // for all sessions
|
| +
|
| + // Relying on |i| < size() is more accurate than |num_sessions_added| and
|
| + // |kMaxSessionsToShow| since we may reach the max at the same time as we
|
| + // reach the size and there's no way to know if we got all the session or
|
| + // not,... unless we compare to the size.
|
| + // Note that we are still exposed to the case where the remaining sessions
|
| + // would be empty, but that's not worth the extra cost of checking.
|
| + if (show_more || i < sessions.size()) {
|
| + AddSeparator(ui::NORMAL_SEPARATOR);
|
| + AddItemWithStringId(IDC_RECENT_TABS_MORE_DEVICES,
|
| + IDS_RECENT_TABS_MORE_DEVICES);
|
| + }
|
| }
|
|
|
| void RecentTabsSubMenuModel::BuildForeignTabItem(
|
|
|