| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/location_bar/location_bar_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 break; | 167 break; |
| 168 default: | 168 default: |
| 169 // Make it obvious that there's a problem. | 169 // Make it obvious that there's a problem. |
| 170 [[NSColor redColor] set]; | 170 [[NSColor redColor] set]; |
| 171 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize)); | 171 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize)); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 + (void)drawLocationBarIconHTTPForScale:(int)scaleFactor { | 176 + (void)drawLocationBarIconHTTPForScale:(int)scaleFactor { |
| 177 NSBezierPath* circlePath = | 177 if (scaleFactor > 1) { |
| 178 [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(2, 2, 12, 12)]; | 178 NSRect ovalRect = NSMakeRect(2.25, 1.75, 12, 12); |
| 179 [circlePath setLineWidth:1.5]; | 179 NSBezierPath* circlePath = |
| 180 [circlePath stroke]; | 180 [NSBezierPath bezierPathWithOvalInRect:ovalRect]; |
| 181 [circlePath setLineWidth:1.5]; |
| 182 [circlePath stroke]; |
| 181 | 183 |
| 182 NSRectFill(NSMakeRect(7, 4, 2, 5)); | 184 NSRectFill(NSMakeRect(7.5, 4.5, 1.5, 4)); |
| 183 NSRectFill(NSMakeRect(7, 10, 2, 2)); | 185 NSRectFill(NSMakeRect(7.5, 9.5, 1.5, 1.5)); |
| 186 } else { |
| 187 NSRect ovalRect = NSMakeRect(2, 2, 12, 12); |
| 188 NSBezierPath* circlePath = |
| 189 [NSBezierPath bezierPathWithOvalInRect:ovalRect]; |
| 190 [circlePath setLineWidth:1.5]; |
| 191 [circlePath stroke]; |
| 192 |
| 193 NSRectFill(NSMakeRect(7, 4, 2, 5)); |
| 194 NSRectFill(NSMakeRect(7, 10, 2, 2)); |
| 195 } |
| 184 } | 196 } |
| 185 | 197 |
| 186 + (void)drawLocationBarIconHTTPSInvalidForScale:(int)scaleFactor { | 198 + (void)drawLocationBarIconHTTPSInvalidForScale:(int)scaleFactor { |
| 187 // The vector icon is upside down relative to the default OS X coordinate | 199 // The vector icon is upside down relative to the default OS X coordinate |
| 188 // system so rotate by 180 degrees. | 200 // system so rotate by 180 degrees. |
| 189 CGContextRef context = static_cast<CGContextRef>( | 201 CGContextRef context = static_cast<CGContextRef>( |
| 190 [[NSGraphicsContext currentContext] graphicsPort]); | 202 [[NSGraphicsContext currentContext] graphicsPort]); |
| 191 const int kHalfDefaultIconSize = kDefaultIconSize / 2; | 203 const int kHalfDefaultIconSize = kDefaultIconSize / 2; |
| 192 CGContextTranslateCTM(context, kHalfDefaultIconSize, kHalfDefaultIconSize); | 204 CGContextTranslateCTM(context, kHalfDefaultIconSize, kHalfDefaultIconSize); |
| 193 CGContextRotateCTM(context, M_PI); | 205 CGContextRotateCTM(context, M_PI); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 216 [cutOutPath relativeLineToPoint:NSMakePoint(0, -3)]; | 228 [cutOutPath relativeLineToPoint:NSMakePoint(0, -3)]; |
| 217 [cutOutPath relativeLineToPoint:NSMakePoint(2, 0)]; | 229 [cutOutPath relativeLineToPoint:NSMakePoint(2, 0)]; |
| 218 [cutOutPath relativeLineToPoint:NSMakePoint(0, 3)]; | 230 [cutOutPath relativeLineToPoint:NSMakePoint(0, 3)]; |
| 219 [cutOutPath closePath]; | 231 [cutOutPath closePath]; |
| 220 | 232 |
| 221 [trianglePath appendBezierPath:cutOutPath]; | 233 [trianglePath appendBezierPath:cutOutPath]; |
| 222 [trianglePath fill]; | 234 [trianglePath fill]; |
| 223 } | 235 } |
| 224 | 236 |
| 225 + (void)drawLocationBarIconHTTPSValidForScale:(int)scaleFactor { | 237 + (void)drawLocationBarIconHTTPSValidForScale:(int)scaleFactor { |
| 238 NSAffineTransform* transform = [NSAffineTransform transform]; |
| 239 // Adjust down 1px in Retina, so that the lock sits on the text baseline. |
| 240 if (scaleFactor > 1) { |
| 241 [transform translateXBy:0 yBy:-0.5]; |
| 242 } |
| 243 |
| 226 NSBezierPath* rectPath = | 244 NSBezierPath* rectPath = |
| 227 [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(4, 3, 8, 7) | 245 [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(4, 3, 8, 7) |
| 228 xRadius:1 | 246 xRadius:1 |
| 229 yRadius:1]; | 247 yRadius:1]; |
| 248 [rectPath transformUsingAffineTransform:transform]; |
| 230 [rectPath fill]; | 249 [rectPath fill]; |
| 231 | 250 |
| 232 NSBezierPath* curvePath = [NSBezierPath bezierPath]; | 251 NSBezierPath* curvePath = [NSBezierPath bezierPath]; |
| 233 [curvePath moveToPoint:NSMakePoint(5.5, 9.75)]; | 252 [curvePath moveToPoint:NSMakePoint(5.5, 9.75)]; |
| 234 [curvePath lineToPoint:NSMakePoint(5.5, 10)]; | 253 [curvePath lineToPoint:NSMakePoint(5.5, 10)]; |
| 235 [curvePath curveToPoint:NSMakePoint(8, 13) | 254 [curvePath curveToPoint:NSMakePoint(8, 13) |
| 236 controlPoint1:NSMakePoint(5.5, 13) | 255 controlPoint1:NSMakePoint(5.5, 13) |
| 237 controlPoint2:NSMakePoint(7.5, 13)]; | 256 controlPoint2:NSMakePoint(7.5, 13)]; |
| 238 [curvePath curveToPoint:NSMakePoint(10.5, 10) | 257 [curvePath curveToPoint:NSMakePoint(10.5, 10) |
| 239 controlPoint1:NSMakePoint(8.5, 13) | 258 controlPoint1:NSMakePoint(8.5, 13) |
| 240 controlPoint2:NSMakePoint(10.5, 13)]; | 259 controlPoint2:NSMakePoint(10.5, 13)]; |
| 241 [curvePath lineToPoint:NSMakePoint(10.5, 9.75)]; | 260 [curvePath lineToPoint:NSMakePoint(10.5, 9.75)]; |
| 242 [curvePath setLineWidth:1.25]; | 261 [curvePath setLineWidth:1.25]; |
| 262 [curvePath transformUsingAffineTransform:transform]; |
| 243 [curvePath stroke]; | 263 [curvePath stroke]; |
| 244 } | 264 } |
| 245 | 265 |
| 246 @end | 266 @end |
| 247 | 267 |
| 248 // TODO(shess): This code is mostly copied from the gtk | 268 // TODO(shess): This code is mostly copied from the gtk |
| 249 // implementation. Make sure it's all appropriate and flesh it out. | 269 // implementation. Make sure it's all appropriate and flesh it out. |
| 250 | 270 |
| 251 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, | 271 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, |
| 252 CommandUpdater* command_updater, | 272 CommandUpdater* command_updater, |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 | 989 |
| 970 return zoom_decoration_->UpdateIfNecessary( | 990 return zoom_decoration_->UpdateIfNecessary( |
| 971 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, | 991 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, |
| 972 IsLocationBarDark()); | 992 IsLocationBarDark()); |
| 973 } | 993 } |
| 974 | 994 |
| 975 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 995 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
| 976 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 996 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
| 977 OnDecorationsChanged(); | 997 OnDecorationsChanged(); |
| 978 } | 998 } |
| OLD | NEW |