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" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources_standard.h" | 17 #include "grit/theme_resources_standard.h" |
| 18 #include "grit/ui_resources_standard.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
21 #include "ui/gfx/mac/nsimage_cache.h" | 22 #include "ui/gfx/mac/nsimage_cache.h" |
22 | 23 |
23 BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile, NSMenu* menu) | 24 BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile, NSMenu* menu) |
24 : menuIsValid_(false), | 25 : menuIsValid_(false), |
25 profile_(profile), | 26 profile_(profile), |
26 controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this | 27 controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this |
27 andMenu:menu]) { | 28 andMenu:menu]) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 [item setToolTip:[BookmarkMenuCocoaController tooltipForNode:node]]; | 303 [item setToolTip:[BookmarkMenuCocoaController tooltipForNode:node]]; |
303 // Check to see if we have a favicon. | 304 // Check to see if we have a favicon. |
304 NSImage* favicon = nil; | 305 NSImage* favicon = nil; |
305 BookmarkModel* model = GetBookmarkModel(); | 306 BookmarkModel* model = GetBookmarkModel(); |
306 if (model) { | 307 if (model) { |
307 const gfx::Image& image = model->GetFavicon(node); | 308 const gfx::Image& image = model->GetFavicon(node); |
308 if (!image.IsEmpty()) | 309 if (!image.IsEmpty()) |
309 favicon = image.ToNSImage(); | 310 favicon = image.ToNSImage(); |
310 } | 311 } |
311 // If we do not have a loaded favicon, use the default site image instead. | 312 // If we do not have a loaded favicon, use the default site image instead. |
312 if (!favicon) | 313 if (!favicon) { |
313 favicon = gfx::GetCachedImageWithName(@"nav.pdf"); | 314 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 315 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); |
| 316 } |
314 [item setImage:favicon]; | 317 [item setImage:favicon]; |
315 } | 318 } |
316 | 319 |
317 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 320 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
318 if (!node) | 321 if (!node) |
319 return nil; | 322 return nil; |
320 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 323 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
321 bookmark_nodes_.find(node); | 324 bookmark_nodes_.find(node); |
322 if (it == bookmark_nodes_.end()) | 325 if (it == bookmark_nodes_.end()) |
323 return nil; | 326 return nil; |
324 return it->second; | 327 return it->second; |
325 } | 328 } |
OLD | NEW |