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" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
13 #include "chrome/browser/ui/browser_live_tab_context.h" | 13 #include "chrome/browser/ui/browser_live_tab_context.h" |
14 #include "chrome/browser/ui/browser_navigator.h" | 14 #include "chrome/browser/ui/browser_navigator.h" |
15 #include "chrome/browser/ui/browser_navigator_params.h" | 15 #include "chrome/browser/ui/browser_navigator_params.h" |
16 #include "chrome/browser/ui/host_desktop.h" | |
17 #include "components/history/core/browser/history_service.h" | 16 #include "components/history/core/browser/history_service.h" |
18 #include "components/history/core/browser/history_types.h" | 17 #include "components/history/core/browser/history_types.h" |
19 #include "components/sessions/core/tab_restore_service.h" | 18 #include "components/sessions/core/tab_restore_service.h" |
20 #import "ui/base/cocoa/cocoa_base_utils.h" | 19 #import "ui/base/cocoa/cocoa_base_utils.h" |
21 #include "ui/base/window_open_disposition.h" | 20 #include "ui/base/window_open_disposition.h" |
22 | 21 |
23 using content::OpenURLParams; | 22 using content::OpenURLParams; |
24 using content::Referrer; | 23 using content::Referrer; |
25 | 24 |
26 @implementation HistoryMenuCocoaController | 25 @implementation HistoryMenuCocoaController |
(...skipping 14 matching lines...) Expand all Loading... |
41 // 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. |
42 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { | 41 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { |
43 // If this item can be restored using TabRestoreService, do so. Otherwise, | 42 // If this item can be restored using TabRestoreService, do so. Otherwise, |
44 // just load the URL. | 43 // just load the URL. |
45 sessions::TabRestoreService* service = | 44 sessions::TabRestoreService* service = |
46 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); | 45 TabRestoreServiceFactory::GetForProfile(bridge_->profile()); |
47 if (node->session_id && service) { | 46 if (node->session_id && service) { |
48 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false); | 47 Browser* browser = chrome::FindTabbedBrowser(bridge_->profile(), false); |
49 BrowserLiveTabContext* context = | 48 BrowserLiveTabContext* context = |
50 browser ? browser->live_tab_context() : NULL; | 49 browser ? browser->live_tab_context() : NULL; |
51 service->RestoreEntryById(context, node->session_id, | 50 service->RestoreEntryById(context, node->session_id, UNKNOWN); |
52 chrome::HOST_DESKTOP_TYPE_NATIVE, UNKNOWN); | |
53 } else { | 51 } else { |
54 DCHECK(node->url.is_valid()); | 52 DCHECK(node->url.is_valid()); |
55 WindowOpenDisposition disposition = | 53 WindowOpenDisposition disposition = |
56 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 54 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
57 chrome::NavigateParams params(bridge_->profile(), node->url, | 55 chrome::NavigateParams params(bridge_->profile(), node->url, |
58 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 56 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
59 params.disposition = disposition; | 57 params.disposition = disposition; |
60 chrome::Navigate(¶ms); | 58 chrome::Navigate(¶ms); |
61 } | 59 } |
62 } | 60 } |
63 | 61 |
64 - (IBAction)openHistoryMenuItem:(id)sender { | 62 - (IBAction)openHistoryMenuItem:(id)sender { |
65 const HistoryMenuBridge::HistoryItem* item = | 63 const HistoryMenuBridge::HistoryItem* item = |
66 bridge_->HistoryItemForMenuItem(sender); | 64 bridge_->HistoryItemForMenuItem(sender); |
67 [self openURLForItem:item]; | 65 [self openURLForItem:item]; |
68 } | 66 } |
69 | 67 |
70 @end // HistoryMenuCocoaController | 68 @end // HistoryMenuCocoaController |
OLD | NEW |