Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/browser/ui/cocoa/history_menu_cocoa_controller.mm

Issue 1350653004: [sessions] Properly namespace recently-componentized TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(&params); 60 chrome::Navigate(&params);
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm ('k') | chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698