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

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

Issue 384105: Mac: Animate the bookmark bar showing/hiding. (Closed)
Patch Set: Comments added per rohitrao's review. Created 11 years, 1 month 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 <Carbon/Carbon.h> 5 #include <Carbon/Carbon.h>
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/scoped_nsdisable_screen_updates.h" 9 #include "base/scoped_nsdisable_screen_updates.h"
10 #import "base/scoped_nsobject.h" 10 #import "base/scoped_nsobject.h"
(...skipping 24 matching lines...) Expand all
35 #import "chrome/browser/cocoa/fullscreen_window.h" 35 #import "chrome/browser/cocoa/fullscreen_window.h"
36 #import "chrome/browser/cocoa/infobar_container_controller.h" 36 #import "chrome/browser/cocoa/infobar_container_controller.h"
37 #import "chrome/browser/cocoa/status_bubble_mac.h" 37 #import "chrome/browser/cocoa/status_bubble_mac.h"
38 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 38 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
39 #import "chrome/browser/cocoa/tab_strip_view.h" 39 #import "chrome/browser/cocoa/tab_strip_view.h"
40 #import "chrome/browser/cocoa/tab_strip_controller.h" 40 #import "chrome/browser/cocoa/tab_strip_controller.h"
41 #import "chrome/browser/cocoa/tab_view.h" 41 #import "chrome/browser/cocoa/tab_view.h"
42 #import "chrome/browser/cocoa/toolbar_controller.h" 42 #import "chrome/browser/cocoa/toolbar_controller.h"
43 #import "chrome/browser/browser_theme_provider.h" 43 #import "chrome/browser/browser_theme_provider.h"
44 #include "chrome/browser/sync/sync_status_ui_helper.h" 44 #include "chrome/browser/sync/sync_status_ui_helper.h"
45 #include "chrome/common/pref_names.h"
45 #include "chrome/common/pref_service.h" 46 #include "chrome/common/pref_service.h"
46 #import "chrome/browser/cocoa/background_gradient_view.h" 47 #import "chrome/browser/cocoa/background_gradient_view.h"
47 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
48 #include "grit/theme_resources.h" 49 #include "grit/theme_resources.h"
49 #import "third_party/GTM/AppKit/GTMTheme.h" 50 #import "third_party/GTM/AppKit/GTMTheme.h"
50 51
51 @interface GTMTheme (BrowserThemeProviderInitialization) 52 @interface GTMTheme (BrowserThemeProviderInitialization)
52 + (GTMTheme*)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider 53 + (GTMTheme*)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider
53 isOffTheRecord:(BOOL)offTheRecord; 54 isOffTheRecord:(BOOL)offTheRecord;
54 @end 55 @end
(...skipping 22 matching lines...) Expand all
77 - (NSRect)window:(NSWindow*)window 78 - (NSRect)window:(NSWindow*)window
78 willPositionSheet:(NSWindow*)sheet 79 willPositionSheet:(NSWindow*)sheet
79 usingRect:(NSRect)defaultSheetRect; 80 usingRect:(NSRect)defaultSheetRect;
80 81
81 // Assign a theme to the window. 82 // Assign a theme to the window.
82 - (void)setTheme; 83 - (void)setTheme;
83 84
84 // Repositions the windows subviews. 85 // Repositions the windows subviews.
85 - (void)layoutSubviews; 86 - (void)layoutSubviews;
86 87
88 // Should we show the normal bookmark bar?
89 - (BOOL)shouldShowBookmarkBar;
90
91 // Is the current page one for which the bookmark should be shown detached *if*
92 // the normal bookmark bar is not shown?
93 - (BOOL)shouldShowDetachedBookmarkBar;
94
87 @end 95 @end
88 96
89 97
90 @implementation BrowserWindowController 98 @implementation BrowserWindowController
91 99
92 // Load the browser window nib and do any Cocoa-specific initialization. 100 // Load the browser window nib and do any Cocoa-specific initialization.
93 // Takes ownership of |browser|. Note that the nib also sets this controller 101 // Takes ownership of |browser|. Note that the nib also sets this controller
94 // up as the window's delegate. 102 // up as the window's delegate.
95 - (id)initWithBrowser:(Browser*)browser { 103 - (id)initWithBrowser:(Browser*)browser {
96 return [self initWithBrowser:browser takeOwnership:YES]; 104 return [self initWithBrowser:browser takeOwnership:YES];
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR)) { 177 browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR)) {
170 [toolbarController_ setHasToolbar:NO]; 178 [toolbarController_ setHasToolbar:NO];
171 } 179 }
172 [[[self window] contentView] addSubview:[toolbarController_ view]]; 180 [[[self window] contentView] addSubview:[toolbarController_ view]];
173 181
174 // Create a sub-controller for the bookmark bar. 182 // Create a sub-controller for the bookmark bar.
175 bookmarkBarController_.reset( 183 bookmarkBarController_.reset(
176 [[BookmarkBarController alloc] 184 [[BookmarkBarController alloc]
177 initWithBrowser:browser_.get() 185 initWithBrowser:browser_.get()
178 initialWidth:NSWidth([[[self window] contentView] frame]) 186 initialWidth:NSWidth([[[self window] contentView] frame])
179 compressDelegate:toolbarController_.get() 187 delegate:self
180 resizeDelegate:self]); 188 resizeDelegate:self]);
181 189
182 // Add bookmark bar to the view hierarchy. This also triggers the 190 // Add bookmark bar to the view hierarchy. This also triggers the
183 // nib load. The bookmark bar is defined (in the nib) to be 191 // nib load. The bookmark bar is defined (in the nib) to be
184 // bottom-aligned to it's parent view (among other things), so 192 // bottom-aligned to it's parent view (among other things), so
185 // position and resize properties don't need to be set. 193 // position and resize properties don't need to be set.
186 [[[self window] contentView] addSubview:[bookmarkBarController_ view] 194 [[[self window] contentView] addSubview:[bookmarkBarController_ view]
187 positioned:NSWindowBelow 195 positioned:NSWindowBelow
188 relativeTo:[toolbarController_ view]]; 196 relativeTo:[toolbarController_ view]];
189 197
190 // Disable the bookmark bar if this window doesn't support them. 198 // Disable the bookmark bar if this window doesn't support them.
191 if (!browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 199 if (!browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
192 [bookmarkBarController_ setBookmarkBarEnabled:NO]; 200 [bookmarkBarController_ setBookmarkBarEnabled:NO];
193 } 201 }
194 202
195 // We don't want to try and show the bar before it gets placed in 203 // We don't want to try and show the bar before it gets placed in its parent
196 // it's parent view, so this step shoudn't be inside the bookmark 204 // view, so this step shoudn't be inside the bookmark bar controller's
197 // bar controller's awakeFromNib. 205 // |-awakeFromNib|.
198 [bookmarkBarController_ showIfNeeded]; 206 [self updateBookmarkBarVisibilityWithAnimation:NO];
199 207
200 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { 208 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) {
201 // Create the extension shelf. 209 // Create the extension shelf.
202 extensionShelfController_.reset([[ExtensionShelfController alloc] 210 extensionShelfController_.reset([[ExtensionShelfController alloc]
203 initWithBrowser:browser_.get() 211 initWithBrowser:browser_.get()
204 resizeDelegate:self]); 212 resizeDelegate:self]);
205 [[[self window] contentView] addSubview:[extensionShelfController_ view]]; 213 [[[self window] contentView] addSubview:[extensionShelfController_ view]];
206 [extensionShelfController_ wasInsertedIntoWindow]; 214 [extensionShelfController_ wasInsertedIntoWindow];
207 } 215 }
208 216
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // We should only ever be called for one of the following four views. 475 // We should only ever be called for one of the following four views.
468 // |downloadShelfController_| may be nil. If we are asked to size the bookmark 476 // |downloadShelfController_| may be nil. If we are asked to size the bookmark
469 // bar directly, its superview must be this controller's content view. 477 // bar directly, its superview must be this controller's content view.
470 DCHECK(view); 478 DCHECK(view);
471 DCHECK(view == [toolbarController_ view] || 479 DCHECK(view == [toolbarController_ view] ||
472 view == [infoBarContainerController_ view] || 480 view == [infoBarContainerController_ view] ||
473 view == [extensionShelfController_ view] || 481 view == [extensionShelfController_ view] ||
474 view == [downloadShelfController_ view] || 482 view == [downloadShelfController_ view] ||
475 view == [bookmarkBarController_ view]); 483 view == [bookmarkBarController_ view]);
476 484
477 // Change the height of the view and call layoutViews. We set the height here 485 // Change the height of the view and call |-layoutSubViews|. We set the height
478 // without regard to where the view is on the screen or whether it needs to 486 // here without regard to where the view is on the screen or whether it needs
479 // "grow up" or "grow down." The below call to layoutSubviews will position 487 // to "grow up" or "grow down." The below call to |-layoutSubviews| will
480 // each view correctly. 488 // position each view correctly.
481 NSRect frame = [view frame]; 489 NSRect frame = [view frame];
482 if (frame.size.height == height) 490 if (frame.size.height == height)
483 return; 491 return;
484 492
485 frame.size.height = height; 493 frame.size.height = height;
486 // TODO(rohitrao): Determine if calling setFrame: twice is bad. 494 // TODO(rohitrao): Determine if calling setFrame: twice is bad.
487 [view setFrame:frame]; 495 [view setFrame:frame];
488 [self layoutSubviews]; 496 [self layoutSubviews];
489 } 497 }
490 498
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 935 }
928 936
929 - (void)showNewTabButton:(BOOL)show { 937 - (void)showNewTabButton:(BOOL)show {
930 [tabStripController_ showNewTabButton:show]; 938 [tabStripController_ showNewTabButton:show];
931 } 939 }
932 940
933 - (BOOL)isBookmarkBarVisible { 941 - (BOOL)isBookmarkBarVisible {
934 return [bookmarkBarController_ isVisible]; 942 return [bookmarkBarController_ isVisible];
935 } 943 }
936 944
937 - (void)updateBookmarkBarVisibility { 945 - (void)updateBookmarkBarVisibilityWithAnimation:(BOOL)animate {
938 [bookmarkBarController_ updateVisibility]; 946 [bookmarkBarController_
947 updateAndShowNormalBar:[self shouldShowBookmarkBar]
948 showDetachedBar:[self shouldShowDetachedBookmarkBar]
949 withAnimation:animate];
939 } 950 }
940 951
941 - (BOOL)isDownloadShelfVisible { 952 - (BOOL)isDownloadShelfVisible {
942 return downloadShelfController_ != nil && 953 return downloadShelfController_ != nil &&
943 [downloadShelfController_ isVisible]; 954 [downloadShelfController_ isVisible];
944 } 955 }
945 956
946 - (DownloadShelfController*)downloadShelf { 957 - (DownloadShelfController*)downloadShelf {
947 if (!downloadShelfController_.get()) { 958 if (!downloadShelfController_.get()) {
948 downloadShelfController_.reset([[DownloadShelfController alloc] 959 downloadShelfController_.reset([[DownloadShelfController alloc]
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1086
1076 // Update all the UI bits. 1087 // Update all the UI bits.
1077 windowShim_->UpdateTitleBar(); 1088 windowShim_->UpdateTitleBar();
1078 1089
1079 #if 0 1090 #if 0
1080 // TODO(pinkerton):Update as more things become window-specific 1091 // TODO(pinkerton):Update as more things become window-specific
1081 toolbar_->SetProfile(newContents->profile()); 1092 toolbar_->SetProfile(newContents->profile());
1082 UpdateToolbar(newContents, true); 1093 UpdateToolbar(newContents, true);
1083 UpdateUIForContents(newContents); 1094 UpdateUIForContents(newContents);
1084 #endif 1095 #endif
1096
1097 // Update the bookmark bar.
1098 [self updateBookmarkBarVisibilityWithAnimation:NO];
1085 } 1099 }
1086 1100
1087 - (void)tabChangedWithContents:(TabContents*)contents 1101 - (void)tabChangedWithContents:(TabContents*)contents
1088 atIndex:(NSInteger)index 1102 atIndex:(NSInteger)index
1089 loadingOnly:(BOOL)loading { 1103 loadingOnly:(BOOL)loading {
1090 if (index == browser_->tabstrip_model()->selected_index()) { 1104 if (index == browser_->tabstrip_model()->selected_index()) {
1091 // Update titles if this is the currently selected tab. 1105 // Update titles if this is the currently selected tab.
1092 windowShim_->UpdateTitleBar(); 1106 windowShim_->UpdateTitleBar();
1093 } 1107 }
1108
1109 // Update the bookmark bar.
1110 [self updateBookmarkBarVisibilityWithAnimation:NO];
1094 } 1111 }
1095 1112
1096 - (void)userChangedTheme { 1113 - (void)userChangedTheme {
1097 [self setTheme]; 1114 [self setTheme];
1098 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; 1115 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
1099 [defaultCenter postNotificationName:kGTMThemeDidChangeNotification 1116 [defaultCenter postNotificationName:kGTMThemeDidChangeNotification
1100 object:theme_]; 1117 object:theme_];
1101 // TODO(dmaclach): Instead of redrawing the whole window, views that care 1118 // TODO(dmaclach): Instead of redrawing the whole window, views that care
1102 // about the active window state should be registering for notifications. 1119 // about the active window state should be registering for notifications.
1103 [[self window] setViewsNeedDisplay:YES]; 1120 [[self window] setViewsNeedDisplay:YES];
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1209
1193 // Delegate method called when window is resized. 1210 // Delegate method called when window is resized.
1194 - (void)windowDidResize:(NSNotification*)notification { 1211 - (void)windowDidResize:(NSNotification*)notification {
1195 // Resize (and possibly move) the status bubble. Note that we may get called 1212 // Resize (and possibly move) the status bubble. Note that we may get called
1196 // when the status bubble does not exist. 1213 // when the status bubble does not exist.
1197 if (statusBubble_) { 1214 if (statusBubble_) {
1198 statusBubble_->UpdateSizeAndPosition(); 1215 statusBubble_->UpdateSizeAndPosition();
1199 } 1216 }
1200 } 1217 }
1201 1218
1219 // (Needed for |BookmarkBarControllerDelegate| protocol.)
1220 - (void)bookmarkBar:(BookmarkBarController*)controller
1221 didChangeFromState:(bookmarks::VisualState)oldState
1222 toState:(bookmarks::VisualState)newState {
1223 [toolbarController_
1224 setHeightCompression:[controller getDesiredToolbarHeightCompression]];
1225 [toolbarController_ setShowsDivider:[controller shouldToolbarShowDivider]];
1226
1227 // TODO(viettrungluu): anything else?
1228 }
1229
1230 // (Needed for |BookmarkBarControllerDelegate| protocol.)
1231 - (void)bookmarkBar:(BookmarkBarController*)controller
1232 willAnimateFromState:(bookmarks::VisualState)oldState
1233 toState:(bookmarks::VisualState)newState {
1234 [toolbarController_
1235 setHeightCompression:[controller getDesiredToolbarHeightCompression]];
1236 [toolbarController_ setShowsDivider:[controller shouldToolbarShowDivider]];
1237
1238 // TODO(viettrungluu): anything else?
1239 }
1240
1202 @end 1241 @end
1203 1242
1204 @implementation BrowserWindowController (Private) 1243 @implementation BrowserWindowController (Private)
1205 1244
1206 // If the browser is in incognito mode, install the image view to decorate 1245 // If the browser is in incognito mode, install the image view to decorate
1207 // the window at the upper right. Use the same base y coordinate as the 1246 // the window at the upper right. Use the same base y coordinate as the
1208 // tab strip. 1247 // tab strip.
1209 - (void)installIncognitoBadge { 1248 - (void)installIncognitoBadge {
1210 if (!browser_->profile()->IsOffTheRecord()) 1249 if (!browser_->profile()->IsOffTheRecord())
1211 return; 1250 return;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 windowPreferences->SetBoolean(L"always_on_top", false); 1317 windowPreferences->SetBoolean(L"always_on_top", false);
1279 windowPreferences->SetInteger(L"work_area_left", workArea.x()); 1318 windowPreferences->SetInteger(L"work_area_left", workArea.x());
1280 windowPreferences->SetInteger(L"work_area_top", workArea.y()); 1319 windowPreferences->SetInteger(L"work_area_top", workArea.y());
1281 windowPreferences->SetInteger(L"work_area_right", workArea.right()); 1320 windowPreferences->SetInteger(L"work_area_right", workArea.right());
1282 windowPreferences->SetInteger(L"work_area_bottom", workArea.bottom()); 1321 windowPreferences->SetInteger(L"work_area_bottom", workArea.bottom());
1283 } 1322 }
1284 1323
1285 - (NSRect)window:(NSWindow*)window 1324 - (NSRect)window:(NSWindow*)window
1286 willPositionSheet:(NSWindow*)sheet 1325 willPositionSheet:(NSWindow*)sheet
1287 usingRect:(NSRect)defaultSheetRect { 1326 usingRect:(NSRect)defaultSheetRect {
1288 // Any sheet should come from right above the apparent content area, or 1327 // Position the sheet as follows:
1289 // equivalently right below the apparent toolbar. 1328 // - If the bookmark bar is hidden or shown as a bubble (on the NTP when the
1290 NSRect toolbarFrame = [[toolbarController_ view] frame]; 1329 // bookmark bar is disabled), position the sheet immediately below the
1291 defaultSheetRect.origin.y = toolbarFrame.origin.y; 1330 // normal toolbar.
1292 1331 // - If the bookmark bar is shown (attached to the normal toolbar), position
1293 // Position as follows: 1332 // the sheet below the bookmark bar.
1294 // - On a normal (non-NTP) page, position the sheet under the bookmark bar if 1333 // - If the bookmark bar is currently animating, position the sheet according
1295 // it's visible. Else put it immediately below the normal toolbar. 1334 // to where the bar will be when the animation ends.
1296 // - On the NTP, if the bookmark bar is enabled ("always visible"), then it 1335 switch ([bookmarkBarController_ visualState]) {
1297 // looks like a normal bookmark bar, so position the sheet under it; if it 1336 case bookmarks::kShowingState: {
1298 // isn't enabled, the bookmark bar will look as if it's a part of the 1337 NSRect bookmarkBarFrame = [[bookmarkBarController_ view] frame];
1299 // content area, so just put it immediately below the toolbar. 1338 defaultSheetRect.origin.y = bookmarkBarFrame.origin.y;
1300 if ([bookmarkBarController_ isVisible] && 1339 break;
1301 (![bookmarkBarController_ isNewTabPage] || 1340 }
1302 [bookmarkBarController_ isAlwaysVisible])) { 1341 case bookmarks::kHiddenState:
1303 NSRect bookmarkBarFrame = [[bookmarkBarController_ view] frame]; 1342 case bookmarks::kDetachedState: {
1304 defaultSheetRect.origin.y -= bookmarkBarFrame.size.height; 1343 NSRect toolbarFrame = [[toolbarController_ view] frame];
1344 defaultSheetRect.origin.y = toolbarFrame.origin.y;
1345 break;
1346 }
1347 default:
1348 case bookmarks::kInvalidState:
1349 NOTREACHED();
1305 } 1350 }
1306
1307 return defaultSheetRect; 1351 return defaultSheetRect;
1308 } 1352 }
1309 1353
1310 // Undocumented method for multi-touch gestures in 10.5. Future OS's will 1354 // Undocumented method for multi-touch gestures in 10.5. Future OS's will
1311 // likely add a public API, but the worst that will happen is that this will 1355 // likely add a public API, but the worst that will happen is that this will
1312 // turn into dead code and just won't get called. 1356 // turn into dead code and just won't get called.
1313 - (void)swipeWithEvent:(NSEvent*)event { 1357 - (void)swipeWithEvent:(NSEvent*)event {
1314 // Map forwards and backwards to history; left is positive, right is negative. 1358 // Map forwards and backwards to history; left is positive, right is negative.
1315 unsigned int command = 0; 1359 unsigned int command = 0;
1316 if ([event deltaX] > 0.5) 1360 if ([event deltaX] > 0.5)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 NSRect toolbarFrame = [toolbarView frame]; 1421 NSRect toolbarFrame = [toolbarView frame];
1378 if (![self isFullscreen]) { 1422 if (![self isFullscreen]) {
1379 // The toolbar is present in the window, so we make room for it. 1423 // The toolbar is present in the window, so we make room for it.
1380 toolbarFrame.origin.x = 0; 1424 toolbarFrame.origin.x = 0;
1381 toolbarFrame.origin.y = maxY - NSHeight(toolbarFrame); 1425 toolbarFrame.origin.y = maxY - NSHeight(toolbarFrame);
1382 toolbarFrame.size.width = NSWidth(contentFrame); 1426 toolbarFrame.size.width = NSWidth(contentFrame);
1383 maxY -= NSHeight(toolbarFrame); 1427 maxY -= NSHeight(toolbarFrame);
1384 } 1428 }
1385 [toolbarView setFrame:toolbarFrame]; 1429 [toolbarView setFrame:toolbarFrame];
1386 1430
1387 if ([bookmarkBarController_ isAlwaysVisible]) { 1431 bookmarks::VisualState bookmarkBarState =
1432 [bookmarkBarController_ visualState];
1433 bookmarks::VisualState lastBookmarkBarState =
1434 [bookmarkBarController_ lastVisualState];
1435
1436 // If the bookmark bar is showing, or animating between showing and hidden,
1437 // place the bookmark bar immediately below the toolbar.
1438 // TODO(viettrungluu): Improve/abstract this when I implement other
1439 // animations.
1440 if ((bookmarkBarState == bookmarks::kShowingState) ||
1441 (bookmarkBarState == bookmarks::kHiddenState &&
1442 lastBookmarkBarState == bookmarks::kShowingState)) {
1388 NSView* bookmarkBarView = [bookmarkBarController_ view]; 1443 NSView* bookmarkBarView = [bookmarkBarController_ view];
1389 [bookmarkBarView setHidden:NO]; 1444 [bookmarkBarView setHidden:NO];
1390 NSRect bookmarkBarFrame = [bookmarkBarView frame]; 1445 NSRect bookmarkBarFrame = [bookmarkBarView frame];
1391 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame); 1446 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame);
1392 bookmarkBarFrame.size.width = NSWidth(contentFrame); 1447 bookmarkBarFrame.size.width = NSWidth(contentFrame);
1393 [bookmarkBarView setFrame:bookmarkBarFrame]; 1448 [bookmarkBarView setFrame:bookmarkBarFrame];
1394 maxY -= NSHeight(bookmarkBarFrame); 1449 maxY -= NSHeight(bookmarkBarFrame);
1395 } 1450 }
1396 1451
1397 // Place the infobar container in place below the toolbar. 1452 // Place the infobar container in place below the toolbar.
1398 NSView* infoBarView = [infoBarContainerController_ view]; 1453 NSView* infoBarView = [infoBarContainerController_ view];
1399 NSRect infoBarFrame = [infoBarView frame]; 1454 NSRect infoBarFrame = [infoBarView frame];
1400 infoBarFrame.origin.y = maxY - NSHeight(infoBarFrame); 1455 infoBarFrame.origin.y = maxY - NSHeight(infoBarFrame);
1401 infoBarFrame.size.width = NSWidth(contentFrame); 1456 infoBarFrame.size.width = NSWidth(contentFrame);
1402 [infoBarView setFrame:infoBarFrame]; 1457 [infoBarView setFrame:infoBarFrame];
1403 maxY -= NSHeight(infoBarFrame); 1458 maxY -= NSHeight(infoBarFrame);
1404 1459
1405 if (![bookmarkBarController_ isAlwaysVisible] && 1460 // If the bookmark bar is detached, place it at the bottom of the stack.
1406 [bookmarkBarController_ isVisible]) { 1461 if (bookmarkBarState == bookmarks::kDetachedState) {
1407 NSView* bookmarkBarView = [bookmarkBarController_ view]; 1462 NSView* bookmarkBarView = [bookmarkBarController_ view];
1408 [bookmarkBarView setHidden:NO]; 1463 [bookmarkBarView setHidden:NO];
1409 NSRect bookmarkBarFrame = [bookmarkBarView frame]; 1464 NSRect bookmarkBarFrame = [bookmarkBarView frame];
1410 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame); 1465 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame);
1411 bookmarkBarFrame.size.width = NSWidth(contentFrame); 1466 bookmarkBarFrame.size.width = NSWidth(contentFrame);
1412 [bookmarkBarView setFrame:bookmarkBarFrame]; 1467 [bookmarkBarView setFrame:bookmarkBarFrame];
1413 maxY -= NSHeight(bookmarkBarFrame); 1468 maxY -= NSHeight(bookmarkBarFrame);
1414 } 1469 }
1415 1470
1416 if (![bookmarkBarController_ isVisible]) {
1417 // If the bookmark bar is not visible in either mode, we need to hide it
1418 // otherwise it'll render over other elements.
1419 [[bookmarkBarController_ view] setHidden:YES];
1420 }
1421
1422 // Place the extension shelf at the bottom of the view, if it exists. 1471 // Place the extension shelf at the bottom of the view, if it exists.
1423 if (extensionShelfController_.get()) { 1472 if (extensionShelfController_.get()) {
1424 NSView* extensionView = [extensionShelfController_ view]; 1473 NSView* extensionView = [extensionShelfController_ view];
1425 NSRect extensionFrame = [extensionView frame]; 1474 NSRect extensionFrame = [extensionView frame];
1426 extensionFrame.origin.y = minY; 1475 extensionFrame.origin.y = minY;
1427 extensionFrame.size.width = NSWidth(contentFrame); 1476 extensionFrame.size.width = NSWidth(contentFrame);
1428 [extensionView setFrame:extensionFrame]; 1477 [extensionView setFrame:extensionFrame];
1429 minY += NSHeight(extensionFrame); 1478 minY += NSHeight(extensionFrame);
1430 } 1479 }
1431 1480
(...skipping 14 matching lines...) Expand all
1446 tabContentFrame.size.height = maxY - minY; 1495 tabContentFrame.size.height = maxY - minY;
1447 tabContentFrame.size.width = NSWidth(contentFrame); 1496 tabContentFrame.size.width = NSWidth(contentFrame);
1448 [tabContentView setFrame:tabContentFrame]; 1497 [tabContentView setFrame:tabContentFrame];
1449 1498
1450 // Position the find bar relative to the infobar container. 1499 // Position the find bar relative to the infobar container.
1451 [findBarCocoaController_ 1500 [findBarCocoaController_
1452 positionFindBarView:[infoBarContainerController_ view]]; 1501 positionFindBarView:[infoBarContainerController_ view]];
1453 1502
1454 verticalOffsetForStatusBubble_ = minY; 1503 verticalOffsetForStatusBubble_ = minY;
1455 1504
1456 // The bottom of the visible toolbar stack is the one that shows the 1505 // Normally, we don't need to tell the toolbar whether or not to show the
1457 // divider stroke. If the bookmark bar is visible and not in new tab page 1506 // divider, but things break down during animation.
1458 // mode, it is the bottom visible toolbar and so it must, otherwise the 1507 [toolbarController_
1459 // main toolbar is. 1508 setShowsDivider:[bookmarkBarController_ shouldToolbarShowDivider]];
1460 BOOL bookmarkToolbarShowsDivider = [bookmarkBarController_ isAlwaysVisible]; 1509 }
1461 [[toolbarController_ backgroundGradientView] 1510
1462 setShowsDivider:!bookmarkToolbarShowsDivider]; 1511 - (BOOL)shouldShowBookmarkBar {
1463 [[bookmarkBarController_ backgroundGradientView] 1512 DCHECK(browser_.get());
1464 setShowsDivider:bookmarkToolbarShowsDivider]; 1513 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
1514 YES : NO;
1515 }
1516
1517 - (BOOL)shouldShowDetachedBookmarkBar {
1518 DCHECK(browser_.get());
1519 TabContents* contents = browser_->GetSelectedTabContents();
1520 return (contents && contents->ShouldShowBookmarkBar()) ? YES : NO;
1465 } 1521 }
1466 1522
1467 @end 1523 @end
1468 1524
1469 @implementation GTMTheme (BrowserThemeProviderInitialization) 1525 @implementation GTMTheme (BrowserThemeProviderInitialization)
1470 + (GTMTheme*)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider 1526 + (GTMTheme*)themeWithBrowserThemeProvider:(BrowserThemeProvider*)provider
1471 isOffTheRecord:(BOOL)isOffTheRecord { 1527 isOffTheRecord:(BOOL)isOffTheRecord {
1472 // First check if it's in the cache. 1528 // First check if it's in the cache.
1473 // TODO(pinkerton): This might be a good candidate for a singleton. 1529 // TODO(pinkerton): This might be a good candidate for a singleton.
1474 typedef std::pair<std::string, BOOL> ThemeKey; 1530 typedef std::pair<std::string, BOOL> ThemeKey;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 if (frameOverlayInactiveImage) { 1668 if (frameOverlayInactiveImage) {
1613 [theme setValue:frameOverlayInactiveImage 1669 [theme setValue:frameOverlayInactiveImage
1614 forAttribute:@"overlay" 1670 forAttribute:@"overlay"
1615 style:GTMThemeStyleWindow 1671 style:GTMThemeStyleWindow
1616 state:GTMThemeStateInactiveWindow]; 1672 state:GTMThemeStateInactiveWindow];
1617 } 1673 }
1618 1674
1619 return theme; 1675 return theme;
1620 } 1676 }
1621 @end 1677 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698