Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 1550173002: Fix bug in not exiting menu when choosing 'delete' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 } 1503 }
1504 1504
1505 void BookmarkBarView::ShowContextMenuForView(views::View* source, 1505 void BookmarkBarView::ShowContextMenuForView(views::View* source,
1506 const gfx::Point& point, 1506 const gfx::Point& point,
1507 ui::MenuSourceType source_type) { 1507 ui::MenuSourceType source_type) {
1508 if (!model_->loaded()) { 1508 if (!model_->loaded()) {
1509 // Don't do anything if the model isn't loaded. 1509 // Don't do anything if the model isn't loaded.
1510 return; 1510 return;
1511 } 1511 }
1512 1512
1513 const BookmarkNode* parent = NULL; 1513 const BookmarkNode* parent = nullptr;
1514 std::vector<const BookmarkNode*> nodes; 1514 std::vector<const BookmarkNode*> nodes;
1515 if (source == other_bookmarks_button_) { 1515 if (source == other_bookmarks_button_) {
1516 parent = model_->other_node(); 1516 parent = model_->other_node();
1517 // Do this so the user can open all bookmarks. BookmarkContextMenu makes 1517 // Do this so the user can open all bookmarks. BookmarkContextMenu makes
1518 // sure the user can't edit/delete the node in this case. 1518 // sure the user can't edit/delete the node in this case.
1519 nodes.push_back(parent); 1519 nodes.push_back(parent);
1520 } else if (source == managed_bookmarks_button_) { 1520 } else if (source == managed_bookmarks_button_) {
1521 parent = managed_->managed_node(); 1521 parent = managed_->managed_node();
1522 nodes.push_back(parent); 1522 nodes.push_back(parent);
1523 } else if (source == supervised_bookmarks_button_) { 1523 } else if (source == supervised_bookmarks_button_) {
1524 parent = managed_->supervised_node(); 1524 parent = managed_->supervised_node();
1525 nodes.push_back(parent); 1525 nodes.push_back(parent);
1526 } else if (source != this && source != apps_page_shortcut_) { 1526 } else if (source != this && source != apps_page_shortcut_) {
1527 // User clicked on one of the bookmark buttons, find which one they 1527 // User clicked on one of the bookmark buttons, find which one they
1528 // clicked on, except for the apps page shortcut, which must behave as if 1528 // clicked on, except for the apps page shortcut, which must behave as if
1529 // the user clicked on the bookmark bar background. 1529 // the user clicked on the bookmark bar background.
1530 int bookmark_button_index = GetIndexOf(source); 1530 int bookmark_button_index = GetIndexOf(source);
1531 DCHECK(bookmark_button_index != -1 && 1531 DCHECK(bookmark_button_index != -1 &&
1532 bookmark_button_index < GetBookmarkButtonCount()); 1532 bookmark_button_index < GetBookmarkButtonCount());
1533 const BookmarkNode* node = 1533 const BookmarkNode* node =
1534 model_->bookmark_bar_node()->GetChild(bookmark_button_index); 1534 model_->bookmark_bar_node()->GetChild(bookmark_button_index);
1535 nodes.push_back(node); 1535 nodes.push_back(node);
1536 parent = node->parent(); 1536 parent = node->parent();
1537 } else { 1537 } else {
1538 parent = model_->bookmark_bar_node(); 1538 parent = model_->bookmark_bar_node();
1539 nodes.push_back(parent); 1539 nodes.push_back(parent);
1540 } 1540 }
1541 bool close_on_remove = 1541 // |close_on_remove| only matters for nested menus. We're not nested at this
1542 (parent == model_->other_node()) && (parent->child_count() == 1); 1542 // point, so this value has no effect.
1543 const bool close_on_remove = true;
1543 1544
1544 context_menu_.reset(new BookmarkContextMenu( 1545 context_menu_.reset(new BookmarkContextMenu(
1545 GetWidget(), browser_, browser_->profile(), 1546 GetWidget(), browser_, browser_->profile(),
1546 browser_->tab_strip_model()->GetActiveWebContents(), 1547 browser_->tab_strip_model()->GetActiveWebContents(),
1547 parent, nodes, close_on_remove)); 1548 parent, nodes, close_on_remove));
1548 context_menu_->RunMenuAt(point, source_type); 1549 context_menu_->RunMenuAt(point, source_type);
1549 } 1550 }
1550 1551
1551 void BookmarkBarView::Init() { 1552 void BookmarkBarView::Init() {
1552 // Note that at this point we're not in a hierarchy so GetThemeProvider() will 1553 // Note that at this point we're not in a hierarchy so GetThemeProvider() will
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 return; 2105 return;
2105 apps_page_shortcut_->SetVisible(visible); 2106 apps_page_shortcut_->SetVisible(visible);
2106 UpdateBookmarksSeparatorVisibility(); 2107 UpdateBookmarksSeparatorVisibility();
2107 LayoutAndPaint(); 2108 LayoutAndPaint();
2108 } 2109 }
2109 2110
2110 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2111 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2111 if (UpdateOtherAndManagedButtonsVisibility()) 2112 if (UpdateOtherAndManagedButtonsVisibility())
2112 LayoutAndPaint(); 2113 LayoutAndPaint();
2113 } 2114 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698