| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 35 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
| 36 AppController* controller = [NSApp delegate]; | 36 AppController* controller = [NSApp delegate]; |
| 37 return ![controller keyWindowIsModal]; | 37 return ![controller keyWindowIsModal]; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Open the URL of the given history item in the current tab. | 40 // Open the URL of the given history item in the current tab. |
| 41 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { | 41 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { |
| 42 // If this item can be restored using TabRestoreService, do so. Otherwise, | 42 // If this item can be restored using TabRestoreService, do so. Otherwise, |
| 43 // just load the URL. | 43 // just load the URL. |
| 44 TabRestoreService* service = | 44 sessions::TabRestoreService* service = |
| 45 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); | 45 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); |
| 46 if (node->session_id && service) { | 46 if (node->session_id && service) { |
| 47 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false, | 47 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false, |
| 48 chrome::HOST_DESKTOP_TYPE_NATIVE); | 48 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 49 BrowserTabRestoreServiceDelegate* delegate = browser ? | 49 BrowserTabRestoreServiceDelegate* delegate = browser ? |
| 50 browser->tab_restore_service_delegate() : NULL; | 50 browser->tab_restore_service_delegate() : NULL; |
| 51 service->RestoreEntryById(delegate, node->session_id, | 51 service->RestoreEntryById(delegate, node->session_id, |
| 52 chrome::HOST_DESKTOP_TYPE_NATIVE, UNKNOWN); | 52 chrome::HOST_DESKTOP_TYPE_NATIVE, UNKNOWN); |
| 53 } else { | 53 } else { |
| 54 DCHECK(node->url.is_valid()); | 54 DCHECK(node->url.is_valid()); |
| 55 WindowOpenDisposition disposition = | 55 WindowOpenDisposition disposition = |
| 56 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 56 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 57 chrome::NavigateParams params(bridge_->profile(), node->url, | 57 chrome::NavigateParams params(bridge_->profile(), node->url, |
| 58 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 58 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 59 params.disposition = disposition; | 59 params.disposition = disposition; |
| 60 chrome::Navigate(¶ms); | 60 chrome::Navigate(¶ms); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 - (IBAction)openHistoryMenuItem:(id)sender { | 64 - (IBAction)openHistoryMenuItem:(id)sender { |
| 65 const HistoryMenuBridge::HistoryItem* item = | 65 const HistoryMenuBridge::HistoryItem* item = |
| 66 bridge_->HistoryItemForMenuItem(sender); | 66 bridge_->HistoryItemForMenuItem(sender); |
| 67 [self openURLForItem:item]; | 67 [self openURLForItem:item]; |
| 68 } | 68 } |
| 69 | 69 |
| 70 @end // HistoryMenuCocoaController | 70 @end // HistoryMenuCocoaController |
| OLD | NEW |