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

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

Issue 306293006: Introduce ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@364865
Patch Set: Add missing dependency in components/policy/policy_browser.gypi Created 6 years, 6 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
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"
11 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 11 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 13 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 17 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 19 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "grit/ui_resources.h" 22 #include "grit/ui_resources.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 71 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 folder_image_.reset( 72 folder_image_.reset(
72 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); 73 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage());
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 bookmarks 78 // Add at most one separator for the bookmark bar and the managed bookmarks
78 // folder. 79 // folder.
79 ChromeBookmarkClient* client = 80 ChromeBookmarkClient* client =
80 BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile_); 81 ChromeBookmarkClientFactory::GetForProfile(profile_);
81 const BookmarkNode* barNode = model->bookmark_bar_node(); 82 const BookmarkNode* barNode = model->bookmark_bar_node();
82 const BookmarkNode* managedNode = client->managed_node(); 83 const BookmarkNode* managedNode = client->managed_node();
83 if (!barNode->empty() || !managedNode->empty()) 84 if (!barNode->empty() || !managedNode->empty())
84 [bookmark_menu addItem:[NSMenuItem separatorItem]]; 85 [bookmark_menu addItem:[NSMenuItem separatorItem]];
85 // TODO(joaodasilva): use the 'Managed Bookmarks' icon for the managedNode. 86 // TODO(joaodasilva): use the 'Managed Bookmarks' icon for the managedNode.
86 if (!managedNode->empty()) 87 if (!managedNode->empty())
87 AddNodeAsSubmenu(bookmark_menu, managedNode, !is_submenu); 88 AddNodeAsSubmenu(bookmark_menu, managedNode, !is_submenu);
88 if (!barNode->empty()) 89 if (!barNode->empty())
89 AddNodeToMenu(barNode, bookmark_menu, !is_submenu); 90 AddNodeToMenu(barNode, bookmark_menu, !is_submenu);
90 91
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 343
343 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { 344 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) {
344 if (!node) 345 if (!node)
345 return nil; 346 return nil;
346 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = 347 std::map<const BookmarkNode*, NSMenuItem*>::iterator it =
347 bookmark_nodes_.find(node); 348 bookmark_nodes_.find(node);
348 if (it == bookmark_nodes_.end()) 349 if (it == bookmark_nodes_.end())
349 return nil; 350 return nil;
350 return it->second; 351 return it->second;
351 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698