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

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

Issue 242823002: Extract GetNodeByID() method from BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert a change in bookmarks_helper.cc that colides with a wstring and cq does not like that Created 6 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 | Annotate | Revision Log
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 "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
14 #include "chrome/browser/bookmarks/bookmark_node_data.h" 14 #include "chrome/browser/bookmarks/bookmark_node_data.h"
15 #include "chrome/browser/bookmarks/bookmark_stats.h" 15 #include "chrome/browser/bookmarks/bookmark_stats.h"
16 #include "chrome/browser/bookmarks/bookmark_utils.h"
16 #include "chrome/browser/prefs/incognito_mode_prefs.h" 17 #include "chrome/browser/prefs/incognito_mode_prefs.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/themes/theme_properties.h" 19 #include "chrome/browser/themes/theme_properties.h"
19 #include "chrome/browser/themes/theme_service.h" 20 #include "chrome/browser/themes/theme_service.h"
20 #import "chrome/browser/themes/theme_service_factory.h" 21 #import "chrome/browser/themes/theme_service_factory.h"
21 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" 22 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
22 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 23 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/chrome_pages.h" 26 #include "chrome/browser/ui/chrome_pages.h"
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 // Example: for a bookmark named "Moma" or "SFGate", it is one pixel 1019 // Example: for a bookmark named "Moma" or "SFGate", it is one pixel
1019 // too small. For "FBL" it is 2 pixels too small. 1020 // too small. For "FBL" it is 2 pixels too small.
1020 // For a bookmark named "SFGateFooWoo", it is just fine. 1021 // For a bookmark named "SFGateFooWoo", it is just fine.
1021 - (CGFloat)widthForBookmarkButtonCell:(NSCell*)cell { 1022 - (CGFloat)widthForBookmarkButtonCell:(NSCell*)cell {
1022 CGFloat desired = [cell cellSize].width + 2; 1023 CGFloat desired = [cell cellSize].width + 2;
1023 return std::min(desired, bookmarks::kDefaultBookmarkWidth); 1024 return std::min(desired, bookmarks::kDefaultBookmarkWidth);
1024 } 1025 }
1025 1026
1026 - (IBAction)openBookmarkMenuItem:(id)sender { 1027 - (IBAction)openBookmarkMenuItem:(id)sender {
1027 int64 tag = [self nodeIdFromMenuTag:[sender tag]]; 1028 int64 tag = [self nodeIdFromMenuTag:[sender tag]];
1028 const BookmarkNode* node = bookmarkModel_->GetNodeByID(tag); 1029 const BookmarkNode* node = GetBookmarkNodeByID(bookmarkModel_, tag);
1029 WindowOpenDisposition disposition = 1030 WindowOpenDisposition disposition =
1030 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); 1031 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]);
1031 [self openURL:node->url() disposition:disposition]; 1032 [self openURL:node->url() disposition:disposition];
1032 } 1033 }
1033 1034
1034 // For the given root node of the bookmark bar, show or hide (as 1035 // For the given root node of the bookmark bar, show or hide (as
1035 // appropriate) the "no items" container (text which says "bookmarks 1036 // appropriate) the "no items" container (text which says "bookmarks
1036 // go here"). 1037 // go here").
1037 - (void)showOrHideNoItemContainerForNode:(const BookmarkNode*)node { 1038 - (void)showOrHideNoItemContainerForNode:(const BookmarkNode*)node {
1038 BOOL hideNoItemWarning = !node->empty(); 1039 BOOL hideNoItemWarning = !node->empty();
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 2681 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2681 (const BookmarkNode*)node { 2682 (const BookmarkNode*)node {
2682 // See if it's in the bar, then if it is in the hierarchy of visible 2683 // See if it's in the bar, then if it is in the hierarchy of visible
2683 // folder menus. 2684 // folder menus.
2684 if (bookmarkModel_->bookmark_bar_node() == node) 2685 if (bookmarkModel_->bookmark_bar_node() == node)
2685 return self; 2686 return self;
2686 return [folderController_ controllerForNode:node]; 2687 return [folderController_ controllerForNode:node];
2687 } 2688 }
2688 2689
2689 @end 2690 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698