Commit 48abb004 authored by sky@chromium.org's avatar sky@chromium.org

Lands http://codereview.chromium.org/291006 for Pierre:

Open all bookmarks in a bookmark menu folder according to the window disposition derived from the event flags. This is currently only possible with a middle click on the top level bookmark bar button. 

BUG=19597
TEST=Control click a folder on your bookmark bar, and thorougly test
bookmark bar, especially with folders.

Review URL: http://codereview.chromium.org/334047

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30281 0039d316-1c4b-4281-b951-d872f2087c98
parent b1d3f6c4
...@@ -227,9 +227,15 @@ class BookmarkFolderButton : public views::MenuButton { ...@@ -227,9 +227,15 @@ class BookmarkFolderButton : public views::MenuButton {
} }
virtual bool IsTriggerableEvent(const views::MouseEvent& e) { virtual bool IsTriggerableEvent(const views::MouseEvent& e) {
// This is hard coded to avoid potential notification on left mouse down, // Left clicks should show the menu contents and right clicks should show
// which we want to show the menu. // the context menu. They should not trigger the opening of underlying urls.
return e.IsMiddleMouseButton(); if (e.GetFlags() == views::MouseEvent::EF_LEFT_BUTTON_DOWN ||
e.GetFlags() == views::MouseEvent::EF_RIGHT_BUTTON_DOWN)
return false;
WindowOpenDisposition disposition(
event_utils::DispositionFromEventFlags(e.GetFlags()));
return disposition != CURRENT_TAB;
} }
virtual void Paint(gfx::Canvas *canvas) { virtual void Paint(gfx::Canvas *canvas) {
......
...@@ -89,10 +89,16 @@ bool BookmarkMenuController::IsTriggerableEvent(const views::MouseEvent& e) { ...@@ -89,10 +89,16 @@ bool BookmarkMenuController::IsTriggerableEvent(const views::MouseEvent& e) {
void BookmarkMenuController::ExecuteCommand(int id, int mouse_event_flags) { void BookmarkMenuController::ExecuteCommand(int id, int mouse_event_flags) {
DCHECK(page_navigator_); DCHECK(page_navigator_);
DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end()); DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end());
GURL url = menu_id_to_node_map_[id]->GetURL();
page_navigator_->OpenURL( const BookmarkNode* node = menu_id_to_node_map_[id];
url, GURL(), event_utils::DispositionFromEventFlags(mouse_event_flags), std::vector<const BookmarkNode*> selection;
PageTransition::AUTO_BOOKMARK); selection.push_back(node);
WindowOpenDisposition initial_disposition =
event_utils::DispositionFromEventFlags(mouse_event_flags);
bookmark_utils::OpenAll(parent_, profile_, page_navigator_, selection,
initial_disposition);
} }
bool BookmarkMenuController::GetDropFormats( bool BookmarkMenuController::GetDropFormats(
......
...@@ -189,8 +189,8 @@ bool MenuButton::OnMousePressed(const MouseEvent& e) { ...@@ -189,8 +189,8 @@ bool MenuButton::OnMousePressed(const MouseEvent& e) {
void MenuButton::OnMouseReleased(const MouseEvent& e, void MenuButton::OnMouseReleased(const MouseEvent& e,
bool canceled) { bool canceled) {
if (GetDragOperations(e.x(), e.y()) != DragDropTypes::DRAG_NONE && if (GetDragOperations(e.x(), e.y()) != DragDropTypes::DRAG_NONE &&
state() != BS_DISABLED && !canceled && !InDrag() && state() != BS_DISABLED && !canceled && !InDrag() && !IsTriggerableEvent(e)
e.IsOnlyLeftMouseButton() && HitTest(e.location())) { && HitTest(e.location())) {
Activate(); Activate();
} else { } else {
TextButton::OnMouseReleased(e, canceled); TextButton::OnMouseReleased(e, canceled);
......
...@@ -439,7 +439,11 @@ void MenuController::OnMouseReleased(SubmenuView* source, ...@@ -439,7 +439,11 @@ void MenuController::OnMouseReleased(SubmenuView* source,
return; return;
} }
if (!part.is_scroll() && part.menu && !part.menu->HasSubmenu()) { // We can use Ctrl+click or the middle mouse button to recursively open urls
// for selected folder menu items. If it's only a left click, show the
// contents of the folder.
if (!part.is_scroll() && part.menu && !(part.menu->HasSubmenu() &&
(event.GetFlags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) {
if (part.menu->GetDelegate()->IsTriggerableEvent(event)) { if (part.menu->GetDelegate()->IsTriggerableEvent(event)) {
Accept(part.menu, event.GetFlags()); Accept(part.menu, event.GetFlags());
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment