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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 continue; | 200 continue; |
201 | 201 |
202 // Create the item for the parent/window. Do not set the title yet because | 202 // Create the item for the parent/window. Do not set the title yet because |
203 // the actual number of items that are in the menu will not be known until | 203 // the actual number of items that are in the menu will not be known until |
204 // things like the NTP are filtered out, which is done when the tab items | 204 // things like the NTP are filtered out, which is done when the tab items |
205 // are actually created. | 205 // are actually created. |
206 HistoryItem* item = new HistoryItem(); | 206 HistoryItem* item = new HistoryItem(); |
207 item->session_id = entry_win->id; | 207 item->session_id = entry_win->id; |
208 | 208 |
209 // Create the submenu. | 209 // Create the submenu. |
210 scoped_nsobject<NSMenu> submenu([[NSMenu alloc] init]); | 210 base::scoped_nsobject<NSMenu> submenu([[NSMenu alloc] init]); |
211 | 211 |
212 // Create standard items within the window submenu. | 212 // Create standard items within the window submenu. |
213 NSString* restore_title = l10n_util::GetNSString( | 213 NSString* restore_title = l10n_util::GetNSString( |
214 IDS_HISTORY_CLOSED_RESTORE_WINDOW_MAC); | 214 IDS_HISTORY_CLOSED_RESTORE_WINDOW_MAC); |
215 scoped_nsobject<NSMenuItem> restore_item( | 215 base::scoped_nsobject<NSMenuItem> restore_item( |
216 [[NSMenuItem alloc] initWithTitle:restore_title | 216 [[NSMenuItem alloc] initWithTitle:restore_title |
217 action:@selector(openHistoryMenuItem:) | 217 action:@selector(openHistoryMenuItem:) |
218 keyEquivalent:@""]); | 218 keyEquivalent:@""]); |
219 [restore_item setTarget:controller_.get()]; | 219 [restore_item setTarget:controller_.get()]; |
220 // Duplicate the HistoryItem otherwise the different NSMenuItems will | 220 // Duplicate the HistoryItem otherwise the different NSMenuItems will |
221 // point to the same HistoryItem, which would then be double-freed when | 221 // point to the same HistoryItem, which would then be double-freed when |
222 // removing the items from the map or in the dtor. | 222 // removing the items from the map or in the dtor. |
223 HistoryItem* dup_item = new HistoryItem(*item); | 223 HistoryItem* dup_item = new HistoryItem(*item); |
224 menu_item_map_.insert(std::make_pair(restore_item.get(), dup_item)); | 224 menu_item_map_.insert(std::make_pair(restore_item.get(), dup_item)); |
225 [submenu addItem:restore_item.get()]; | 225 [submenu addItem:restore_item.get()]; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 489 } |
490 | 490 |
491 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { | 491 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { |
492 DCHECK(item); | 492 DCHECK(item); |
493 if (item->icon_requested) { | 493 if (item->icon_requested) { |
494 cancelable_task_tracker_.TryCancel(item->icon_task_id); | 494 cancelable_task_tracker_.TryCancel(item->icon_task_id); |
495 item->icon_requested = false; | 495 item->icon_requested = false; |
496 item->icon_task_id = CancelableTaskTracker::kBadTaskId; | 496 item->icon_task_id = CancelableTaskTracker::kBadTaskId; |
497 } | 497 } |
498 } | 498 } |
OLD | NEW |