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

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

Issue 155494: First cut at infobars on Mac. These are not expected to be... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 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) 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 "base/mac_util.h" 5 #include "base/mac_util.h"
6 #include "base/sys_string_conversions.h" 6 #include "base/sys_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model.h" 7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" 10 #import "chrome/browser/cocoa/bookmark_bar_bridge.h"
(...skipping 26 matching lines...) Expand all
37 const CGFloat kDefaultBookmarkWidth = 150.0; 37 const CGFloat kDefaultBookmarkWidth = 150.0;
38 const CGFloat kBookmarkVerticalPadding = 2.0; 38 const CGFloat kBookmarkVerticalPadding = 2.0;
39 const CGFloat kBookmarkHorizontalPadding = 8.0; 39 const CGFloat kBookmarkHorizontalPadding = 8.0;
40 }; 40 };
41 41
42 @implementation BookmarkBarController 42 @implementation BookmarkBarController
43 43
44 - (id)initWithProfile:(Profile*)profile 44 - (id)initWithProfile:(Profile*)profile
45 parentView:(NSView*)parentView 45 parentView:(NSView*)parentView
46 webContentView:(NSView*)webContentView 46 webContentView:(NSView*)webContentView
47 infoBarsView:(NSView*)infoBarsView
47 delegate:(id<BookmarkURLOpener>)delegate { 48 delegate:(id<BookmarkURLOpener>)delegate {
48 if ((self = [super initWithNibName:@"BookmarkBar" 49 if ((self = [super initWithNibName:@"BookmarkBar"
49 bundle:mac_util::MainAppBundle()])) { 50 bundle:mac_util::MainAppBundle()])) {
50 bookmarkModel_ = profile->GetBookmarkModel(); 51 bookmarkModel_ = profile->GetBookmarkModel();
51 preferences_ = profile->GetPrefs(); 52 preferences_ = profile->GetPrefs();
52 parentView_ = parentView; 53 parentView_ = parentView;
53 webContentView_ = webContentView; 54 webContentView_ = webContentView;
55 infoBarsView_ = infoBarsView;
54 delegate_ = delegate; 56 delegate_ = delegate;
55 } 57 }
56 return self; 58 return self;
57 } 59 }
58 60
59 - (void)awakeFromNib { 61 - (void)awakeFromNib {
60 // We default to NOT open, which means height=0. 62 // We default to NOT open, which means height=0.
61 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. 63 DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
62 NSRect frame = [[self view] frame]; 64 NSRect frame = [[self view] frame];
63 frame.size.height = 0; 65 frame.size.height = 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 115 }
114 if (!contentViewHasOffset_ && apply) { 116 if (!contentViewHasOffset_ && apply) {
115 // There is no offset to unconditionally apply. 117 // There is no offset to unconditionally apply.
116 return; 118 return;
117 } 119 }
118 120
119 // None of these locals are members of the Hall of Justice. 121 // None of these locals are members of the Hall of Justice.
120 NSRect superframe = [parentView_ frame]; 122 NSRect superframe = [parentView_ frame];
121 NSRect frame = [[self view] frame]; 123 NSRect frame = [[self view] frame];
122 NSRect webframe = [webContentView_ frame]; 124 NSRect webframe = [webContentView_ frame];
125 NSRect infoframe = [infoBarsView_ frame];
123 if (apply) { 126 if (apply) {
124 superframe.size.height += kBookmarkBarSuperviewHeightAdjustment; 127 superframe.size.height += kBookmarkBarSuperviewHeightAdjustment;
125 // TODO(jrg): y=0 if we add the bookmark bar before the parent 128 // TODO(jrg): y=0 if we add the bookmark bar before the parent
126 // view (toolbar) is placed in the view hierarchy. A different 129 // view (toolbar) is placed in the view hierarchy. A different
127 // CL, where the bookmark bar is extracted from the toolbar nib, 130 // CL, where the bookmark bar is extracted from the toolbar nib,
128 // may fix this awkwardness. 131 // may fix this awkwardness.
129 if (superframe.origin.y > 0) { 132 if (superframe.origin.y > 0) {
130 superframe.origin.y -= kBookmarkBarSuperviewHeightAdjustment; 133 superframe.origin.y -= kBookmarkBarSuperviewHeightAdjustment;
131 webframe.size.height -= kBookmarkBarWebframeHeightAdjustment; 134 webframe.size.height -= kBookmarkBarWebframeHeightAdjustment;
132 } 135 }
133 frame.size.height += kBookmarkBarHeight; 136 frame.size.height += kBookmarkBarHeight;
137 infoframe.origin.y -= kBookmarkBarWebframeHeightAdjustment;
134 } else { 138 } else {
135 superframe.size.height -= kBookmarkBarSuperviewHeightAdjustment; 139 superframe.size.height -= kBookmarkBarSuperviewHeightAdjustment;
136 superframe.origin.y += kBookmarkBarSuperviewHeightAdjustment; 140 superframe.origin.y += kBookmarkBarSuperviewHeightAdjustment;
137 frame.size.height -= kBookmarkBarHeight; 141 frame.size.height -= kBookmarkBarHeight;
138 webframe.size.height += kBookmarkBarWebframeHeightAdjustment; 142 webframe.size.height += kBookmarkBarWebframeHeightAdjustment;
143 infoframe.origin.y += kBookmarkBarWebframeHeightAdjustment;
139 } 144 }
140 145
141 // TODO(jrg): Animators can be a little fussy. Setting these three 146 // TODO(jrg): Animators can be a little fussy. Setting these three
142 // off can sometimes causes races where the finish isn't as 147 // off can sometimes causes races where the finish isn't as
143 // expected. Fix, or clean out the animators as an option. 148 // expected. Fix, or clean out the animators as an option.
144 // Odd racing is FAR worse than a lack of an animator. 149 // Odd racing is FAR worse than a lack of an animator.
145 if (1 /* immediately */) { 150 if (1 /* immediately */) {
146 [parentView_ setFrame:superframe]; 151 [parentView_ setFrame:superframe];
147 [webContentView_ setFrame:webframe]; 152 [webContentView_ setFrame:webframe];
153 [infoBarsView_ setFrame:infoframe];
148 [[self view] setFrame:frame]; 154 [[self view] setFrame:frame];
149 } else { 155 } else {
150 [[parentView_ animator] setFrame:superframe]; 156 [[parentView_ animator] setFrame:superframe];
151 [[webContentView_ animator] setFrame:webframe]; 157 [[webContentView_ animator] setFrame:webframe];
158 [[infoBarsView_ animator] setFrame:infoframe];
152 [[[self view] animator] setFrame:frame]; 159 [[[self view] animator] setFrame:frame];
153 } 160 }
154 161
155 [[self view] setNeedsDisplay:YES]; 162 [[self view] setNeedsDisplay:YES];
156 [parentView_ setNeedsDisplay:YES]; 163 [parentView_ setNeedsDisplay:YES];
157 [webContentView_ setNeedsDisplay:YES]; 164 [webContentView_ setNeedsDisplay:YES];
165 [infoBarsView_ setNeedsDisplay:YES];
158 } 166 }
159 167
160 - (BOOL)isBookmarkBarVisible { 168 - (BOOL)isBookmarkBarVisible {
161 return barShouldBeShown_; 169 return barShouldBeShown_;
162 } 170 }
163 171
164 // We don't change a preference; we only change visibility. 172 // We don't change a preference; we only change visibility.
165 // Preference changing (global state) is handled in 173 // Preference changing (global state) is handled in
166 // BrowserWindowCocoa::ToggleBookmarkBar(). 174 // BrowserWindowCocoa::ToggleBookmarkBar().
167 - (void)toggleBookmarkBar { 175 - (void)toggleBookmarkBar {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 - (void)nodeChildrenReordered:(BookmarkModel*)model 397 - (void)nodeChildrenReordered:(BookmarkModel*)model
390 node:(const BookmarkNode*)node { 398 node:(const BookmarkNode*)node {
391 [self loaded:model]; 399 [self loaded:model];
392 } 400 }
393 401
394 - (void)setDelegate:(id<BookmarkURLOpener>)delegate { 402 - (void)setDelegate:(id<BookmarkURLOpener>)delegate {
395 delegate_ = delegate; 403 delegate_ = delegate;
396 } 404 }
397 405
398 @end 406 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.h ('k') | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698