From 02211ea22720579a995619d295c227b0d80f48d9 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Thu, 8 Sep 2016 12:08:55 +0900 Subject: [PATCH] Cancel to open bookmarks if "how to open the bookmark folder?" confirmation dialog is canceled. See: https://github.com/piroor/treestyletab/issues/1155 --- modules/base.js | 3 ++- modules/bookmark.js | 6 +++++- modules/constants.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/base.js b/modules/base.js index fff7d4e4..856fab3d 100644 --- a/modules/base.js +++ b/modules/base.js @@ -335,7 +335,8 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, { ); if (button < 0) - button = 1; + return this.kGROUP_BOOKMARK_CANCEL; + var behaviors = [ this.kGROUP_BOOKMARK_SUBTREE | dummyTabFlag, this.kGROUP_BOOKMARK_SEPARATE diff --git a/modules/bookmark.js b/modules/bookmark.js index 7883cb02..d3ad98e8 100644 --- a/modules/bookmark.js +++ b/modules/bookmark.js @@ -297,7 +297,8 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, { var TST = aBrowserWindow.TreeStyleTabService; result.behavior = TST.openGroupBookmarkBehavior(); - if (result.behavior & this.kGROUP_BOOKMARK_SUBTREE) { + if (result.behavior != this.kGROUP_BOOKMARK_CANCEL && + result.behavior & this.kGROUP_BOOKMARK_SUBTREE) { log('handleTabsOpenProcess: open as a group'); let treeStructure = result.behavior & this.kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE ? null : @@ -429,6 +430,9 @@ PlacesUIUtils._openTabset = function(aItemsToOpen, aEvent, aWindow, ...aArgs) { var result = BS.handleTabsOpenProcess(where, aEvent, w, ids, uris, aItemsToOpen, this.__treestyletab__folderName); log(' result: ', result); + if (result.behavior == this.kGROUP_BOOKMARK_CANCEL) + return; + var tabs = TST.doAndGetNewTabs((function() { this.__treestyletab__openTabset(aItemsToOpen, aEvent, aWindow, ...aArgs); }).bind(this), w.gBrowser); diff --git a/modules/constants.js b/modules/constants.js index a5e565a0..3b8945ec 100644 --- a/modules/constants.js +++ b/modules/constants.js @@ -235,6 +235,7 @@ var TreeStyleTabConstants = Object.freeze({ kGROUP_BOOKMARK_USE_DUMMY_FORCE : 1024, kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE : 512, kGROUP_BOOKMARK_EXPAND_ALL_TREE : 2048, + kGROUP_BOOKMARK_CANCEL : -1, CONTENT_SCRIPT : 'chrome://treestyletab/content/content-utils.js',