Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Side by Side Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc

Issue 2200993004: Make TabRestoreService::Entry noncopyable and fix up surrounding code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tab-test-cleanup
Patch Set: Add back NOTREACHED() and a return for gcc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 10 #include "base/metrics/histogram.h"
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 IDS_RECENTLY_CLOSED); 433 IDS_RECENTLY_CLOSED);
434 #if defined(OS_MACOSX) 434 #if defined(OS_MACOSX)
435 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 435 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
436 SetIcon(last_local_model_index_, 436 SetIcon(last_local_model_index_,
437 rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW)); 437 rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW));
438 #else 438 #else
439 SetIcon(last_local_model_index_, CreateFavicon(gfx::VectorIconId::TAB)); 439 SetIcon(last_local_model_index_, CreateFavicon(gfx::VectorIconId::TAB));
440 #endif 440 #endif
441 441
442 int added_count = 0; 442 int added_count = 0;
443 sessions::TabRestoreService::Entries entries = service->entries(); 443 for (const auto &entry : service->entries()) {
444 for (sessions::TabRestoreService::Entries::const_iterator it = 444 if (added_count == kMaxLocalEntries) {
445 entries.begin(); 445 break;
446 it != entries.end() && added_count < kMaxLocalEntries; ++it) { 446 }
447 sessions::TabRestoreService::Entry* entry = *it; 447 switch (entry->type()) {
448 if (entry->type == sessions::TabRestoreService::TAB) { 448 case sessions::TabRestoreService::TAB: {
449 sessions::TabRestoreService::Tab* tab = 449 auto& tab =
450 static_cast<sessions::TabRestoreService::Tab*>(entry); 450 static_cast<const sessions::TabRestoreService::Tab&>(*entry);
451 const sessions::SerializedNavigationEntry& current_navigation = 451 const sessions::SerializedNavigationEntry& current_navigation =
452 tab->navigations.at(tab->current_navigation_index); 452 tab.navigations.at(tab.current_navigation_index);
453 BuildLocalTabItem( 453 BuildLocalTabItem(
454 entry->id, 454 entry->id,
455 current_navigation.title(), 455 current_navigation.title(),
456 current_navigation.virtual_url(), 456 current_navigation.virtual_url(),
457 ++last_local_model_index_); 457 ++last_local_model_index_);
458 } else { 458 break; }
459 DCHECK_EQ(entry->type, sessions::TabRestoreService::WINDOW); 459 case sessions::TabRestoreService::WINDOW: {
460 BuildLocalWindowItem( 460 BuildLocalWindowItem(
461 entry->id, static_cast<sessions::TabRestoreService::Window*>(entry) 461 entry->id,
462 ->tabs.size(), 462 static_cast<const sessions::TabRestoreService::Window&>(*entry)
463 ++last_local_model_index_); 463 .tabs.size(),
464 ++last_local_model_index_);
465 break; }
464 } 466 }
465 ++added_count; 467 ++added_count;
466 } 468 }
467 } 469 }
468 DCHECK_GE(last_local_model_index_, 0); 470 DCHECK_GE(last_local_model_index_, 0);
469 } 471 }
470 472
471 void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() { 473 void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() {
472 // All other devices' items (device headers or tabs) use AddItem*() to append 474 // All other devices' items (device headers or tabs) use AddItem*() to append
473 // a menu item, because they are always only built once (i.e. invoked from 475 // a menu item, because they are always only built once (i.e. invoked from
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 726
725 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); 727 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate();
726 if (menu_model_delegate) 728 if (menu_model_delegate)
727 menu_model_delegate->OnMenuStructureChanged(); 729 menu_model_delegate->OnMenuStructureChanged();
728 } 730 }
729 731
730 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( 732 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed(
731 sessions::TabRestoreService* service) { 733 sessions::TabRestoreService* service) {
732 TabRestoreServiceChanged(service); 734 TabRestoreServiceChanged(service);
733 } 735 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698