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

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

Issue 2623693003: Move more vector icons into respective directories. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.cc ('k') | chrome/browser/ui/views/tabs/tab.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 22 matching lines...) Expand all
33 #include "components/strings/grit/components_strings.h" 33 #include "components/strings/grit/components_strings.h"
34 #include "components/sync_sessions/open_tabs_ui_delegate.h" 34 #include "components/sync_sessions/open_tabs_ui_delegate.h"
35 #include "components/sync_sessions/synced_session.h" 35 #include "components/sync_sessions/synced_session.h"
36 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
37 #include "ui/base/accelerators/accelerator.h" 37 #include "ui/base/accelerators/accelerator.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/resources/grit/ui_resources.h" 40 #include "ui/resources/grit/ui_resources.h"
41 41
42 #if !defined(OS_MACOSX) 42 #if !defined(OS_MACOSX)
43 #include "chrome/app/vector_icons/vector_icons.h"
43 #include "ui/gfx/color_palette.h" 44 #include "ui/gfx/color_palette.h"
44 #include "ui/gfx/paint_vector_icon.h" 45 #include "ui/gfx/paint_vector_icon.h"
45 #include "ui/gfx/vector_icons_public.h"
46 #endif 46 #endif
47 47
48 #if defined(USE_ASH) 48 #if defined(USE_ASH)
49 #include "ash/common/accelerators/accelerator_table.h" // nogncheck 49 #include "ash/common/accelerators/accelerator_table.h" // nogncheck
50 #endif // defined(USE_ASH) 50 #endif // defined(USE_ASH)
51 51
52 namespace { 52 namespace {
53 53
54 // Initial comamnd ID's for navigatable (and hence executable) tab/window menu 54 // Initial comamnd ID's for navigatable (and hence executable) tab/window menu
55 // items. The menumodel and storage structures are not 1-1: 55 // items. The menumodel and storage structures are not 1-1:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return command_id; 124 return command_id;
125 } 125 }
126 126
127 // Convert |command_id| of menu item to index in |local_window_items_|. 127 // Convert |command_id| of menu item to index in |local_window_items_|.
128 int CommandIdToWindowVectorIndex(int command_id) { 128 int CommandIdToWindowVectorIndex(int command_id) {
129 DCHECK(IsWindowModelCommandId(command_id)); 129 DCHECK(IsWindowModelCommandId(command_id));
130 return command_id - kFirstLocalWindowCommandId; 130 return command_id - kFirstLocalWindowCommandId;
131 } 131 }
132 132
133 #if !defined(OS_MACOSX) 133 #if !defined(OS_MACOSX)
134 gfx::Image CreateFavicon(gfx::VectorIconId id) { 134 gfx::Image CreateFavicon(const gfx::VectorIcon& icon) {
135 return gfx::Image(gfx::CreateVectorIcon(id, 16, gfx::kChromeIconGrey)); 135 return gfx::Image(gfx::CreateVectorIcon(icon, 16, gfx::kChromeIconGrey));
136 } 136 }
137 #endif 137 #endif
138 138
139 } // namespace 139 } // namespace
140 140
141 enum RecentTabAction { 141 enum RecentTabAction {
142 LOCAL_SESSION_TAB = 0, 142 LOCAL_SESSION_TAB = 0,
143 OTHER_DEVICE_TAB, 143 OTHER_DEVICE_TAB,
144 RESTORE_WINDOW, 144 RESTORE_WINDOW,
145 SHOW_MORE, 145 SHOW_MORE,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 IDS_RECENTLY_CLOSED); 432 IDS_RECENTLY_CLOSED);
433 } else { 433 } else {
434 InsertItemWithStringIdAt(++last_local_model_index_, 434 InsertItemWithStringIdAt(++last_local_model_index_,
435 kRecentlyClosedHeaderCommandId, 435 kRecentlyClosedHeaderCommandId,
436 IDS_RECENTLY_CLOSED); 436 IDS_RECENTLY_CLOSED);
437 #if defined(OS_MACOSX) 437 #if defined(OS_MACOSX)
438 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 438 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
439 SetIcon(last_local_model_index_, 439 SetIcon(last_local_model_index_,
440 rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW)); 440 rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW));
441 #else 441 #else
442 SetIcon(last_local_model_index_, CreateFavicon(gfx::VectorIconId::TAB)); 442 SetIcon(last_local_model_index_, CreateFavicon(kTabIcon));
443 #endif 443 #endif
444 444
445 int added_count = 0; 445 int added_count = 0;
446 for (const auto& entry : service->entries()) { 446 for (const auto& entry : service->entries()) {
447 if (added_count == kMaxLocalEntries) 447 if (added_count == kMaxLocalEntries)
448 break; 448 break;
449 switch (entry->type) { 449 switch (entry->type) {
450 case sessions::TabRestoreService::TAB: { 450 case sessions::TabRestoreService::TAB: {
451 auto& tab = 451 auto& tab =
452 static_cast<const sessions::TabRestoreService::Tab&>(*entry); 452 static_cast<const sessions::TabRestoreService::Tab&>(*entry);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int num_tabs, 545 int num_tabs,
546 int curr_model_index) { 546 int curr_model_index) {
547 int command_id = WindowVectorIndexToCommandId(local_window_items_.size()); 547 int command_id = WindowVectorIndexToCommandId(local_window_items_.size());
548 // See comments in BuildLocalEntries() about usage of InsertItem*At(). 548 // See comments in BuildLocalEntries() about usage of InsertItem*At().
549 InsertItemAt(curr_model_index, command_id, l10n_util::GetPluralStringFUTF16( 549 InsertItemAt(curr_model_index, command_id, l10n_util::GetPluralStringFUTF16(
550 IDS_RECENTLY_CLOSED_WINDOW, num_tabs)); 550 IDS_RECENTLY_CLOSED_WINDOW, num_tabs));
551 #if defined(OS_MACOSX) 551 #if defined(OS_MACOSX)
552 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 552 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
553 SetIcon(curr_model_index, rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW)); 553 SetIcon(curr_model_index, rb.GetNativeImageNamed(IDR_RECENTLY_CLOSED_WINDOW));
554 #else 554 #else
555 SetIcon(curr_model_index, CreateFavicon(gfx::VectorIconId::TAB)); 555 SetIcon(curr_model_index, CreateFavicon(kTabIcon));
556 #endif 556 #endif
557 local_window_items_.push_back(window_id); 557 local_window_items_.push_back(window_id);
558 } 558 }
559 559
560 void RecentTabsSubMenuModel::BuildOtherDevicesTabItem( 560 void RecentTabsSubMenuModel::BuildOtherDevicesTabItem(
561 const std::string& session_tag, 561 const std::string& session_tag,
562 const sessions::SessionTab& tab) { 562 const sessions::SessionTab& tab) {
563 const sessions::SerializedNavigationEntry& current_navigation = 563 const sessions::SerializedNavigationEntry& current_navigation =
564 tab.navigations.at(tab.normalized_navigation_index()); 564 tab.navigations.at(tab.normalized_navigation_index());
565 TabNavigationItem item(session_tag, tab.tab_id.id(), 565 TabNavigationItem item(session_tag, tab.tab_id.id(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 case sync_sessions::SyncedSession::TYPE_LINUX: 597 case sync_sessions::SyncedSession::TYPE_LINUX:
598 case sync_sessions::SyncedSession::TYPE_OTHER: 598 case sync_sessions::SyncedSession::TYPE_OTHER:
599 case sync_sessions::SyncedSession::TYPE_UNSET: 599 case sync_sessions::SyncedSession::TYPE_UNSET:
600 favicon_id = IDR_LAPTOP_FAVICON; 600 favicon_id = IDR_LAPTOP_FAVICON;
601 break; 601 break;
602 } 602 }
603 603
604 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 604 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
605 SetIcon(index_in_menu, rb.GetNativeImageNamed(favicon_id)); 605 SetIcon(index_in_menu, rb.GetNativeImageNamed(favicon_id));
606 #else 606 #else
607 gfx::VectorIconId favicon_id = gfx::VectorIconId::VECTOR_ICON_NONE; 607 const gfx::VectorIcon* favicon = nullptr;
608 switch (device_type) { 608 switch (device_type) {
609 case sync_sessions::SyncedSession::TYPE_PHONE: 609 case sync_sessions::SyncedSession::TYPE_PHONE:
610 favicon_id = gfx::VectorIconId::SMARTPHONE; 610 favicon = &kSmartphoneIcon;
611 break; 611 break;
612 612
613 case sync_sessions::SyncedSession::TYPE_TABLET: 613 case sync_sessions::SyncedSession::TYPE_TABLET:
614 favicon_id = gfx::VectorIconId::TABLET; 614 favicon = &kTabletIcon;
615 break; 615 break;
616 616
617 case sync_sessions::SyncedSession::TYPE_CHROMEOS: 617 case sync_sessions::SyncedSession::TYPE_CHROMEOS:
618 case sync_sessions::SyncedSession::TYPE_WIN: 618 case sync_sessions::SyncedSession::TYPE_WIN:
619 case sync_sessions::SyncedSession::TYPE_MACOSX: 619 case sync_sessions::SyncedSession::TYPE_MACOSX:
620 case sync_sessions::SyncedSession::TYPE_LINUX: 620 case sync_sessions::SyncedSession::TYPE_LINUX:
621 case sync_sessions::SyncedSession::TYPE_OTHER: 621 case sync_sessions::SyncedSession::TYPE_OTHER:
622 case sync_sessions::SyncedSession::TYPE_UNSET: 622 case sync_sessions::SyncedSession::TYPE_UNSET:
623 favicon_id = gfx::VectorIconId::LAPTOP; 623 favicon = &kLaptopIcon;
624 break; 624 break;
625 } 625 }
626 626
627 SetIcon(index_in_menu, CreateFavicon(favicon_id)); 627 SetIcon(index_in_menu, CreateFavicon(*favicon));
628 #endif 628 #endif
629 } 629 }
630 630
631 void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) { 631 void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) {
632 bool is_local_tab = command_id < kFirstOtherDevicesTabCommandId; 632 bool is_local_tab = command_id < kFirstOtherDevicesTabCommandId;
633 int index_in_menu = GetIndexOfCommandId(command_id); 633 int index_in_menu = GetIndexOfCommandId(command_id);
634 634
635 if (!is_local_tab) { 635 if (!is_local_tab) {
636 // If tab has synced favicon, use it. 636 // If tab has synced favicon, use it.
637 // Note that currently, other devices' tabs only have favicons if 637 // Note that currently, other devices' tabs only have favicons if
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); 730 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate();
731 if (menu_model_delegate) 731 if (menu_model_delegate)
732 menu_model_delegate->OnMenuStructureChanged(); 732 menu_model_delegate->OnMenuStructureChanged();
733 } 733 }
734 734
735 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( 735 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed(
736 sessions::TabRestoreService* service) { 736 sessions::TabRestoreService* service) {
737 TabRestoreServiceChanged(service); 737 TabRestoreServiceChanged(service);
738 } 738 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.cc ('k') | chrome/browser/ui/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698