| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/passwords/passwords_bubble_utils.h" | 5 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/ui/chrome_style.h" | 9 #include "chrome/browser/ui/chrome_style.h" |
| 10 #include "skia/ext/skia_utils_mac.h" | 10 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 [textField setDrawsBackground:NO]; | 66 [textField setDrawsBackground:NO]; |
| 67 [textField setBezeled:NO]; | 67 [textField setBezeled:NO]; |
| 68 [textField setFont:LabelFont()]; | 68 [textField setFont:LabelFont()]; |
| 69 [[textField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | 69 [[textField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 70 [textField sizeToFit]; | 70 [textField sizeToFit]; |
| 71 } | 71 } |
| 72 | 72 |
| 73 std::pair<CGFloat, CGFloat> GetResizedColumns( | 73 std::pair<CGFloat, CGFloat> GetResizedColumns( |
| 74 CGFloat maxWidth, | 74 CGFloat maxWidth, |
| 75 std::pair<CGFloat, CGFloat> columnsWidth) { | 75 std::pair<CGFloat, CGFloat> columnsWidth) { |
| 76 DCHECK_GE(maxWidth, kItemLabelSpacing + kMinUsernameSize); |
| 76 // Free space can be negative. | 77 // Free space can be negative. |
| 77 CGFloat freeSpace = | 78 CGFloat freeSpace = |
| 78 maxWidth - (columnsWidth.first + columnsWidth.second + kItemLabelSpacing); | 79 maxWidth - (columnsWidth.first + columnsWidth.second + kItemLabelSpacing); |
| 79 if (freeSpace >= 0) { | 80 if (freeSpace >= 0) { |
| 80 return std::make_pair(columnsWidth.first + freeSpace / 2, | 81 return std::make_pair(columnsWidth.first + freeSpace / 2, |
| 81 columnsWidth.second + freeSpace / 2); | 82 columnsWidth.second + freeSpace / 2); |
| 82 } | 83 } |
| 83 // Make sure that the sizes are nonnegative. | 84 // Make sure that the sizes are nonnegative. |
| 84 CGFloat firstColumnPercent = | 85 CGFloat firstColumnPercent = |
| 85 columnsWidth.first / (columnsWidth.first + columnsWidth.second); | 86 columnsWidth.first / (columnsWidth.first + columnsWidth.second); |
| 87 CGFloat firstColumnSize = std::max( |
| 88 kMinUsernameSize, columnsWidth.first + freeSpace * firstColumnPercent); |
| 86 return std::make_pair( | 89 return std::make_pair( |
| 87 columnsWidth.first + freeSpace * firstColumnPercent, | 90 firstColumnSize, |
| 88 columnsWidth.second + freeSpace * (1 - firstColumnPercent)); | 91 maxWidth - kItemLabelSpacing - firstColumnSize); |
| 89 } | 92 } |
| 90 | 93 |
| 91 NSSecureTextField* PasswordLabel(const base::string16& text) { | 94 NSSecureTextField* PasswordLabel(const base::string16& text) { |
| 92 base::scoped_nsobject<NSSecureTextField> textField( | 95 base::scoped_nsobject<NSSecureTextField> textField( |
| 93 [[NSSecureTextField alloc] initWithFrame:NSZeroRect]); | 96 [[NSSecureTextField alloc] initWithFrame:NSZeroRect]); |
| 94 InitLabel(textField, text); | 97 InitLabel(textField, text); |
| 95 return textField.autorelease(); | 98 return textField.autorelease(); |
| 96 } | 99 } |
| 97 | 100 |
| 98 NSButton* DialogButton(NSString* title) { | 101 NSButton* DialogButton(NSString* title) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 gfx::Range range, | 147 gfx::Range range, |
| 145 id<NSTextViewDelegate> delegate) { | 148 id<NSTextViewDelegate> delegate) { |
| 146 return LabelWithLink( | 149 return LabelWithLink( |
| 147 text, color, | 150 text, color, |
| 148 ResourceBundle::GetSharedInstance() | 151 ResourceBundle::GetSharedInstance() |
| 149 .GetFontList(ResourceBundle::SmallFont) | 152 .GetFontList(ResourceBundle::SmallFont) |
| 150 .GetPrimaryFont() | 153 .GetPrimaryFont() |
| 151 .GetNativeFont(), | 154 .GetNativeFont(), |
| 152 range, delegate); | 155 range, delegate); |
| 153 } | 156 } |
| OLD | NEW |