| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 using content::WebContents; | 74 using content::WebContents; |
| 75 | 75 |
| 76 namespace { | 76 namespace { |
| 77 | 77 |
| 78 // Duration of the toolbar animation. | 78 // Duration of the toolbar animation. |
| 79 const NSTimeInterval kToolBarAnimationDuration = 0.12; | 79 const NSTimeInterval kToolBarAnimationDuration = 0.12; |
| 80 | 80 |
| 81 // The height of the location bar in Material Design. | 81 // The height of the location bar in Material Design. |
| 82 const CGFloat kMaterialDesignLocationBarHeight = 28; | 82 const CGFloat kMaterialDesignLocationBarHeight = 28; |
| 83 | 83 |
| 84 // The padding between the top of the toolbar and the top of the |
| 85 // location bar. |
| 86 const CGFloat kMaterialDesignLocationBarPadding = 2; |
| 87 |
| 84 // The padding between Material Design elements and the edges of the toolbar. | 88 // The padding between Material Design elements and the edges of the toolbar. |
| 85 const CGFloat kMaterialDesignElementPadding = 4; | 89 const CGFloat kMaterialDesignElementPadding = 4; |
| 86 | 90 |
| 87 // Toolbar buttons are 24x24 and centered in a 28x28 space, so there is a 2pt- | 91 // Toolbar buttons are 24x24 and centered in a 28x28 space, so there is a 2pt- |
| 88 // wide inset. | 92 // wide inset. |
| 89 const CGFloat kMaterialDesignButtonInset = 2; | 93 const CGFloat kMaterialDesignButtonInset = 2; |
| 90 | 94 |
| 91 // The y-offset of the browser actions container from the location bar. | 95 // The y-offset of the browser actions container from the location bar. |
| 92 const CGFloat kMaterialDesignContainerYOffset = 2; | 96 const CGFloat kMaterialDesignContainerYOffset = 2; |
| 93 | 97 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 305 |
| 302 // Set the toolbar height. | 306 // Set the toolbar height. |
| 303 NSRect frame = [toolbarView frame]; | 307 NSRect frame = [toolbarView frame]; |
| 304 frame.size.height = [self baseToolbarHeight]; | 308 frame.size.height = [self baseToolbarHeight]; |
| 305 [toolbarView setFrame:frame]; | 309 [toolbarView setFrame:frame]; |
| 306 | 310 |
| 307 NSRect backButtonFrame = [backButton_ frame]; | 311 NSRect backButtonFrame = [backButton_ frame]; |
| 308 backButtonFrame.origin.x = | 312 backButtonFrame.origin.x = |
| 309 kMaterialDesignElementPadding + kMaterialDesignButtonInset; | 313 kMaterialDesignElementPadding + kMaterialDesignButtonInset; |
| 310 backButtonFrame.origin.y = NSMaxY(toolbarBounds) - | 314 backButtonFrame.origin.y = NSMaxY(toolbarBounds) - |
| 311 kMaterialDesignElementPadding - kMaterialDesignButtonInset - | 315 kMaterialDesignElementPadding - toolbarButtonSize.height; |
| 312 toolbarButtonSize.height; | |
| 313 backButtonFrame.size = toolbarButtonSize; | 316 backButtonFrame.size = toolbarButtonSize; |
| 314 [backButton_ setFrame:backButtonFrame]; | 317 [backButton_ setFrame:backButtonFrame]; |
| 315 | 318 |
| 316 NSRect forwardButtonFrame = [forwardButton_ frame]; | 319 NSRect forwardButtonFrame = [forwardButton_ frame]; |
| 317 forwardButtonFrame.origin.x = | 320 forwardButtonFrame.origin.x = |
| 318 NSMaxX(backButtonFrame) + 2 * kMaterialDesignButtonInset; | 321 NSMaxX(backButtonFrame) + 2 * kMaterialDesignButtonInset; |
| 319 forwardButtonFrame.origin.y = backButtonFrame.origin.y; | 322 forwardButtonFrame.origin.y = backButtonFrame.origin.y; |
| 320 forwardButtonFrame.size = toolbarButtonSize; | 323 forwardButtonFrame.size = toolbarButtonSize; |
| 321 [forwardButton_ setFrame:forwardButtonFrame]; | 324 [forwardButton_ setFrame:forwardButtonFrame]; |
| 322 | 325 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 menuButtonFrame.origin.y = homeButtonFrame.origin.y; | 357 menuButtonFrame.origin.y = homeButtonFrame.origin.y; |
| 355 menuButtonFrame.size = toolbarButtonSize; | 358 menuButtonFrame.size = toolbarButtonSize; |
| 356 [appMenuButton_ setFrame:menuButtonFrame]; | 359 [appMenuButton_ setFrame:menuButtonFrame]; |
| 357 | 360 |
| 358 // Adjust the size and location on the location bar to take up the | 361 // Adjust the size and location on the location bar to take up the |
| 359 // space between the reload and menu buttons. | 362 // space between the reload and menu buttons. |
| 360 NSRect locationBarFrame = [locationBar_ frame]; | 363 NSRect locationBarFrame = [locationBar_ frame]; |
| 361 locationBarFrame.origin.x = NSMaxX(homeButtonFrame) + | 364 locationBarFrame.origin.x = NSMaxX(homeButtonFrame) + |
| 362 kMaterialDesignButtonInset; | 365 kMaterialDesignButtonInset; |
| 363 locationBarFrame.origin.y = NSMaxY(toolbarBounds) - | 366 locationBarFrame.origin.y = NSMaxY(toolbarBounds) - |
| 364 kMaterialDesignElementPadding - kMaterialDesignLocationBarHeight; | 367 kMaterialDesignLocationBarPadding - kMaterialDesignLocationBarHeight; |
| 365 locationBarFrame.size.width = | 368 locationBarFrame.size.width = |
| 366 menuButtonFrame.origin.x - | 369 menuButtonFrame.origin.x - |
| 367 locationBarFrame.origin.x; | 370 locationBarFrame.origin.x; |
| 368 locationBarFrame.size.height = kMaterialDesignLocationBarHeight; | 371 locationBarFrame.size.height = kMaterialDesignLocationBarHeight; |
| 369 [locationBar_ setFrame:locationBarFrame]; | 372 [locationBar_ setFrame:locationBarFrame]; |
| 370 | 373 |
| 371 // Correctly position the extension buttons' container view. | 374 // Correctly position the extension buttons' container view. |
| 372 NSRect containerFrame = [browserActionsContainerView_ frame]; | 375 NSRect containerFrame = [browserActionsContainerView_ frame]; |
| 373 containerFrame.size.width += kMaterialDesignButtonInset; | 376 containerFrame.size.width += kMaterialDesignButtonInset; |
| 374 containerFrame.origin.y = | 377 containerFrame.origin.y = |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1155 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 1153 // Do nothing. | 1156 // Do nothing. |
| 1154 } | 1157 } |
| 1155 | 1158 |
| 1156 // (URLDropTargetController protocol) | 1159 // (URLDropTargetController protocol) |
| 1157 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1160 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 1158 return drag_util::IsUnsupportedDropData(profile_, info); | 1161 return drag_util::IsUnsupportedDropData(profile_, info); |
| 1159 } | 1162 } |
| 1160 | 1163 |
| 1161 @end | 1164 @end |
| OLD | NEW |