OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/cocoa/history_menu_bridge.h" | 5 #include "chrome/browser/ui/cocoa/history_menu_bridge.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 HistoryItem* tab_item = HistoryItemForTab(tab); | 178 HistoryItem* tab_item = HistoryItemForTab(tab); |
179 if (tab_item) { | 179 if (tab_item) { |
180 item->tabs.push_back(tab_item); | 180 item->tabs.push_back(tab_item); |
181 AddItemToMenu(tab_item, submenu.get(), kRecentlyClosed + 1, | 181 AddItemToMenu(tab_item, submenu.get(), kRecentlyClosed + 1, |
182 subindex++); | 182 subindex++); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 // Now that the number of tabs that has been added is known, set the title | 186 // Now that the number of tabs that has been added is known, set the title |
187 // of the parent menu item. | 187 // of the parent menu item. |
188 if (item->tabs.size() == 1) { | 188 item->title = l10n_util::GetPluralStringFUTF16( |
189 item->title = l10n_util::GetStringUTF16( | 189 IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW, item->tabs.size()); |
190 IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_SINGLE); | |
191 } else { | |
192 item->title =l10n_util::GetStringFUTF16( | |
193 IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_MULTIPLE, | |
194 base::IntToString16(item->tabs.size())); | |
195 } | |
196 | 190 |
197 // Sometimes it is possible for there to not be any subitems for a given | 191 // Sometimes it is possible for there to not be any subitems for a given |
198 // window; if that is the case, do not add the entry to the main menu. | 192 // window; if that is the case, do not add the entry to the main menu. |
199 if ([[submenu itemArray] count] > 2) { | 193 if ([[submenu itemArray] count] > 2) { |
200 // Create the menu item parent. | 194 // Create the menu item parent. |
201 NSMenuItem* parent_item = | 195 NSMenuItem* parent_item = |
202 AddItemToMenu(item, menu, kRecentlyClosed, index++); | 196 AddItemToMenu(item, menu, kRecentlyClosed, index++); |
203 [parent_item setSubmenu:submenu.get()]; | 197 [parent_item setSubmenu:submenu.get()]; |
204 ++added_count; | 198 ++added_count; |
205 } | 199 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 const history::URLRows& deleted_rows, | 446 const history::URLRows& deleted_rows, |
453 const std::set<GURL>& favicon_urls) { | 447 const std::set<GURL>& favicon_urls) { |
454 OnHistoryChanged(); | 448 OnHistoryChanged(); |
455 } | 449 } |
456 | 450 |
457 void HistoryMenuBridge::OnHistoryServiceLoaded( | 451 void HistoryMenuBridge::OnHistoryServiceLoaded( |
458 history::HistoryService* history_service) { | 452 history::HistoryService* history_service) { |
459 history_service_ = history_service; | 453 history_service_ = history_service; |
460 Init(); | 454 Init(); |
461 } | 455 } |
OLD | NEW |