OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/frame/global_menu_bar_x11.h" | 5 #include "chrome/browser/ui/views/frame/global_menu_bar_x11.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <glib-object.h> | 8 #include <glib-object.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 744 |
745 // We'll get the index the "Recently Closed" header. (This can vary depending | 745 // We'll get the index the "Recently Closed" header. (This can vary depending |
746 // on the number of "Most Visited" items. | 746 // on the number of "Most Visited" items. |
747 int index = GetIndexOfMenuItemWithTag(history_menu_, | 747 int index = GetIndexOfMenuItemWithTag(history_menu_, |
748 TAG_RECENTLY_CLOSED_HEADER) + 1; | 748 TAG_RECENTLY_CLOSED_HEADER) + 1; |
749 | 749 |
750 unsigned int added_count = 0; | 750 unsigned int added_count = 0; |
751 for (sessions::TabRestoreService::Entries::const_iterator it = | 751 for (sessions::TabRestoreService::Entries::const_iterator it = |
752 entries.begin(); | 752 entries.begin(); |
753 it != entries.end() && added_count < kRecentlyClosedCount; ++it) { | 753 it != entries.end() && added_count < kRecentlyClosedCount; ++it) { |
754 sessions::TabRestoreService::Entry* entry = *it; | 754 sessions::TabRestoreService::Entry* entry = it->get(); |
755 | 755 |
756 if (entry->type == sessions::TabRestoreService::WINDOW) { | 756 if (entry->type == sessions::TabRestoreService::WINDOW) { |
757 sessions::TabRestoreService::Window* entry_win = | 757 sessions::TabRestoreService::Window* entry_win = |
758 static_cast<sessions::TabRestoreService::Window*>(entry); | 758 static_cast<sessions::TabRestoreService::Window*>(entry); |
759 std::vector<sessions::TabRestoreService::Tab>& tabs = entry_win->tabs; | 759 auto& tabs = entry_win->tabs; |
760 if (tabs.empty()) | 760 if (tabs.empty()) |
761 continue; | 761 continue; |
762 | 762 |
763 // Create the item for the parent/window. | 763 // Create the item for the parent/window. |
764 HistoryItem* item = new HistoryItem(); | 764 HistoryItem* item = new HistoryItem(); |
765 item->session_id = entry_win->id; | 765 item->session_id = entry_win->id; |
766 | 766 |
767 std::string title = l10n_util::GetPluralStringFUTF8( | 767 std::string title = l10n_util::GetPluralStringFUTF8( |
768 IDS_RECENTLY_CLOSED_WINDOW, tabs.size()); | 768 IDS_RECENTLY_CLOSED_WINDOW, tabs.size()); |
769 DbusmenuMenuitem* parent_item = BuildMenuItem( | 769 DbusmenuMenuitem* parent_item = BuildMenuItem( |
(...skipping 15 matching lines...) Expand all Loading... |
785 DeleteHistoryItem); | 785 DeleteHistoryItem); |
786 menuitem_child_append(parent_item, restore_item); | 786 menuitem_child_append(parent_item, restore_item); |
787 g_object_unref(restore_item); | 787 g_object_unref(restore_item); |
788 | 788 |
789 DbusmenuMenuitem* separator = BuildSeparator(); | 789 DbusmenuMenuitem* separator = BuildSeparator(); |
790 menuitem_child_append(parent_item, separator); | 790 menuitem_child_append(parent_item, separator); |
791 g_object_unref(separator); | 791 g_object_unref(separator); |
792 | 792 |
793 // Loop over the window's tabs and add them to the submenu. | 793 // Loop over the window's tabs and add them to the submenu. |
794 int subindex = 2; | 794 int subindex = 2; |
795 std::vector<sessions::TabRestoreService::Tab>::const_iterator iter; | 795 for (const auto& tab : tabs) { |
796 for (iter = tabs.begin(); iter != tabs.end(); ++iter) { | 796 HistoryItem* tab_item = HistoryItemForTab(*tab); |
797 sessions::TabRestoreService::Tab tab = *iter; | |
798 HistoryItem* tab_item = HistoryItemForTab(tab); | |
799 item->tabs.push_back(tab_item); | 797 item->tabs.push_back(tab_item); |
800 AddHistoryItemToMenu(tab_item, | 798 AddHistoryItemToMenu(tab_item, |
801 parent_item, | 799 parent_item, |
802 TAG_RECENTLY_CLOSED, | 800 TAG_RECENTLY_CLOSED, |
803 subindex++); | 801 subindex++); |
804 } | 802 } |
805 | 803 |
806 ++added_count; | 804 ++added_count; |
807 } else if (entry->type == sessions::TabRestoreService::TAB) { | 805 } else if (entry->type == sessions::TabRestoreService::TAB) { |
808 sessions::TabRestoreService::Tab* tab = | 806 sessions::TabRestoreService::Tab* tab = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 unsigned int timestamp) { | 887 unsigned int timestamp) { |
890 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), kProfileId)); | 888 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), kProfileId)); |
891 avatar_menu_->EditProfile(id); | 889 avatar_menu_->EditProfile(id); |
892 } | 890 } |
893 | 891 |
894 void GlobalMenuBarX11::OnCreateProfileItemActivated(DbusmenuMenuitem* sender, | 892 void GlobalMenuBarX11::OnCreateProfileItemActivated(DbusmenuMenuitem* sender, |
895 unsigned int timestamp) { | 893 unsigned int timestamp) { |
896 profiles::CreateAndSwitchToNewProfile(ProfileManager::CreateCallback(), | 894 profiles::CreateAndSwitchToNewProfile(ProfileManager::CreateCallback(), |
897 ProfileMetrics::ADD_NEW_USER_MENU); | 895 ProfileMetrics::ADD_NEW_USER_MENU); |
898 } | 896 } |
OLD | NEW |