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

Side by Side Diff: chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.cc

Issue 112913004: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
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/gtk/bookmarks/bookmark_sub_menu_model_gtk.h" 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void BookmarkNodeMenuModel::PopulateMenu() { 75 void BookmarkNodeMenuModel::PopulateMenu() {
76 DCHECK(submenus_.empty()); 76 DCHECK(submenus_.empty());
77 for (int i = 0; i < node_->child_count(); ++i) { 77 for (int i = 0; i < node_->child_count(); ++i) {
78 const BookmarkNode* child = node_->GetChild(i); 78 const BookmarkNode* child = node_->GetChild(i);
79 if (child->is_folder()) { 79 if (child->is_folder()) {
80 AddSubMenuForNode(child); 80 AddSubMenuForNode(child);
81 } else { 81 } else {
82 // Ironically the label will end up getting converted back to UTF8 later. 82 // Ironically the label will end up getting converted back to UTF8 later.
83 // We need to escape any Windows-style "&" characters since they will be 83 // We need to escape any Windows-style "&" characters since they will be
84 // converted in MenuGtk outside of our control here. 84 // converted in MenuGtk outside of our control here.
85 const base::string16 label = UTF8ToUTF16( 85 const base::string16 label = base::UTF8ToUTF16(
86 ui::EscapeWindowsStyleAccelerators(BuildMenuLabelFor(child))); 86 ui::EscapeWindowsStyleAccelerators(BuildMenuLabelFor(child)));
87 // No command id. We override ActivatedAt below to handle activations. 87 // No command id. We override ActivatedAt below to handle activations.
88 AddItem(kBookmarkItemCommandId, label); 88 AddItem(kBookmarkItemCommandId, label);
89 GdkPixbuf* node_icon = GetPixbufForNode( 89 GdkPixbuf* node_icon = GetPixbufForNode(
90 child, 90 child,
91 model_, 91 model_,
92 GtkThemeService::GetFrom(profile_)->UsingNativeTheme()); 92 GtkThemeService::GetFrom(profile_)->UsingNativeTheme());
93 SetIcon(GetItemCount() - 1, gfx::Image(node_icon)); 93 SetIcon(GetItemCount() - 1, gfx::Image(node_icon));
94 // TODO(mdm): set up an observer to watch for icon load events and set 94 // TODO(mdm): set up an observer to watch for icon load events and set
95 // the icons in response. 95 // the icons in response.
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 void BookmarkNodeMenuModel::AddSubMenuForNode(const BookmarkNode* node) { 100 void BookmarkNodeMenuModel::AddSubMenuForNode(const BookmarkNode* node) {
101 DCHECK(node->is_folder()); 101 DCHECK(node->is_folder());
102 // Ironically the label will end up getting converted back to UTF8 later. 102 // Ironically the label will end up getting converted back to UTF8 later.
103 // We need to escape any Windows-style "&" characters since they will be 103 // We need to escape any Windows-style "&" characters since they will be
104 // converted in MenuGtk outside of our control here. 104 // converted in MenuGtk outside of our control here.
105 const base::string16 label = 105 const base::string16 label = base::UTF8ToUTF16(
106 UTF8ToUTF16(ui::EscapeWindowsStyleAccelerators(BuildMenuLabelFor(node))); 106 ui::EscapeWindowsStyleAccelerators(BuildMenuLabelFor(node)));
107 // Don't pass in the delegate, if any. Bookmark submenus don't need one. 107 // Don't pass in the delegate, if any. Bookmark submenus don't need one.
108 BookmarkNodeMenuModel* submenu = 108 BookmarkNodeMenuModel* submenu =
109 new BookmarkNodeMenuModel(NULL, model_, node, page_navigator_, profile_); 109 new BookmarkNodeMenuModel(NULL, model_, node, page_navigator_, profile_);
110 // No command id. Nothing happens if you click on the submenu itself. 110 // No command id. Nothing happens if you click on the submenu itself.
111 AddSubMenu(kBookmarkItemCommandId, label, submenu); 111 AddSubMenu(kBookmarkItemCommandId, label, submenu);
112 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 112 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
113 const gfx::Image& folder_icon = rb.GetImageNamed(IDR_BOOKMARK_BAR_FOLDER); 113 const gfx::Image& folder_icon = rb.GetImageNamed(IDR_BOOKMARK_BAR_FOLDER);
114 SetIcon(GetItemCount() - 1, folder_icon); 114 SetIcon(GetItemCount() - 1, folder_icon);
115 submenus_.push_back(submenu); 115 submenus_.push_back(submenu);
116 } 116 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 bool BookmarkSubMenuModel::IsVisibleAt(int index) const { 233 bool BookmarkSubMenuModel::IsVisibleAt(int index) const {
234 // We don't want the delegate interfering with bookmark items. 234 // We don't want the delegate interfering with bookmark items.
235 return index >= fixed_items_ || SimpleMenuModel::IsVisibleAt(index); 235 return index >= fixed_items_ || SimpleMenuModel::IsVisibleAt(index);
236 } 236 }
237 237
238 // static 238 // static
239 bool BookmarkSubMenuModel::IsBookmarkItemCommandId(int command_id) { 239 bool BookmarkSubMenuModel::IsBookmarkItemCommandId(int command_id) {
240 return command_id == kBookmarkItemCommandId; 240 return command_id == kBookmarkItemCommandId;
241 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698