| OLD | NEW |
| 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 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #import "chrome/browser/app_controller_mac.h" | 9 #import "chrome/browser/app_controller_mac.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if (menuIsValid_) | 60 if (menuIsValid_) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 BookmarkModel* model = GetBookmarkModel(); | 63 BookmarkModel* model = GetBookmarkModel(); |
| 64 if (!model || !model->IsLoaded()) | 64 if (!model || !model->IsLoaded()) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 if (!folder_image_) { | 67 if (!folder_image_) { |
| 68 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 68 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 69 folder_image_.reset( | 69 folder_image_.reset( |
| 70 [rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); | 70 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 ClearBookmarkMenu(bookmark_menu); | 73 ClearBookmarkMenu(bookmark_menu); |
| 74 | 74 |
| 75 // Add bookmark bar items, if any. | 75 // Add bookmark bar items, if any. |
| 76 const BookmarkNode* barNode = model->bookmark_bar_node(); | 76 const BookmarkNode* barNode = model->bookmark_bar_node(); |
| 77 CHECK(barNode); | 77 CHECK(barNode); |
| 78 if (!barNode->empty()) { | 78 if (!barNode->empty()) { |
| 79 [bookmark_menu addItem:[NSMenuItem separatorItem]]; | 79 [bookmark_menu addItem:[NSMenuItem separatorItem]]; |
| 80 AddNodeToMenu(barNode, bookmark_menu, !is_submenu); | 80 AddNodeToMenu(barNode, bookmark_menu, !is_submenu); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 NSImage* favicon = nil; | 306 NSImage* favicon = nil; |
| 307 BookmarkModel* model = GetBookmarkModel(); | 307 BookmarkModel* model = GetBookmarkModel(); |
| 308 if (model) { | 308 if (model) { |
| 309 const gfx::Image& image = model->GetFavicon(node); | 309 const gfx::Image& image = model->GetFavicon(node); |
| 310 if (!image.IsEmpty()) | 310 if (!image.IsEmpty()) |
| 311 favicon = image.ToNSImage(); | 311 favicon = image.ToNSImage(); |
| 312 } | 312 } |
| 313 // If we do not have a loaded favicon, use the default site image instead. | 313 // If we do not have a loaded favicon, use the default site image instead. |
| 314 if (!favicon) { | 314 if (!favicon) { |
| 315 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 315 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 316 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); | 316 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage(); |
| 317 } | 317 } |
| 318 [item setImage:favicon]; | 318 [item setImage:favicon]; |
| 319 } | 319 } |
| 320 | 320 |
| 321 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 321 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
| 322 if (!node) | 322 if (!node) |
| 323 return nil; | 323 return nil; |
| 324 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 324 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
| 325 bookmark_nodes_.find(node); | 325 bookmark_nodes_.find(node); |
| 326 if (it == bookmark_nodes_.end()) | 326 if (it == bookmark_nodes_.end()) |
| 327 return nil; | 327 return nil; |
| 328 return it->second; | 328 return it->second; |
| 329 } | 329 } |
| OLD | NEW |