summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_bar_controller.mm
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-11 01:54:33 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-11 01:54:33 +0000
commitcaf6a6aadaa15f9e3ffe92ed938e5151cf8d05ea (patch)
tree34d3eb6f8ce1e102aa7cd77b028c1a1f109039a4 /chrome/browser/cocoa/bookmark_bar_controller.mm
parented93b29f568bd25cb637675494ef90d812534aba (diff)
downloadchromium_src-caf6a6aadaa15f9e3ffe92ed938e5151cf8d05ea.zip
chromium_src-caf6a6aadaa15f9e3ffe92ed938e5151cf8d05ea.tar.gz
chromium_src-caf6a6aadaa15f9e3ffe92ed938e5151cf8d05ea.tar.bz2
Once the initial URL is opened in a new window, insure that subsequent URLs are opened in the new window instead of the original window. This change hinges on having URL opening code return the browser into which the URL was opened so that subsequent openings may now into which browser to do so.
BUG=39901 TEST=Bring up context menu on a folder with two or more bookmarks and select "Open All in Incognito Window". Insure that all of the URLs are opened in the newly created, top-most window. Verify that no new tabs were created in the original window. Perform this same test using "Open All in New Window". Review URL: http://codereview.chromium.org/1634004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm40
1 files changed, 16 insertions, 24 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index f0e332a..9121bac 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -9,9 +9,11 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#import "chrome/browser/browser_theme_provider.h"
+#import "chrome/browser/browser_window.h"
#import "chrome/browser/cocoa/background_gradient_view.h"
#import "chrome/browser/cocoa/bookmark_bar_bridge.h"
#import "chrome/browser/cocoa/bookmark_bar_constants.h"
@@ -180,10 +182,6 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12;
- (void)watchForExitEvent:(BOOL)watch;
-// An ObjC version of bookmark_utils::OpenAllImpl().
-- (void)openBookmarkNodesRecursive:(const BookmarkNode*)node
- disposition:(WindowOpenDisposition)disposition;
-
@end
@implementation BookmarkBarController
@@ -416,7 +414,7 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12;
// bookmark folders, not a button context menu.
- (void)closeAllBookmarkFolders {
[self watchForExitEvent:NO];
- [[folderController_ window] close];
+ [folderController_ close];
folderController_ = nil;
}
@@ -1283,22 +1281,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
}
}
-- (void)openBookmarkNodesRecursive:(const BookmarkNode*)node
- disposition:(WindowOpenDisposition)disposition {
- DCHECK(node);
- for (int i = 0; i < node->GetChildCount(); i++) {
- const BookmarkNode* child = node->GetChild(i);
- if (child->is_url()) {
- [self openURL:child->GetURL() disposition:disposition];
- // We revert to a basic disposition in case the initial
- // disposition opened a new window.
- disposition = NEW_BACKGROUND_TAB;
- } else {
- [self openBookmarkNodesRecursive:child disposition:disposition];
- }
- }
-}
-
// Return the BookmarkNode associated with the given NSMenuItem. Can
// return NULL which means "do nothing". One case where it would
// return NULL is if the bookmark model gets modified while you have a
@@ -1313,10 +1295,20 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
return node;
}
+- (void)openAll:(const BookmarkNode*)node
+ disposition:(WindowOpenDisposition)disposition {
+ [self closeAllBookmarkFolders];
+ bookmark_utils::OpenAll(browser_->window()->GetNativeHandle(),
+ browser_->profile(),
+ browser_,
+ node,
+ disposition);
+}
+
- (IBAction)openAllBookmarks:(id)sender {
const BookmarkNode* node = [self nodeFromMenuItem:sender];
if (node) {
- [self openBookmarkNodesRecursive:node disposition:NEW_FOREGROUND_TAB];
+ [self openAll:node disposition:NEW_FOREGROUND_TAB];
UserMetrics::RecordAction(UserMetricsAction("OpenAllBookmarks"),
browser_->profile());
}
@@ -1325,7 +1317,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
- (IBAction)openAllBookmarksNewWindow:(id)sender {
const BookmarkNode* node = [self nodeFromMenuItem:sender];
if (node) {
- [self openBookmarkNodesRecursive:node disposition:NEW_WINDOW];
+ [self openAll:node disposition:NEW_WINDOW];
UserMetrics::RecordAction(UserMetricsAction("OpenAllBookmarksNewWindow"),
browser_->profile());
}
@@ -1334,7 +1326,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
- (IBAction)openAllBookmarksIncognitoWindow:(id)sender {
const BookmarkNode* node = [self nodeFromMenuItem:sender];
if (node) {
- [self openBookmarkNodesRecursive:node disposition:OFF_THE_RECORD];
+ [self openAll:node disposition:OFF_THE_RECORD];
UserMetrics::RecordAction(
UserMetricsAction("OpenAllBookmarksIncognitoWindow"),
browser_->profile());