| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_menu_delegate.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 10 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 MenuItemView* parent, | 57 MenuItemView* parent, |
| 58 const BookmarkNode* node, | 58 const BookmarkNode* node, |
| 59 int start_child_index, | 59 int start_child_index, |
| 60 ShowOptions show_options) { | 60 ShowOptions show_options) { |
| 61 profile_->GetBookmarkModel()->AddObserver(this); | 61 profile_->GetBookmarkModel()->AddObserver(this); |
| 62 real_delegate_ = real_delegate; | 62 real_delegate_ = real_delegate; |
| 63 if (parent) { | 63 if (parent) { |
| 64 parent_menu_item_ = parent; | 64 parent_menu_item_ = parent; |
| 65 int initial_count = parent->GetSubmenu() ? | 65 int initial_count = parent->GetSubmenu() ? |
| 66 parent->GetSubmenu()->GetMenuItemCount() : 0; | 66 parent->GetSubmenu()->GetMenuItemCount() : 0; |
| 67 if ((start_child_index < node->child_count()) && |
| 68 (initial_count > 0)) { |
| 69 parent->AppendSeparator(); |
| 70 } |
| 67 BuildMenu(node, start_child_index, parent, &next_menu_id_); | 71 BuildMenu(node, start_child_index, parent, &next_menu_id_); |
| 68 if (show_options == SHOW_OTHER_FOLDER) { | 72 if (show_options == SHOW_OTHER_FOLDER) { |
| 69 const BookmarkNode* other_folder = | 73 const BookmarkNode* other_folder = |
| 70 profile_->GetBookmarkModel()->other_node(); | 74 profile_->GetBookmarkModel()->other_node(); |
| 71 if (other_folder->child_count() > 0) { | 75 if (!other_folder->empty()) { |
| 72 int current_count = parent->GetSubmenu() ? | 76 parent->AppendSeparator(); |
| 73 parent->GetSubmenu()->GetMenuItemCount() : 0; | |
| 74 if (current_count != initial_count) | |
| 75 parent->AppendSeparator(); | |
| 76 BuildOtherFolderMenu(parent, &next_menu_id_); | 77 BuildOtherFolderMenu(parent, &next_menu_id_); |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 } else { | 80 } else { |
| 80 menu_ = CreateMenu(node, start_child_index, show_options); | 81 menu_ = CreateMenu(node, start_child_index, show_options); |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 | 84 |
| 84 void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node, | 85 void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node, |
| 85 int start_index) { | 86 int start_index) { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 break; | 442 break; |
| 442 } | 443 } |
| 443 } | 444 } |
| 444 if (ancestor_removed) { | 445 if (ancestor_removed) { |
| 445 node_to_menu_id_map_.erase(i++); | 446 node_to_menu_id_map_.erase(i++); |
| 446 } else { | 447 } else { |
| 447 ++i; | 448 ++i; |
| 448 } | 449 } |
| 449 } | 450 } |
| 450 } | 451 } |
| OLD | NEW |