| 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/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/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU | 9 #include "chrome/app/chrome_command_ids.h" // IDC_BOOKMARK_MENU |
| 10 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // "identifier" here to avoid conflict with objc's concept of "id"). | 86 // "identifier" here to avoid conflict with objc's concept of "id"). |
| 87 - (const BookmarkNode*)nodeForIdentifier:(int)identifier { | 87 - (const BookmarkNode*)nodeForIdentifier:(int)identifier { |
| 88 return bookmarks::GetBookmarkNodeByID(bridge_->GetBookmarkModel(), | 88 return bookmarks::GetBookmarkNodeByID(bridge_->GetBookmarkModel(), |
| 89 identifier); | 89 identifier); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Open the URL of the given BookmarkNode in the current tab. | 92 // Open the URL of the given BookmarkNode in the current tab. |
| 93 - (void)openURLForNode:(const BookmarkNode*)node { | 93 - (void)openURLForNode:(const BookmarkNode*)node { |
| 94 Browser* browser = chrome::FindTabbedBrowser(bridge_->GetProfile(), true); | 94 Browser* browser = chrome::FindTabbedBrowser(bridge_->GetProfile(), true); |
| 95 if (!browser) { | 95 if (!browser) { |
| 96 browser = new Browser(Browser::CreateParams(bridge_->GetProfile())); | 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. | 106 // Open sites under BookmarkNode with the specified disposition. |
| 107 - (void)openAll:(NSInteger)tag | 107 - (void)openAll:(NSInteger)tag |
| 108 withDisposition:(WindowOpenDisposition)disposition { | 108 withDisposition:(WindowOpenDisposition)disposition { |
| 109 int identifier = tag; | 109 int identifier = tag; |
| 110 | 110 |
| 111 const BookmarkNode* node = [self nodeForIdentifier:identifier]; | 111 const BookmarkNode* node = [self nodeForIdentifier:identifier]; |
| 112 DCHECK(node); | 112 DCHECK(node); |
| 113 | 113 |
| 114 Browser* browser = chrome::FindTabbedBrowser(bridge_->GetProfile(), true); | 114 Browser* browser = chrome::FindTabbedBrowser(bridge_->GetProfile(), true); |
| 115 if (!browser) { | 115 if (!browser) { |
| 116 browser = new Browser(Browser::CreateParams(bridge_->GetProfile())); | 116 browser = new Browser(Browser::CreateParams(bridge_->GetProfile(), true)); |
| 117 } | 117 } |
| 118 DCHECK(browser); | 118 DCHECK(browser); |
| 119 | 119 |
| 120 if (!node || !browser) | 120 if (!node || !browser) |
| 121 return; // shouldn't be reached | 121 return; // shouldn't be reached |
| 122 | 122 |
| 123 chrome::OpenAll(NULL, browser, node, disposition, browser->profile()); | 123 chrome::OpenAll(NULL, browser, node, disposition, browser->profile()); |
| 124 | 124 |
| 125 if (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) { | 125 if (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) { |
| 126 content::RecordAction(UserMetricsAction("OpenAllBookmarks")); | 126 content::RecordAction(UserMetricsAction("OpenAllBookmarks")); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 152 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_WINDOW; | 152 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_WINDOW; |
| 153 [self openAll:[sender tag] withDisposition:disposition]; | 153 [self openAll:[sender tag] withDisposition:disposition]; |
| 154 } | 154 } |
| 155 | 155 |
| 156 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender { | 156 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender { |
| 157 WindowOpenDisposition disposition = WindowOpenDisposition::OFF_THE_RECORD; | 157 WindowOpenDisposition disposition = WindowOpenDisposition::OFF_THE_RECORD; |
| 158 [self openAll:[sender tag] withDisposition:disposition]; | 158 [self openAll:[sender tag] withDisposition:disposition]; |
| 159 } | 159 } |
| 160 | 160 |
| 161 @end // BookmarkMenuCocoaController | 161 @end // BookmarkMenuCocoaController |
| OLD | NEW |