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

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

Issue 2605006: [Mac] Disable menu certain menu items when a modal dialog or sheet is present. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Remove confusion (or add more?) Created 10 years, 6 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
« no previous file with comments | « chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/history_menu_cocoa_controller.h"
6
5 #include "base/scoped_vector.h" 7 #include "base/scoped_vector.h"
6 #include "chrome/app/chrome_dll_resource.h" // IDC_HISTORY_MENU 8 #include "chrome/app/chrome_dll_resource.h" // IDC_HISTORY_MENU
9 #import "chrome/browser/app_controller_mac.h"
7 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
8 #import "chrome/browser/cocoa/history_menu_cocoa_controller.h"
9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/cocoa/event_utils.h" 12 #include "chrome/browser/cocoa/event_utils.h"
12 #include "chrome/browser/history/history.h" 13 #include "chrome/browser/history/history.h"
13 #include "chrome/browser/history/history_types.h" 14 #include "chrome/browser/history/history_types.h"
14 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
15 #include "chrome/browser/tab_contents/tab_contents.h" 16 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "webkit/glue/window_open_disposition.h" 17 #include "webkit/glue/window_open_disposition.h"
17 18
18 @implementation HistoryMenuCocoaController 19 @implementation HistoryMenuCocoaController
19 20
20 - (id)initWithBridge:(HistoryMenuBridge*)bridge { 21 - (id)initWithBridge:(HistoryMenuBridge*)bridge {
21 if ((self = [super init])) { 22 if ((self = [super init])) {
22 bridge_ = bridge; 23 bridge_ = bridge;
23 DCHECK(bridge_); 24 DCHECK(bridge_);
24 } 25 }
25 return self; 26 return self;
26 } 27 }
27 28
29 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
30 AppController* controller = [NSApp delegate];
31 return [controller keyWindowIsNotModal];
32 }
33
28 // Open the URL of the given history item in the current tab. 34 // Open the URL of the given history item in the current tab.
29 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node { 35 - (void)openURLForItem:(const HistoryMenuBridge::HistoryItem*)node {
30 Browser* browser = Browser::GetOrCreateTabbedBrowser(bridge_->profile()); 36 Browser* browser = Browser::GetOrCreateTabbedBrowser(bridge_->profile());
31 WindowOpenDisposition disposition = 37 WindowOpenDisposition disposition =
32 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); 38 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]);
33 39
34 // If this item can be restored using TabRestoreService, do so. Otherwise, 40 // If this item can be restored using TabRestoreService, do so. Otherwise,
35 // just load the URL. 41 // just load the URL.
36 TabRestoreService* service = bridge_->profile()->GetTabRestoreService(); 42 TabRestoreService* service = bridge_->profile()->GetTabRestoreService();
37 if (node->session_id && service) { 43 if (node->session_id && service) {
38 service->RestoreEntryById(browser, node->session_id, false); 44 service->RestoreEntryById(browser, node->session_id, false);
39 } else { 45 } else {
40 DCHECK(node->url.is_valid()); 46 DCHECK(node->url.is_valid());
41 browser->OpenURL(node->url, GURL(), disposition, 47 browser->OpenURL(node->url, GURL(), disposition,
42 PageTransition::AUTO_BOOKMARK); 48 PageTransition::AUTO_BOOKMARK);
43 } 49 }
44 } 50 }
45 51
46 - (IBAction)openHistoryMenuItem:(id)sender { 52 - (IBAction)openHistoryMenuItem:(id)sender {
47 const HistoryMenuBridge::HistoryItem* item = 53 const HistoryMenuBridge::HistoryItem* item =
48 bridge_->HistoryItemForMenuItem(sender); 54 bridge_->HistoryItemForMenuItem(sender);
49 [self openURLForItem:item]; 55 [self openURLForItem:item];
50 } 56 }
51 57
52 @end // HistoryMenuCocoaController 58 @end // HistoryMenuCocoaController
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698