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

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

Issue 336001: [Mac] Make bookmark bar a primitive drag destination. (Closed)
Patch Set: cleanup Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "app/l10n_util_mac.h" 5 #include "app/l10n_util_mac.h"
6 #include "app/resource_bundle.h" 6 #include "app/resource_bundle.h"
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_editor.h" 9 #include "chrome/browser/bookmarks/bookmark_editor.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 tabObserver_.reset( 73 tabObserver_.reset(
74 new TabStripModelObserverBridge(browser_->tabstrip_model(), self)); 74 new TabStripModelObserverBridge(browser_->tabstrip_model(), self));
75 75
76 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 76 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
77 folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); 77 folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]);
78 } 78 }
79 return self; 79 return self;
80 } 80 }
81 81
82 - (void)dealloc { 82 - (void)dealloc {
83 // Remove our view from its superview so it doesn't attempt to reference
pink (ping after 24hrs) 2009/10/27 15:00:43 is this necessary with dmac's changes, or just a h
Nico 2009/10/27 15:52:42 See http://codereview.chromium.org/334029 .
84 // it when the controller is gone.
85 [[self view] removeFromSuperview];
83 bridge_.reset(NULL); 86 bridge_.reset(NULL);
84 [[NSNotificationCenter defaultCenter] removeObserver:self]; 87 [[NSNotificationCenter defaultCenter] removeObserver:self];
85 [super dealloc]; 88 [super dealloc];
86 } 89 }
87 90
88 - (void)awakeFromNib { 91 - (void)awakeFromNib {
89 // We default to NOT open, which means height=0. 92 // We default to NOT open, which means height=0.
90 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. 93 DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
91 94
92 // Set our initial height to zero, since that is what the superview 95 // Set our initial height to zero, since that is what the superview
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 - (BOOL)isNewTabPage { 198 - (BOOL)isNewTabPage {
196 return browser_ && browser_->GetSelectedTabContents() && 199 return browser_ && browser_->GetSelectedTabContents() &&
197 browser_->GetSelectedTabContents()->ShouldShowBookmarkBar(); 200 browser_->GetSelectedTabContents()->ShouldShowBookmarkBar();
198 } 201 }
199 202
200 - (BOOL)isAlwaysVisible { 203 - (BOOL)isAlwaysVisible {
201 return browser_ && 204 return browser_ &&
202 browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); 205 browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
203 } 206 }
204 207
208 - (BOOL)addURLs:(NSArray*)urls withTitles:(NSArray*)titles at:(NSPoint)point {
209 // TODO(jrg): Support drops on folders etc
210 // TODO(jrg): Use |point|.
211 DCHECK([urls count] == [titles count]);
212 const BookmarkNode* node = bookmarkModel_->GetBookmarkBarNode();
213
214 for (size_t i = 0; i < [urls count]; ++i) {
215 bookmarkModel_->AddURL(
216 node,
217 node->GetChildCount(),
218 base::SysNSStringToWide([titles objectAtIndex:i]),
219 GURL([[urls objectAtIndex:i] UTF8String]));
220 }
221 return YES;
222 }
223
205 - (int)currentTabContentsHeight { 224 - (int)currentTabContentsHeight {
206 return browser_->GetSelectedTabContents()->view()->GetContainerSize(). 225 return browser_->GetSelectedTabContents()->view()->GetContainerSize().
207 height(); 226 height();
208 } 227 }
209 228
210 - (ThemeProvider*)themeProvider { 229 - (ThemeProvider*)themeProvider {
211 return browser_->profile()->GetThemeProvider(); 230 return browser_->profile()->GetThemeProvider();
212 } 231 }
213 232
214 - (BOOL)drawAsFloatingBar { 233 - (BOOL)drawAsFloatingBar {
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 759
741 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate { 760 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate {
742 urlDelegate_ = urlDelegate; 761 urlDelegate_ = urlDelegate;
743 } 762 }
744 763
745 - (NSArray*)buttons { 764 - (NSArray*)buttons {
746 return buttons_.get(); 765 return buttons_.get();
747 } 766 }
748 767
749 @end 768 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698