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

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

Issue 7327010: Makes the bookmark menu show a separator before other bookmarks. (Closed) Base URL: svn://svn.chromium.org/chrome/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 | « no previous file | 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-inl.h" 7 #include "base/stl_util-inl.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"
11 #include "chrome/browser/bookmarks/bookmark_utils.h" 11 #include "chrome/browser/bookmarks/bookmark_utils.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 14 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
15 #include "chrome/browser/ui/views/event_utils.h" 15 #include "chrome/browser/ui/views/event_utils.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "content/browser/tab_contents/page_navigator.h" 17 #include "content/browser/tab_contents/page_navigator.h"
18 #include "content/browser/user_metrics.h" 18 #include "content/browser/user_metrics.h"
19 #include "content/common/page_transition_types.h" 19 #include "content/common/page_transition_types.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "grit/ui_resources.h" 22 #include "grit/ui_resources.h"
23 #include "ui/base/dragdrop/os_exchange_data.h" 23 #include "ui/base/dragdrop/os_exchange_data.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 #include "views/controls/button/menu_button.h" 26 #include "views/controls/button/menu_button.h"
27 #include "views/controls/menu/menu_item_view.h" 27 #include "views/controls/menu/menu_item_view.h"
28 #include "views/controls/menu/submenu_view.h"
28 29
29 using views::MenuItemView; 30 using views::MenuItemView;
30 31
31 // Max width of a menu. There does not appear to be an OS value for this, yet 32 // Max width of a menu. There does not appear to be an OS value for this, yet
32 // both IE and FF restrict the max width of a menu. 33 // both IE and FF restrict the max width of a menu.
33 static const int kMaxMenuWidth = 400; 34 static const int kMaxMenuWidth = 400;
34 35
35 BookmarkMenuDelegate::BookmarkMenuDelegate(Profile* profile, 36 BookmarkMenuDelegate::BookmarkMenuDelegate(Profile* profile,
36 PageNavigator* navigator, 37 PageNavigator* navigator,
37 gfx::NativeWindow parent, 38 gfx::NativeWindow parent,
(...skipping 16 matching lines...) Expand all
54 55
55 void BookmarkMenuDelegate::Init(views::MenuDelegate* real_delegate, 56 void BookmarkMenuDelegate::Init(views::MenuDelegate* real_delegate,
56 MenuItemView* parent, 57 MenuItemView* parent,
57 const BookmarkNode* node, 58 const BookmarkNode* node,
58 int start_child_index, 59 int start_child_index,
59 ShowOptions show_options) { 60 ShowOptions show_options) {
60 profile_->GetBookmarkModel()->AddObserver(this); 61 profile_->GetBookmarkModel()->AddObserver(this);
61 real_delegate_ = real_delegate; 62 real_delegate_ = real_delegate;
62 if (parent) { 63 if (parent) {
63 parent_menu_item_ = parent; 64 parent_menu_item_ = parent;
65 int initial_count = parent->GetSubmenu() ?
66 parent->GetSubmenu()->GetMenuItemCount() : 0;
64 BuildMenu(node, start_child_index, parent, &next_menu_id_); 67 BuildMenu(node, start_child_index, parent, &next_menu_id_);
65 if (show_options == SHOW_OTHER_FOLDER) 68 if (show_options == SHOW_OTHER_FOLDER) {
66 BuildOtherFolderMenu(parent, &next_menu_id_); 69 const BookmarkNode* other_folder =
70 profile_->GetBookmarkModel()->other_node();
71 if (other_folder->child_count() > 0) {
72 int current_count = parent->GetSubmenu() ?
73 parent->GetSubmenu()->GetMenuItemCount() : 0;
74 if (current_count != initial_count)
75 parent->AppendSeparator();
76 BuildOtherFolderMenu(parent, &next_menu_id_);
77 }
78 }
67 } else { 79 } else {
68 menu_ = CreateMenu(node, start_child_index, show_options); 80 menu_ = CreateMenu(node, start_child_index, show_options);
69 } 81 }
70 } 82 }
71 83
72 void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node, 84 void BookmarkMenuDelegate::SetActiveMenu(const BookmarkNode* node,
73 int start_index) { 85 int start_index) {
74 DCHECK(!parent_menu_item_); 86 DCHECK(!parent_menu_item_);
75 if (!node_to_menu_map_[node]) 87 if (!node_to_menu_map_[node])
76 CreateMenu(node, start_index, HIDE_OTHER_FOLDER); 88 CreateMenu(node, start_index, HIDE_OTHER_FOLDER);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 break; 441 break;
430 } 442 }
431 } 443 }
432 if (ancestor_removed) { 444 if (ancestor_removed) {
433 node_to_menu_id_map_.erase(i++); 445 node_to_menu_id_map_.erase(i++);
434 } else { 446 } else {
435 ++i; 447 ++i;
436 } 448 }
437 } 449 }
438 } 450 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698