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

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

Issue 7483003: Removed separator in bookmarks sub-menu if there are no bookmarks or folders to display (only fix... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | 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) 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
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->child_count() > 0) {
tfarina 2011/07/22 22:32:46 while you are here, can you change this check to !
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 BuildMenu(other_folder, 0, submenu, next_menu_id); 352 BuildMenu(other_folder, 0, submenu, next_menu_id);
352 menu_id_to_node_map_[id] = other_folder; 353 menu_id_to_node_map_[id] = other_folder;
353 } 354 }
354 355
355 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent, 356 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent,
356 int start_child_index, 357 int start_child_index,
357 MenuItemView* menu, 358 MenuItemView* menu,
358 int* next_menu_id) { 359 int* next_menu_id) {
359 DCHECK(!parent->child_count() || 360 DCHECK(!parent->child_count() ||
360 start_child_index < parent->child_count()); 361 start_child_index < parent->child_count());
362
sky 2011/07/22 22:47:00 remove this line.
361 for (int i = start_child_index; i < parent->child_count(); ++i) { 363 for (int i = start_child_index; i < parent->child_count(); ++i) {
362 const BookmarkNode* node = parent->GetChild(i); 364 const BookmarkNode* node = parent->GetChild(i);
363 int id = *next_menu_id; 365 int id = *next_menu_id;
364 366
365 (*next_menu_id)++; 367 (*next_menu_id)++;
366 if (node->is_url()) { 368 if (node->is_url()) {
367 SkBitmap icon = profile_->GetBookmarkModel()->GetFavicon(node); 369 SkBitmap icon = profile_->GetBookmarkModel()->GetFavicon(node);
368 if (icon.width() == 0) { 370 if (icon.width() == 0) {
369 icon = *ResourceBundle::GetSharedInstance(). 371 icon = *ResourceBundle::GetSharedInstance().
370 GetBitmapNamed(IDR_DEFAULT_FAVICON); 372 GetBitmapNamed(IDR_DEFAULT_FAVICON);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 break; 443 break;
442 } 444 }
443 } 445 }
444 if (ancestor_removed) { 446 if (ancestor_removed) {
445 node_to_menu_id_map_.erase(i++); 447 node_to_menu_id_map_.erase(i++);
446 } else { 448 } else {
447 ++i; 449 ++i;
448 } 450 }
449 } 451 }
450 } 452 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698