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

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

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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/views/bookmarks/bookmark_menu_delegate.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/bookmarks/bookmark_node_data.h" 9 #include "chrome/browser/bookmarks/bookmark_node_data.h"
10 #include "chrome/browser/bookmarks/bookmark_utils.h" 10 #include "chrome/browser/bookmarks/bookmark_utils.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if (!node->IsVisible() || node->GetTotalNodeCount() == 1) 429 if (!node->IsVisible() || node->GetTotalNodeCount() == 1)
430 return; // No children, don't create a menu. 430 return; // No children, don't create a menu.
431 431
432 if (!*added_separator) { 432 if (!*added_separator) {
433 *added_separator = true; 433 *added_separator = true;
434 menu->AppendSeparator(); 434 menu->AppendSeparator();
435 } 435 }
436 int id = *next_menu_id; 436 int id = *next_menu_id;
437 (*next_menu_id)++; 437 (*next_menu_id)++;
438 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 438 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
439 SkBitmap* folder_icon = rb.GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); 439 gfx::ImageSkia* folder_icon = rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER);
440 MenuItemView* submenu = menu->AppendSubMenuWithIcon( 440 MenuItemView* submenu = menu->AppendSubMenuWithIcon(
441 id, node->GetTitle(), *folder_icon); 441 id, node->GetTitle(), *folder_icon);
442 BuildMenu(node, 0, submenu, next_menu_id); 442 BuildMenu(node, 0, submenu, next_menu_id);
443 menu_id_to_node_map_[id] = node; 443 menu_id_to_node_map_[id] = node;
444 } 444 }
445 445
446 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent, 446 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent,
447 int start_child_index, 447 int start_child_index,
448 MenuItemView* menu, 448 MenuItemView* menu,
449 int* next_menu_id) { 449 int* next_menu_id) {
450 DCHECK(parent->empty() || start_child_index < parent->child_count()); 450 DCHECK(parent->empty() || start_child_index < parent->child_count());
451 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 451 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
452 for (int i = start_child_index; i < parent->child_count(); ++i) { 452 for (int i = start_child_index; i < parent->child_count(); ++i) {
453 const BookmarkNode* node = parent->GetChild(i); 453 const BookmarkNode* node = parent->GetChild(i);
454 int id = *next_menu_id; 454 int id = *next_menu_id;
455 455
456 (*next_menu_id)++; 456 (*next_menu_id)++;
457 if (node->is_url()) { 457 if (node->is_url()) {
458 SkBitmap icon = profile_->GetBookmarkModel()->GetFavicon(node); 458 gfx::ImageSkia icon = gfx::ImageSkia(
459 profile_->GetBookmarkModel()->GetFavicon(node));
459 if (icon.width() == 0) { 460 if (icon.width() == 0) {
460 icon = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 461 icon = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
461 } 462 }
462 menu->AppendMenuItemWithIcon(id, node->GetTitle(), icon); 463 menu->AppendMenuItemWithIcon(id, node->GetTitle(), icon);
463 node_to_menu_id_map_[node] = id; 464 node_to_menu_id_map_[node] = id;
464 } else if (node->is_folder()) { 465 } else if (node->is_folder()) {
465 SkBitmap* folder_icon = rb.GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); 466 gfx::ImageSkia* folder_icon =
467 rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER);
466 MenuItemView* submenu = menu->AppendSubMenuWithIcon( 468 MenuItemView* submenu = menu->AppendSubMenuWithIcon(
467 id, node->GetTitle(), *folder_icon); 469 id, node->GetTitle(), *folder_icon);
468 node_to_menu_id_map_[node] = id; 470 node_to_menu_id_map_[node] = id;
469 BuildMenu(node, 0, submenu, next_menu_id); 471 BuildMenu(node, 0, submenu, next_menu_id);
470 } else { 472 } else {
471 NOTREACHED(); 473 NOTREACHED();
472 } 474 }
473 menu_id_to_node_map_[id] = node; 475 menu_id_to_node_map_[id] = node;
474 } 476 }
475 } 477 }
476 478
477 MenuItemView* BookmarkMenuDelegate::GetMenuByID(int id) { 479 MenuItemView* BookmarkMenuDelegate::GetMenuByID(int id) {
478 for (NodeToMenuMap::const_iterator i = node_to_menu_map_.begin(); 480 for (NodeToMenuMap::const_iterator i = node_to_menu_map_.begin();
479 i != node_to_menu_map_.end(); ++i) { 481 i != node_to_menu_map_.end(); ++i) {
480 MenuItemView* menu = i->second->GetMenuItemByID(id); 482 MenuItemView* menu = i->second->GetMenuItemByID(id);
481 if (menu) 483 if (menu)
482 return menu; 484 return menu;
483 } 485 }
484 486
485 return parent_menu_item_ ? parent_menu_item_->GetMenuItemByID(id) : NULL; 487 return parent_menu_item_ ? parent_menu_item_->GetMenuItemByID(id) : NULL;
486 } 488 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | chrome/browser/ui/views/constrained_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698