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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm

Issue 2814703003: [Mac] Use templated images for bookmark menu (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <AppKit/AppKit.h> 5 #import <AppKit/AppKit.h>
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/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_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return; 63 return;
64 64
65 BookmarkModel* model = GetBookmarkModel(); 65 BookmarkModel* model = GetBookmarkModel();
66 if (!model || !model->loaded()) 66 if (!model || !model->loaded())
67 return; 67 return;
68 68
69 if (!folder_image_) { 69 if (!folder_image_) {
70 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 70 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 folder_image_.reset( 71 folder_image_.reset(
72 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); 72 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage());
73 [folder_image_ setTemplate:YES];
73 } 74 }
74 75
75 ClearBookmarkMenu(bookmark_menu); 76 ClearBookmarkMenu(bookmark_menu);
76 77
77 // Add at most one separator for the bookmark bar and the managed and 78 // Add at most one separator for the bookmark bar and the managed and
78 // supervised bookmarks folders. 79 // supervised bookmarks folders.
79 bookmarks::ManagedBookmarkService* managed = 80 bookmarks::ManagedBookmarkService* managed =
80 ManagedBookmarkServiceFactory::GetForProfile(profile_); 81 ManagedBookmarkServiceFactory::GetForProfile(profile_);
81 const BookmarkNode* barNode = model->bookmark_bar_node(); 82 const BookmarkNode* barNode = model->bookmark_bar_node();
82 const BookmarkNode* managedNode = managed->managed_node(); 83 const BookmarkNode* managedNode = managed->managed_node();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 BookmarkModel* model = GetBookmarkModel(); 349 BookmarkModel* model = GetBookmarkModel();
349 if (model) { 350 if (model) {
350 const gfx::Image& image = model->GetFavicon(node); 351 const gfx::Image& image = model->GetFavicon(node);
351 if (!image.IsEmpty()) 352 if (!image.IsEmpty())
352 favicon = image.ToNSImage(); 353 favicon = image.ToNSImage();
353 } 354 }
354 // If we do not have a loaded favicon, use the default site image instead. 355 // If we do not have a loaded favicon, use the default site image instead.
355 if (!favicon) { 356 if (!favicon) {
356 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 357 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
357 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage(); 358 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage();
359 [favicon setTemplate:YES];
358 } 360 }
359 [item setImage:favicon]; 361 [item setImage:favicon];
360 } 362 }
361 363
362 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { 364 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) {
363 if (!node) 365 if (!node)
364 return nil; 366 return nil;
365 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = 367 std::map<const BookmarkNode*, NSMenuItem*>::iterator it =
366 bookmark_nodes_.find(node); 368 bookmark_nodes_.find(node);
367 if (it == bookmark_nodes_.end()) 369 if (it == bookmark_nodes_.end())
368 return nil; 370 return nil;
369 return it->second; 371 return it->second;
370 } 372 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698