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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm

Issue 11906008: Make Mac menu code obey incognito availability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adjust comment Created 7 years, 11 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 | Annotate | Revision Log
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/bookmarks/bookmark_menu_cocoa_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU 8 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU
9 #import "chrome/browser/app_controller_mac.h" 9 #import "chrome/browser/app_controller_mac.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 std::string url_string = node->url().possibly_invalid_spec(); 42 std::string url_string = node->url().possibly_invalid_spec();
43 NSString* url = [NSString stringWithUTF8String:url_string.c_str()]; 43 NSString* url = [NSString stringWithUTF8String:url_string.c_str()];
44 if ([title length] == 0) 44 if ([title length] == 0)
45 return url; 45 return url;
46 else if ([url length] == 0 || [url isEqualToString:title]) 46 else if ([url length] == 0 || [url isEqualToString:title])
47 return title; 47 return title;
48 else 48 else
49 return [NSString stringWithFormat:@"%@\n%@", title, url]; 49 return [NSString stringWithFormat:@"%@\n%@", title, url];
50 } 50 }
51 51
52 - (id)initWithBridge:(BookmarkMenuBridge *)bridge 52 - (id)initWithBridge:(BookmarkMenuBridge*)bridge
53 andMenu:(NSMenu*)menu { 53 andMenu:(NSMenu*)menu {
54 if ((self = [super init])) { 54 if ((self = [super init])) {
55 bridge_ = bridge; 55 bridge_ = bridge;
56 DCHECK(bridge_); 56 DCHECK(bridge_);
57 menu_ = menu; 57 menu_ = menu;
58 [[self menu] setDelegate:self]; 58 [[self menu] setDelegate:self];
59 } 59 }
60 return self; 60 return self;
61 } 61 }
62 62
63 - (void)dealloc { 63 - (void)dealloc {
64 if ([[self menu] delegate] == self) 64 if ([[self menu] delegate] == self)
65 [[self menu] setDelegate:nil]; 65 [[self menu] setDelegate:nil];
66 [super dealloc]; 66 [super dealloc];
67 } 67 }
68 68
69 - (NSMenu*)menu { 69 - (NSMenu*)menu {
70 return menu_; 70 return menu_;
71 } 71 }
72 72
73 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { 73 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
74 AppController* controller = [NSApp delegate]; 74 AppController* controller = [NSApp delegate];
75 return [controller keyWindowIsNotModal]; 75 return ![controller keyWindowIsModal];
76 } 76 }
77 77
78 // NSMenu delegate method: called just before menu is displayed. 78 // NSMenu delegate method: called just before menu is displayed.
79 - (void)menuNeedsUpdate:(NSMenu*)menu { 79 - (void)menuNeedsUpdate:(NSMenu*)menu {
80 bridge_->UpdateMenu(menu); 80 bridge_->UpdateMenu(menu);
81 } 81 }
82 82
83 // Return the a BookmarkNode that has the given id (called 83 // Return the a BookmarkNode that has the given id (called
84 // "identifier" here to avoid conflict with objc's concept of "id"). 84 // "identifier" here to avoid conflict with objc's concept of "id").
85 - (const BookmarkNode*)nodeForIdentifier:(int)identifier { 85 - (const BookmarkNode*)nodeForIdentifier:(int)identifier {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 - (IBAction)openAllBookmarksNewWindow:(id)sender { 151 - (IBAction)openAllBookmarksNewWindow:(id)sender {
152 [self openAll:[sender tag] withDisposition:NEW_WINDOW]; 152 [self openAll:[sender tag] withDisposition:NEW_WINDOW];
153 } 153 }
154 154
155 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender { 155 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender {
156 [self openAll:[sender tag] withDisposition:OFF_THE_RECORD]; 156 [self openAll:[sender tag] withDisposition:OFF_THE_RECORD];
157 } 157 }
158 158
159 @end // BookmarkMenuCocoaController 159 @end // BookmarkMenuCocoaController
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/cocoa/history_menu_cocoa_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698