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 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
6 | 6 |
7 #include "app/mac/nsimage_cache.h" | |
8 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
10 #import "chrome/browser/app_controller_mac.h" | 9 #import "chrome/browser/app_controller_mac.h" |
11 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" |
17 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
19 #include "skia/ext/skia_utils_mac.h" | 18 #include "skia/ext/skia_utils_mac.h" |
20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 22 #include "ui/gfx/mac/nsimage_cache.h" |
23 | 23 |
24 BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile) | 24 BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile) |
25 : menuIsValid_(false), | 25 : menuIsValid_(false), |
26 profile_(profile), | 26 profile_(profile), |
27 controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]) { | 27 controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]) { |
28 if (GetBookmarkModel()) | 28 if (GetBookmarkModel()) |
29 ObserveBookmarkModel(); | 29 ObserveBookmarkModel(); |
30 } | 30 } |
31 | 31 |
32 BookmarkMenuBridge::~BookmarkMenuBridge() { | 32 BookmarkMenuBridge::~BookmarkMenuBridge() { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 NSImage* favicon = nil; | 291 NSImage* favicon = nil; |
292 BookmarkModel* model = GetBookmarkModel(); | 292 BookmarkModel* model = GetBookmarkModel(); |
293 if (model) { | 293 if (model) { |
294 const SkBitmap& bitmap = model->GetFavicon(node); | 294 const SkBitmap& bitmap = model->GetFavicon(node); |
295 if (!bitmap.isNull()) | 295 if (!bitmap.isNull()) |
296 favicon = gfx::SkBitmapToNSImage(bitmap); | 296 favicon = gfx::SkBitmapToNSImage(bitmap); |
297 } | 297 } |
298 // Either we do not have a loaded favicon or the conversion from SkBitmap | 298 // Either we do not have a loaded favicon or the conversion from SkBitmap |
299 // failed. Use the default site image instead. | 299 // failed. Use the default site image instead. |
300 if (!favicon) | 300 if (!favicon) |
301 favicon = app::mac::GetCachedImageWithName(@"nav.pdf"); | 301 favicon = gfx::GetCachedImageWithName(@"nav.pdf"); |
302 [item setImage:favicon]; | 302 [item setImage:favicon]; |
303 } | 303 } |
304 | 304 |
305 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 305 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
306 if (!node) | 306 if (!node) |
307 return nil; | 307 return nil; |
308 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 308 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
309 bookmark_nodes_.find(node); | 309 bookmark_nodes_.find(node); |
310 if (it == bookmark_nodes_.end()) | 310 if (it == bookmark_nodes_.end()) |
311 return nil; | 311 return nil; |
312 return it->second; | 312 return it->second; |
313 } | 313 } |
OLD | NEW |