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

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

Issue 2804903003: [Mac] Remove "Open All Bookmarks" menu items from application and wrench menus (Closed)
Patch Set: Rebase Created 3 years, 7 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/bookmarks/bookmark_menu_cocoa_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
6 6
7 #import "base/mac/foundation_util.h" 7 #import "base/mac/foundation_util.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU 10 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 browser = new Browser(Browser::CreateParams(bridge_->GetProfile(), true)); 96 browser = new Browser(Browser::CreateParams(bridge_->GetProfile(), true));
97 } 97 }
98 WindowOpenDisposition disposition = 98 WindowOpenDisposition disposition =
99 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); 99 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]);
100 OpenURLParams params( 100 OpenURLParams params(
101 node->url(), Referrer(), disposition, 101 node->url(), Referrer(), disposition,
102 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false); 102 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
103 browser->OpenURL(params); 103 browser->OpenURL(params);
104 } 104 }
105 105
106 // Open sites under BookmarkNode with the specified disposition.
107 - (void)openAll:(NSInteger)tag
108 withDisposition:(WindowOpenDisposition)disposition {
109 int identifier = tag;
110
111 const BookmarkNode* node = [self nodeForIdentifier:identifier];
112 DCHECK(node);
113
114 Browser* browser = chrome::FindTabbedBrowser(bridge_->GetProfile(), true);
115 if (!browser) {
116 browser = new Browser(Browser::CreateParams(bridge_->GetProfile(), true));
117 }
118 DCHECK(browser);
119
120 if (!node || !browser)
121 return; // shouldn't be reached
122
123 chrome::OpenAll(nullptr, browser, node, disposition, browser->profile());
124
125 if (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) {
126 base::RecordAction(UserMetricsAction("OpenAllBookmarks"));
127 } else if (disposition == WindowOpenDisposition::NEW_WINDOW) {
128 base::RecordAction(UserMetricsAction("OpenAllBookmarksNewWindow"));
129 } else {
130 base::RecordAction(UserMetricsAction("OpenAllBookmarksIncognitoWindow"));
131 }
132 }
133
134 - (IBAction)openBookmarkMenuItem:(id)sender { 106 - (IBAction)openBookmarkMenuItem:(id)sender {
135 NSInteger tag = [sender tag]; 107 NSInteger tag = [sender tag];
136 int identifier = tag; 108 int identifier = tag;
137 const BookmarkNode* node = [self nodeForIdentifier:identifier]; 109 const BookmarkNode* node = [self nodeForIdentifier:identifier];
138 DCHECK(node); 110 DCHECK(node);
139 if (!node) 111 if (!node)
140 return; // shouldn't be reached 112 return; // shouldn't be reached
141 113
142 [self openURLForNode:node]; 114 [self openURLForNode:node];
143 } 115 }
144 116
145 - (IBAction)openAllBookmarks:(id)sender {
146 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
147 [self openAll:[sender tag] withDisposition:disposition];
148 }
149
150 - (IBAction)openAllBookmarksNewWindow:(id)sender {
151 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_WINDOW;
152 [self openAll:[sender tag] withDisposition:disposition];
153 }
154
155 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender {
156 WindowOpenDisposition disposition = WindowOpenDisposition::OFF_THE_RECORD;
157 [self openAll:[sender tag] withDisposition:disposition];
158 }
159
160 @end // BookmarkMenuCocoaController 117 @end // BookmarkMenuCocoaController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698