| OLD | NEW |
| 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/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 toolbarButtonSize.width; | 361 toolbarButtonSize.width; |
| 362 menuButtonFrame.origin.y = homeButtonFrame.origin.y; | 362 menuButtonFrame.origin.y = homeButtonFrame.origin.y; |
| 363 menuButtonFrame.size = toolbarButtonSize; | 363 menuButtonFrame.size = toolbarButtonSize; |
| 364 [appMenuButton_ setFrame:menuButtonFrame]; | 364 [appMenuButton_ setFrame:menuButtonFrame]; |
| 365 | 365 |
| 366 // Adjust the size and location on the location bar to take up the | 366 // Adjust the size and location on the location bar to take up the |
| 367 // space between the reload and menu buttons. | 367 // space between the reload and menu buttons. |
| 368 NSRect locationBarFrame = [locationBar_ frame]; | 368 NSRect locationBarFrame = [locationBar_ frame]; |
| 369 locationBarFrame.origin.x = NSMaxX(homeButtonFrame) + | 369 locationBarFrame.origin.x = NSMaxX(homeButtonFrame) + |
| 370 kMaterialDesignButtonInset; | 370 kMaterialDesignButtonInset; |
| 371 if (![homeButton_ isHidden]) { |
| 372 // Ensure proper spacing between the home button and the location bar. |
| 373 locationBarFrame.origin.x += kMaterialDesignElementPadding; |
| 374 } |
| 371 locationBarFrame.origin.y = NSMaxY(toolbarBounds) - | 375 locationBarFrame.origin.y = NSMaxY(toolbarBounds) - |
| 372 kMaterialDesignLocationBarPadding - kMaterialDesignLocationBarHeight; | 376 kMaterialDesignLocationBarPadding - kMaterialDesignLocationBarHeight; |
| 373 locationBarFrame.size.width = | 377 locationBarFrame.size.width = |
| 374 menuButtonFrame.origin.x - | 378 menuButtonFrame.origin.x - |
| 375 locationBarFrame.origin.x; | 379 locationBarFrame.origin.x; |
| 376 locationBarFrame.size.height = kMaterialDesignLocationBarHeight; | 380 locationBarFrame.size.height = kMaterialDesignLocationBarHeight; |
| 377 [locationBar_ setFrame:locationBarFrame]; | 381 [locationBar_ setFrame:locationBarFrame]; |
| 378 | 382 |
| 379 // Correctly position the extension buttons' container view. | 383 // Correctly position the extension buttons' container view. |
| 380 NSRect containerFrame = [browserActionsContainerView_ frame]; | 384 NSRect containerFrame = [browserActionsContainerView_ frame]; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 BOOL hide = showHomeButton_.GetValue() ? NO : YES; | 795 BOOL hide = showHomeButton_.GetValue() ? NO : YES; |
| 792 if (hide == [homeButton_ isHidden]) | 796 if (hide == [homeButton_ isHidden]) |
| 793 return; // Nothing to do, view state matches pref state. | 797 return; // Nothing to do, view state matches pref state. |
| 794 | 798 |
| 795 // Always shift the text field by the width of the home button minus one pixel | 799 // Always shift the text field by the width of the home button minus one pixel |
| 796 // since the frame edges of each button are right on top of each other. When | 800 // since the frame edges of each button are right on top of each other. When |
| 797 // hiding the button, reverse the direction of the movement (to the left). | 801 // hiding the button, reverse the direction of the movement (to the left). |
| 798 CGFloat moveX = [homeButton_ frame].size.width; | 802 CGFloat moveX = [homeButton_ frame].size.width; |
| 799 if (!ui::MaterialDesignController::IsModeMaterial()) { | 803 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 800 moveX -= 1.0; | 804 moveX -= 1.0; |
| 805 } else { |
| 806 // Ensure proper spacing between the home button and the location bar. |
| 807 moveX += kMaterialDesignElementPadding; |
| 801 } | 808 } |
| 802 if (hide) | 809 if (hide) |
| 803 moveX *= -1; // Reverse the direction of the move. | 810 moveX *= -1; // Reverse the direction of the move. |
| 804 | 811 |
| 805 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] | 812 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] |
| 806 byAmount:moveX]]; | 813 byAmount:moveX]]; |
| 807 [homeButton_ setHidden:hide]; | 814 [homeButton_ setHidden:hide]; |
| 808 } | 815 } |
| 809 | 816 |
| 810 // Install the app menu buttons. Calling this repeatedly is inexpensive so it | 817 // Install the app menu buttons. Calling this repeatedly is inexpensive so it |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1186 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 1180 // Do nothing. | 1187 // Do nothing. |
| 1181 } | 1188 } |
| 1182 | 1189 |
| 1183 // (URLDropTargetController protocol) | 1190 // (URLDropTargetController protocol) |
| 1184 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1191 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 1185 return drag_util::IsUnsupportedDropData(profile_, info); | 1192 return drag_util::IsUnsupportedDropData(profile_, info); |
| 1186 } | 1193 } |
| 1187 | 1194 |
| 1188 @end | 1195 @end |
| OLD | NEW |