summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 15:39:44 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 15:39:44 +0000
commit5a43397bd2e2fdceecf359a8430db0983fd3dba8 (patch)
tree0fd16a46f42548fd2a00e3c646846577e67a9c0b /chrome
parent66d12ca5dad733c6d148509d2d145de1ef80ab14 (diff)
downloadchromium_src-5a43397bd2e2fdceecf359a8430db0983fd3dba8.zip
chromium_src-5a43397bd2e2fdceecf359a8430db0983fd3dba8.tar.gz
chromium_src-5a43397bd2e2fdceecf359a8430db0983fd3dba8.tar.bz2
Fixes two bookmark manager bugs:
. Pressing enter when more than one folder is selected opens them all. . Show in folder is only enabled when it makes sense: you've selected a bookmark in the table and the table is showing recently bookmarked or search results. BUG=4034 4044 TEST=see bugs Review URL: http://codereview.chromium.org/9367 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu.cc8
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu.h8
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu_test.cc19
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc15
4 files changed, 39 insertions, 11 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu.cc b/chrome/browser/bookmarks/bookmark_context_menu.cc
index 0e45493..e25f4fa 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu.cc
@@ -261,7 +261,9 @@ BookmarkContextMenu::BookmarkContextMenu(
l10n_util::GetString(IDS_BOOKMARK_BAR_REMOVE));
if (configuration == BOOKMARK_MANAGER_TABLE ||
- configuration == BOOKMARK_MANAGER_ORGANIZE_MENU) {
+ configuration == BOOKMARK_MANAGER_TABLE_OTHER ||
+ configuration == BOOKMARK_MANAGER_ORGANIZE_MENU ||
+ configuration == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) {
menu_->AppendMenuItemWithLabel(
IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER,
l10n_util::GetString(IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER));
@@ -442,8 +444,8 @@ bool BookmarkContextMenu::IsCommandEnabled(int id) const {
return !selection_.empty() && !is_root_node;
case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER:
- return (configuration_ == BOOKMARK_MANAGER_TABLE ||
- configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU) &&
+ return (configuration_ == BOOKMARK_MANAGER_TABLE_OTHER ||
+ configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) &&
selection_.size() == 1;
case IDS_BOOMARK_BAR_NEW_FOLDER:
diff --git a/chrome/browser/bookmarks/bookmark_context_menu.h b/chrome/browser/bookmarks/bookmark_context_menu.h
index 2991637..80769ff 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu.h
+++ b/chrome/browser/bookmarks/bookmark_context_menu.h
@@ -23,8 +23,14 @@ class BookmarkContextMenu : public views::MenuDelegate,
enum ConfigurationType {
BOOKMARK_BAR,
BOOKMARK_MANAGER_TABLE,
+ // Used when the source is the table in the bookmark manager and the table
+ // is showing recently bookmarked or searched.
+ BOOKMARK_MANAGER_TABLE_OTHER,
BOOKMARK_MANAGER_TREE,
- BOOKMARK_MANAGER_ORGANIZE_MENU
+ BOOKMARK_MANAGER_ORGANIZE_MENU,
+ // Used when the source is the bookmark manager and the table is showing
+ // recently bookmarked or searched.
+ BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER
};
// Creates the bookmark context menu.
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_test.cc b/chrome/browser/bookmarks/bookmark_context_menu_test.cc
index e665058..3f0e063 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu_test.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu_test.cc
@@ -269,3 +269,22 @@ TEST_F(BookmarkContextMenuTest, DisabledItemsWithOtherNode) {
EXPECT_FALSE(controller.IsCommandEnabled(IDS_BOOKMARK_BAR_EDIT));
EXPECT_FALSE(controller.IsCommandEnabled(IDS_BOOKMARK_BAR_REMOVE));
}
+
+// Tests the enabled state of the menus when supplied an empty vector and null
+// parent.
+TEST_F(BookmarkContextMenuTest, EmptyNodesNullParent) {
+ BookmarkContextMenu controller(
+ NULL, profile_.get(), NULL, NULL, NULL, std::vector<BookmarkNode*>(),
+ BookmarkContextMenu::BOOKMARK_MANAGER_ORGANIZE_MENU);
+ EXPECT_FALSE(controller.IsCommandEnabled(IDS_BOOMARK_BAR_OPEN_ALL));
+ EXPECT_FALSE(
+ controller.IsCommandEnabled(IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW));
+ EXPECT_FALSE(controller.IsCommandEnabled(IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO));
+ EXPECT_FALSE(controller.IsCommandEnabled(IDS_BOOKMARK_BAR_REMOVE));
+ EXPECT_FALSE(
+ controller.IsCommandEnabled(IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER));
+ EXPECT_FALSE(
+ controller.IsCommandEnabled(IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK));
+ EXPECT_FALSE(
+ controller.IsCommandEnabled(IDS_BOOMARK_BAR_NEW_FOLDER));
+}
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index 4cc816f..9650e92 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.cc
@@ -436,20 +436,21 @@ void BookmarkManagerView::ShowMenu(
(config == BookmarkContextMenu::BOOKMARK_MANAGER_ORGANIZE_MENU &&
table_view_->HasFocus())) {
std::vector<BookmarkNode*> nodes = GetSelectedTableNodes();
- if (nodes.empty())
- return;
-
BookmarkNode* parent = GetSelectedFolder();
+ if (!parent) {
+ if (config == BookmarkContextMenu::BOOKMARK_MANAGER_TABLE)
+ config = BookmarkContextMenu::BOOKMARK_MANAGER_TABLE_OTHER;
+ else
+ config = BookmarkContextMenu::BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER;
+ }
BookmarkContextMenu menu(host, profile_, NULL, NULL, parent, nodes,
config);
menu.RunMenuAt(x, y);
} else {
BookmarkNode* node = GetSelectedFolder();
- if (!node)
- return;
-
std::vector<BookmarkNode*> nodes;
- nodes.push_back(node);
+ if (node)
+ nodes.push_back(node);
BookmarkContextMenu menu(GetContainer()->GetHWND(), profile_, NULL, NULL,
node, nodes, config);
menu.RunMenuAt(x, y);