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 #import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h" | 5 #import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU | 7 #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU |
8 #import "chrome/browser/app_controller_mac.h" | 8 #import "chrome/browser/app_controller_mac.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 10 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 return ![controller keyWindowIsModal]; | 38 return ![controller keyWindowIsModal]; |
39 } | 39 } |
40 | 40 |
41 // Open the URL of the given history item in the current tab. | 41 // Open the URL of the given history item in the current tab. |
42 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { | 42 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { |
43 // If this item can be restored using TabRestoreService, do so. Otherwise, | 43 // If this item can be restored using TabRestoreService, do so. Otherwise, |
44 // just load the URL. | 44 // just load the URL. |
45 sessions::TabRestoreService* service = | 45 sessions::TabRestoreService* service = |
46 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); | 46 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); |
47 if (node->session_id && service) { | 47 if (node->session_id && service) { |
48 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false, | 48 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false); |
49 chrome::HOST_DESKTOP_TYPE_NATIVE); | |
50 BrowserLiveTabContext* context = | 49 BrowserLiveTabContext* context = |
51 browser ? browser->live_tab_context() : NULL; | 50 browser ? browser->live_tab_context() : NULL; |
52 service->RestoreEntryById(context, node->session_id, | 51 service->RestoreEntryById(context, node->session_id, |
53 chrome::HOST_DESKTOP_TYPE_NATIVE, UNKNOWN); | 52 chrome::HOST_DESKTOP_TYPE_NATIVE, UNKNOWN); |
54 } else { | 53 } else { |
55 DCHECK(node->url.is_valid()); | 54 DCHECK(node->url.is_valid()); |
56 WindowOpenDisposition disposition = | 55 WindowOpenDisposition disposition = |
57 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 56 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
58 chrome::NavigateParams params(bridge_->profile(), node->url, | 57 chrome::NavigateParams params(bridge_->profile(), node->url, |
59 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 58 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
60 params.disposition = disposition; | 59 params.disposition = disposition; |
61 chrome::Navigate(¶ms); | 60 chrome::Navigate(¶ms); |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 - (IBAction)openHistoryMenuItem:(id)sender { | 64 - (IBAction)openHistoryMenuItem:(id)sender { |
66 const HistoryMenuBridge::HistoryItem* item = | 65 const HistoryMenuBridge::HistoryItem* item = |
67 bridge_->HistoryItemForMenuItem(sender); | 66 bridge_->HistoryItemForMenuItem(sender); |
68 [self openURLForItem:item]; | 67 [self openURLForItem:item]; |
69 } | 68 } |
70 | 69 |
71 @end // HistoryMenuCocoaController | 70 @end // HistoryMenuCocoaController |
OLD | NEW |