| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return menu; | 339 return menu; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void BookmarkMenuDelegate::BuildOtherFolderMenu( | 342 void BookmarkMenuDelegate::BuildOtherFolderMenu( |
| 343 MenuItemView* menu, int* next_menu_id) { | 343 MenuItemView* menu, int* next_menu_id) { |
| 344 const BookmarkNode* other_folder = profile_->GetBookmarkModel()->other_node(); | 344 const BookmarkNode* other_folder = profile_->GetBookmarkModel()->other_node(); |
| 345 int id = *next_menu_id; | 345 int id = *next_menu_id; |
| 346 (*next_menu_id)++; | 346 (*next_menu_id)++; |
| 347 SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). | 347 SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). |
| 348 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); | 348 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); |
| 349 MenuItemView* submenu = menu->AppendSubMenuWithIcon( | 349 views::MenuItemInterface* submenu = menu->AppendSubMenuWithIcon( |
| 350 id, UTF16ToWide( | 350 id, UTF16ToWide( |
| 351 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED)), | 351 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED)), |
| 352 *folder_icon); | 352 *folder_icon); |
| 353 BuildMenu(other_folder, 0, submenu, next_menu_id); | 353 BuildMenu(other_folder, 0, submenu, next_menu_id); |
| 354 menu_id_to_node_map_[id] = other_folder; | 354 menu_id_to_node_map_[id] = other_folder; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent, | 357 void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent, |
| 358 int start_child_index, | 358 int start_child_index, |
| 359 MenuItemView* menu, | 359 views::MenuItemInterface* menu, |
| 360 int* next_menu_id) { | 360 int* next_menu_id) { |
| 361 DCHECK(!parent->child_count() || | 361 DCHECK(!parent->child_count() || |
| 362 start_child_index < parent->child_count()); | 362 start_child_index < parent->child_count()); |
| 363 for (int i = start_child_index; i < parent->child_count(); ++i) { | 363 for (int i = start_child_index; i < parent->child_count(); ++i) { |
| 364 const BookmarkNode* node = parent->GetChild(i); | 364 const BookmarkNode* node = parent->GetChild(i); |
| 365 int id = *next_menu_id; | 365 int id = *next_menu_id; |
| 366 | 366 |
| 367 (*next_menu_id)++; | 367 (*next_menu_id)++; |
| 368 if (node->is_url()) { | 368 if (node->is_url()) { |
| 369 SkBitmap icon = profile_->GetBookmarkModel()->GetFavicon(node); | 369 SkBitmap icon = profile_->GetBookmarkModel()->GetFavicon(node); |
| 370 if (icon.width() == 0) { | 370 if (icon.width() == 0) { |
| 371 icon = *ResourceBundle::GetSharedInstance(). | 371 icon = *ResourceBundle::GetSharedInstance(). |
| 372 GetBitmapNamed(IDR_DEFAULT_FAVICON); | 372 GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 373 } | 373 } |
| 374 menu->AppendMenuItemWithIcon(id, UTF16ToWide(node->GetTitle()), icon); | 374 menu->AppendMenuItemWithIcon(id, UTF16ToWide(node->GetTitle()), icon); |
| 375 node_to_menu_id_map_[node] = id; | 375 node_to_menu_id_map_[node] = id; |
| 376 } else if (node->is_folder()) { | 376 } else if (node->is_folder()) { |
| 377 SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). | 377 SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). |
| 378 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); | 378 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); |
| 379 MenuItemView* submenu = menu->AppendSubMenuWithIcon( | 379 views::MenuItemInterface* submenu = menu->AppendSubMenuWithIcon( |
| 380 id, UTF16ToWide(node->GetTitle()), *folder_icon); | 380 id, UTF16ToWide(node->GetTitle()), *folder_icon); |
| 381 node_to_menu_id_map_[node] = id; | 381 node_to_menu_id_map_[node] = id; |
| 382 BuildMenu(node, 0, submenu, next_menu_id); | 382 BuildMenu(node, 0, submenu, next_menu_id); |
| 383 } else { | 383 } else { |
| 384 NOTREACHED(); | 384 NOTREACHED(); |
| 385 } | 385 } |
| 386 menu_id_to_node_map_[id] = node; | 386 menu_id_to_node_map_[id] = node; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 break; | 443 break; |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 if (ancestor_removed) { | 446 if (ancestor_removed) { |
| 447 node_to_menu_id_map_.erase(i++); | 447 node_to_menu_id_map_.erase(i++); |
| 448 } else { | 448 } else { |
| 449 ++i; | 449 ++i; |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 } | 452 } |
| OLD | NEW |