| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 - (void)dealloc { | 115 - (void)dealloc { |
| 116 [fillColor_ release]; | 116 [fillColor_ release]; |
| 117 [super dealloc]; | 117 [super dealloc]; |
| 118 } | 118 } |
| 119 | 119 |
| 120 + (NSImage*)imageForId:(gfx::VectorIconId)vectorIconId | 120 + (NSImage*)imageForId:(gfx::VectorIconId)vectorIconId |
| 121 color:(SkColor)vectorIconColor { | 121 color:(SkColor)vectorIconColor { |
| 122 if (vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTP && | 122 if (vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTP && |
| 123 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID && | 123 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID && |
| 124 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID) { | 124 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID && |
| 125 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID_INVERT && |
| 126 vectorIconId != gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_INVERT) { |
| 125 return NSImageFromImageSkiaWithColorSpace( | 127 return NSImageFromImageSkiaWithColorSpace( |
| 126 gfx::CreateVectorIcon(vectorIconId, kDefaultIconSize, vectorIconColor), | 128 gfx::CreateVectorIcon(vectorIconId, kDefaultIconSize, vectorIconColor), |
| 127 base::mac::GetSRGBColorSpace()); | 129 base::mac::GetSRGBColorSpace()); |
| 128 } | 130 } |
| 129 | 131 |
| 130 base::scoped_nsobject<LocationBarImageRep> imageRep = | 132 base::scoped_nsobject<LocationBarImageRep> imageRep = |
| 131 [[LocationBarImageRep alloc] | 133 [[LocationBarImageRep alloc] |
| 132 initWithDrawSelector:@selector(drawLocationBarIcon:) | 134 initWithDrawSelector:@selector(drawLocationBarIcon:) |
| 133 delegate:[LocationBarImageRep class]]; | 135 delegate:[LocationBarImageRep class]]; |
| 134 [imageRep setIconId:vectorIconId]; | 136 [imageRep setIconId:vectorIconId]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 152 [[NSGraphicsContext currentContext] graphicsPort]); | 154 [[NSGraphicsContext currentContext] graphicsPort]); |
| 153 CGRect unitRect = CGRectMake(0.0, 0.0, 1.0, 1.0); | 155 CGRect unitRect = CGRectMake(0.0, 0.0, 1.0, 1.0); |
| 154 CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, unitRect); | 156 CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, unitRect); |
| 155 int scaleFactor = deviceRect.size.height; | 157 int scaleFactor = deviceRect.size.height; |
| 156 | 158 |
| 157 switch ([imageRep iconId]) { | 159 switch ([imageRep iconId]) { |
| 158 case gfx::VectorIconId::LOCATION_BAR_HTTP: | 160 case gfx::VectorIconId::LOCATION_BAR_HTTP: |
| 159 [self drawLocationBarIconHTTPForScale:scaleFactor]; | 161 [self drawLocationBarIconHTTPForScale:scaleFactor]; |
| 160 break; | 162 break; |
| 161 case gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID: | 163 case gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID: |
| 164 case gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID_INVERT: |
| 162 [self drawLocationBarIconHTTPSInvalidForScale:scaleFactor]; | 165 [self drawLocationBarIconHTTPSInvalidForScale:scaleFactor]; |
| 163 break; | 166 break; |
| 167 case gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_INVERT: |
| 164 case gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID: | 168 case gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID: |
| 165 [self drawLocationBarIconHTTPSValidForScale:scaleFactor]; | 169 [self drawLocationBarIconHTTPSValidForScale:scaleFactor]; |
| 166 break; | 170 break; |
| 167 default: | 171 default: |
| 168 // Make it obvious that there's a problem. | 172 // Make it obvious that there's a problem. |
| 169 [[NSColor redColor] set]; | 173 [[NSColor redColor] set]; |
| 170 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize)); | 174 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize)); |
| 171 break; | 175 break; |
| 172 } | 176 } |
| 173 } | 177 } |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 992 |
| 989 return zoom_decoration_->UpdateIfNecessary( | 993 return zoom_decoration_->UpdateIfNecessary( |
| 990 ui_zoom::ZoomController::FromWebContents(web_contents), | 994 ui_zoom::ZoomController::FromWebContents(web_contents), |
| 991 default_zoom_changed, IsLocationBarDark()); | 995 default_zoom_changed, IsLocationBarDark()); |
| 992 } | 996 } |
| 993 | 997 |
| 994 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 998 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
| 995 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 999 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
| 996 OnDecorationsChanged(); | 1000 OnDecorationsChanged(); |
| 997 } | 1001 } |
| OLD | NEW |