Index: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc |
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc |
index a7aa7da40eb34fd16fe8749b488f0229fe8f6c12..876a6aa51a83b76a86747680b1dfc362ccf15f1a 100644 |
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc |
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc |
@@ -7,6 +7,7 @@ |
#include "base/prefs/pref_service.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/bookmarks/bookmark_model_factory.h" |
+#include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
#include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
@@ -71,12 +72,23 @@ void BookmarkMenuDelegate::Init(views::MenuDelegate* real_delegate, |
location_ = location; |
if (parent) { |
parent_menu_item_ = parent; |
+ |
+ // Add a separator if there are existing items in the menu, and if the |
+ // current node has children. If |node| is the bookmark bar then the |
+ // managed node is shown as its first child, if it's not empty. |
+ BookmarkModel* model = GetBookmarkModel(); |
+ ChromeBookmarkClient* client = GetChromeBookmarkClient(); |
+ bool show_managed = show_options == SHOW_PERMANENT_FOLDERS && |
+ node == model->bookmark_bar_node() && |
+ !client->managed_node()->empty(); |
+ bool has_children = |
+ (start_child_index < node->child_count()) || show_managed; |
int initial_count = parent->GetSubmenu() ? |
parent->GetSubmenu()->GetMenuItemCount() : 0; |
- if ((start_child_index < node->child_count()) && |
- (initial_count > 0)) { |
+ if (has_children && initial_count > 0) |
parent->AppendSeparator(); |
- } |
+ if (show_managed) |
+ BuildMenuForManagedNode(parent, &next_menu_id_); |
BuildMenu(node, start_child_index, parent, &next_menu_id_); |
if (show_options == SHOW_PERMANENT_FOLDERS) |
BuildMenusForPermanentNodes(parent, &next_menu_id_); |
@@ -95,6 +107,10 @@ BookmarkModel* BookmarkMenuDelegate::GetBookmarkModel() { |
return BookmarkModelFactory::GetForProfile(profile_); |
} |
+ChromeBookmarkClient* BookmarkMenuDelegate::GetChromeBookmarkClient() { |
+ return BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile_); |
+} |
+ |
void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node, |
int start_index) { |
DCHECK(!parent_menu_item_); |
@@ -270,8 +286,9 @@ int BookmarkMenuDelegate::OnPerformDrop( |
break; |
} |
+ bool copy = event.source_operations() == ui::DragDropTypes::DRAG_COPY; |
return chrome::DropBookmarks(profile_, drop_data_, |
- drop_parent, index_to_drop_at); |
+ drop_parent, index_to_drop_at, copy); |
} |
bool BookmarkMenuDelegate::ShowContextMenu(MenuItemView* source, |
@@ -409,8 +426,11 @@ MenuItemView* BookmarkMenuDelegate::CreateMenu(const BookmarkNode* parent, |
menu->SetCommand(next_menu_id_++); |
menu_id_to_node_map_[menu->GetCommand()] = parent; |
menu->set_has_icons(true); |
+ bool show_permanent = show_options == SHOW_PERMANENT_FOLDERS; |
+ if (show_permanent && parent == GetBookmarkModel()->bookmark_bar_node()) |
+ BuildMenuForManagedNode(menu, &next_menu_id_); |
BuildMenu(parent, start_child_index, menu, &next_menu_id_); |
- if (show_options == SHOW_PERMANENT_FOLDERS) |
+ if (show_permanent) |
BuildMenusForPermanentNodes(menu, &next_menu_id_); |
return menu; |
} |
@@ -453,6 +473,17 @@ void BookmarkMenuDelegate::BuildMenuForPermanentNode( |
menu_id_to_node_map_[id] = node; |
} |
+void BookmarkMenuDelegate::BuildMenuForManagedNode( |
+ MenuItemView* menu, |
+ int* next_menu_id) { |
+ // Don't add a separator for this menu. |
+ bool added_separator = true; |
+ const BookmarkNode* node = GetChromeBookmarkClient()->managed_node(); |
+ // TODO(joaodasilva): use the "managed bookmark folder" icon here. |
+ // http://crbug.com/49598 |
+ BuildMenuForPermanentNode(node, menu, next_menu_id, &added_separator); |
+} |
+ |
void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent, |
int start_child_index, |
MenuItemView* menu, |