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

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

Issue 14262013: On Mac, ensure messages displayed in the bookmark bar do not overlap with the Apps bookmark button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered comments, added tests. Created 7 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"
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 [buttons_ objectAtIndex:static_cast<NSUInteger>(index)]; 1380 [buttons_ objectAtIndex:static_cast<NSUInteger>(index)];
1381 if ([button showsBorderOnlyWhileMouseInside]) { 1381 if ([button showsBorderOnlyWhileMouseInside]) {
1382 [button setShowsBorderOnlyWhileMouseInside:NO]; 1382 [button setShowsBorderOnlyWhileMouseInside:NO];
1383 [button setShowsBorderOnlyWhileMouseInside:YES]; 1383 [button setShowsBorderOnlyWhileMouseInside:YES];
1384 } 1384 }
1385 } 1385 }
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 1389
1390 // Adjust the horizontal width and the visibility of the "For quick access" 1390 // Adjust the horizontal width, x position and the visibility of the "For quick
1391 // text field and "Import bookmarks..." button based on the current width 1391 // access" text field and "Import bookmarks..." button based on the current
1392 // of the containing |buttonView_| (which is affected by window width). 1392 // width of the containing |buttonView_| (which is affected by window width).
1393 - (void)adjustNoItemContainerWidthsForMaxX:(CGFloat)maxViewX { 1393 - (void)adjustNoItemContainerForMaxX:(CGFloat)maxViewX {
1394 if (![[buttonView_ noItemContainer] isHidden]) { 1394 if (![[buttonView_ noItemContainer] isHidden]) {
1395 // Reset initial frames for the two items, then adjust as necessary. 1395 // Reset initial frames for the two items, then adjust as necessary.
1396 NSTextField* noItemTextfield = [buttonView_ noItemTextfield]; 1396 NSTextField* noItemTextfield = [buttonView_ noItemTextfield];
1397 [noItemTextfield setFrame:originalNoItemsRect_]; 1397 NSRect noItemsRect = originalNoItemsRect_;
1398 NSRect importBookmarksRect = originalImportBookmarksRect_;
1399 if (![appsPageShortcutButton_ isHidden]) {
1400 float width = NSWidth([appsPageShortcutButton_ frame]);
1401 noItemsRect.origin.x += width;
1402 importBookmarksRect.origin.x += width;
1403 }
1404 [noItemTextfield setFrame:noItemsRect];
1398 [noItemTextfield setHidden:NO]; 1405 [noItemTextfield setHidden:NO];
1399 NSButton* importBookmarksButton = [buttonView_ importBookmarksButton]; 1406 NSButton* importBookmarksButton = [buttonView_ importBookmarksButton];
1400 [importBookmarksButton setFrame:originalImportBookmarksRect_]; 1407 [importBookmarksButton setFrame:importBookmarksRect];
1401 [importBookmarksButton setHidden:NO]; 1408 [importBookmarksButton setHidden:NO];
1402 // Check each to see if they need to be shrunk or hidden. 1409 // Check each to see if they need to be shrunk or hidden.
1403 if ([self shrinkOrHideView:importBookmarksButton forMaxX:maxViewX]) 1410 if ([self shrinkOrHideView:importBookmarksButton forMaxX:maxViewX])
1404 [self shrinkOrHideView:noItemTextfield forMaxX:maxViewX]; 1411 [self shrinkOrHideView:noItemTextfield forMaxX:maxViewX];
1405 } 1412 }
1406 } 1413 }
1407 1414
1408 // Scans through all buttons from left to right, calculating from scratch where 1415 // Scans through all buttons from left to right, calculating from scratch where
1409 // they should be based on the preceding widths, until it finds the one 1416 // they should be based on the preceding widths, until it finds the one
1410 // requested. 1417 // requested.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 break; 1518 break;
1512 } 1519 }
1513 ++displayedButtonCount_; 1520 ++displayedButtonCount_;
1514 [buttons_ addObject:button]; 1521 [buttons_ addObject:button];
1515 [buttonView_ addSubview:button]; 1522 [buttonView_ addSubview:button];
1516 } 1523 }
1517 1524
1518 // While we're here, adjust the horizontal width and the visibility 1525 // While we're here, adjust the horizontal width and the visibility
1519 // of the "For quick access" and "Import bookmarks..." text fields. 1526 // of the "For quick access" and "Import bookmarks..." text fields.
1520 if (![buttons_ count]) 1527 if (![buttons_ count])
1521 [self adjustNoItemContainerWidthsForMaxX:maxViewX]; 1528 [self adjustNoItemContainerForMaxX:maxViewX];
1522 } 1529 }
1523 1530
1524 #pragma mark Private Methods Exposed for Testing 1531 #pragma mark Private Methods Exposed for Testing
1525 1532
1526 - (BookmarkBarView*)buttonView { 1533 - (BookmarkBarView*)buttonView {
1527 return buttonView_; 1534 return buttonView_;
1528 } 1535 }
1529 1536
1530 - (NSMutableArray*)buttons { 1537 - (NSMutableArray*)buttons {
1531 return buttons_.get(); 1538 return buttons_.get();
1532 } 1539 }
1533 1540
1534 - (NSButton*)offTheSideButton { 1541 - (NSButton*)offTheSideButton {
1535 return offTheSideButton_; 1542 return offTheSideButton_;
1536 } 1543 }
1537 1544
1545 - (NSButton*)appsPageShortcutButton {
1546 return appsPageShortcutButton_;
1547 }
1548
1538 - (BOOL)offTheSideButtonIsHidden { 1549 - (BOOL)offTheSideButtonIsHidden {
1539 return [offTheSideButton_ isHidden]; 1550 return [offTheSideButton_ isHidden];
1540 } 1551 }
1541 1552
1553 - (BOOL)appsPageShortcutButtonIsHidden {
1554 return [appsPageShortcutButton_ isHidden];
1555 }
1556
1542 - (BookmarkButton*)otherBookmarksButton { 1557 - (BookmarkButton*)otherBookmarksButton {
1543 return otherBookmarksButton_.get(); 1558 return otherBookmarksButton_.get();
1544 } 1559 }
1545 1560
1546 - (BookmarkBarFolderController*)folderController { 1561 - (BookmarkBarFolderController*)folderController {
1547 return folderController_; 1562 return folderController_;
1548 } 1563 }
1549 1564
1550 - (id)folderTarget { 1565 - (id)folderTarget {
1551 return folderTarget_.get(); 1566 return folderTarget_.get();
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 2677 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2663 (const BookmarkNode*)node { 2678 (const BookmarkNode*)node {
2664 // See if it's in the bar, then if it is in the hierarchy of visible 2679 // See if it's in the bar, then if it is in the hierarchy of visible
2665 // folder menus. 2680 // folder menus.
2666 if (bookmarkModel_->bookmark_bar_node() == node) 2681 if (bookmarkModel_->bookmark_bar_node() == node)
2667 return self; 2682 return self;
2668 return [folderController_ controllerForNode:node]; 2683 return [folderController_ controllerForNode:node];
2669 } 2684 }
2670 2685
2671 @end 2686 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698