Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 2150733002: [Material][Mac] Update Security Icon Colors in Omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Make it obvious that there's a problem. 172 // Make it obvious that there's a problem.
173 [[NSColor redColor] set]; 173 [[NSColor redColor] set];
174 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize)); 174 NSRectFill(NSMakeRect(0, 0, kDefaultIconSize, kDefaultIconSize));
175 break; 175 break;
176 } 176 }
177 } 177 }
178 178
179 + (void)drawLocationBarIconHTTPForScale:(int)scaleFactor { 179 + (void)drawLocationBarIconHTTPForScale:(int)scaleFactor {
180 if (scaleFactor > 1) { 180 if (scaleFactor > 1) {
181 NSRect ovalRect = NSMakeRect(2.25, 1.75, 12, 12); 181 NSRect ovalRect = NSMakeRect(2.25, 1.75, 12, 12);
182 NSBezierPath* circlePath = 182 NSBezierPath* circlePath = [NSBezierPath bezierPathWithOvalInRect:ovalRect];
183 [NSBezierPath bezierPathWithOvalInRect:ovalRect];
184 [circlePath setLineWidth:1.5]; 183 [circlePath setLineWidth:1.5];
185 [circlePath stroke]; 184 [circlePath stroke];
186 185
187 NSRectFill(NSMakeRect(7.5, 4.5, 1.5, 4)); 186 NSRectFill(NSMakeRect(7.5, 4.5, 1.5, 4));
188 NSRectFill(NSMakeRect(7.5, 9.5, 1.5, 1.5)); 187 NSRectFill(NSMakeRect(7.5, 9.5, 1.5, 1.5));
189 } else { 188 } else {
190 NSRect ovalRect = NSMakeRect(2, 2, 12, 12); 189 NSRect ovalRect = NSMakeRect(2, 2, 12, 12);
191 NSBezierPath* circlePath = 190 NSBezierPath* circlePath = [NSBezierPath bezierPathWithOvalInRect:ovalRect];
192 [NSBezierPath bezierPathWithOvalInRect:ovalRect];
193 [circlePath setLineWidth:1.5]; 191 [circlePath setLineWidth:1.5];
194 [circlePath stroke]; 192 [circlePath stroke];
195 193
196 NSRectFill(NSMakeRect(7, 4, 2, 5)); 194 NSRectFill(NSMakeRect(7, 4, 2, 5));
197 NSRectFill(NSMakeRect(7, 10, 2, 2)); 195 NSRectFill(NSMakeRect(7, 10, 2, 2));
198 } 196 }
199 } 197 }
200 198
201 + (void)drawLocationBarIconHTTPSInvalidForScale:(int)scaleFactor { 199 + (void)drawLocationBarIconHTTPSInvalidForScale:(int)scaleFactor {
202 // The vector icon is upside down relative to the default OS X coordinate 200 // The vector icon is upside down relative to the default OS X coordinate
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 Update(nullptr); 736 Update(nullptr);
739 } 737 }
740 738
741 void LocationBarViewMac::UpdateLocationIcon() { 739 void LocationBarViewMac::UpdateLocationIcon() {
742 bool in_dark_mode = IsLocationBarDark(); 740 bool in_dark_mode = IsLocationBarDark();
743 741
744 SkColor vector_icon_color = gfx::kPlaceholderColor; 742 SkColor vector_icon_color = gfx::kPlaceholderColor;
745 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; 743 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE;
746 if (ShouldShowEVBubble()) { 744 if (ShouldShowEVBubble()) {
747 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; 745 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID;
748 vector_icon_color = in_dark_mode 746 vector_icon_color =
749 ? kMaterialDarkVectorIconColor 747 in_dark_mode ? kMaterialDarkVectorIconColor : gfx::kGoogleGreen700;
750 : gfx::kGoogleGreen700;
751 } else { 748 } else {
752 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode); 749 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode);
753 if (in_dark_mode) { 750 if (in_dark_mode) {
754 vector_icon_color = SK_ColorWHITE; 751 vector_icon_color = SK_ColorWHITE;
752 } else if (vector_icon_id != gfx::VectorIconId::OMNIBOX_SEARCH) {
753 security_state::SecurityStateModel::SecurityLevel security_level =
754 GetToolbarModel()->GetSecurityLevel(false);
755 if (security_level == security_state::SecurityStateModel::NONE) {
756 vector_icon_color = gfx::kChromeIconGrey;
757 } else if (vector_icon_id != gfx::VectorIconId::OMNIBOX_SEARCH &&
758 (security_level == security_state::SecurityStateModel::EV_SECURE ||
759 security_level == security_state::SecurityStateModel::SECURE)) {
760 vector_icon_color = gfx::kGoogleGreen700;
761 } else if (security_level ==
762 security_state::SecurityStateModel::SECURITY_ERROR) {
763 vector_icon_color = gfx::kGoogleRed700;
764 } else if (security_level ==
765 security_state::SecurityStateModel::SECURITY_WARNING){
766 vector_icon_color = gfx::kGoogleYellow700;
767 }
755 } else { 768 } else {
756 vector_icon_color = OmniboxViewMac::BaseTextColorSkia(in_dark_mode); 769 vector_icon_color = OmniboxViewMac::BaseTextColorSkia(in_dark_mode);
757 } 770 }
758 } 771 }
759 772
760 // If the theme is dark, then the color should always be
761 // kMaterialDarkVectorIconColor.
762 if (in_dark_mode)
763 vector_icon_color = kMaterialDarkVectorIconColor;
764
765 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); 773 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE);
766 NSImage* image = 774 NSImage* image =
767 [LocationBarImageRep imageForId:vector_icon_id color:vector_icon_color]; 775 [LocationBarImageRep imageForId:vector_icon_id color:vector_icon_color];
768 776
769 location_icon_decoration_->SetImage(image); 777 location_icon_decoration_->SetImage(image);
770 ev_bubble_decoration_->SetImage(image); 778 ev_bubble_decoration_->SetImage(image);
771 Layout(); 779 Layout();
772 } 780 }
773 781
774 void LocationBarViewMac::UpdateColorsToMatchTheme() { 782 void LocationBarViewMac::UpdateColorsToMatchTheme() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 1000
993 return zoom_decoration_->UpdateIfNecessary( 1001 return zoom_decoration_->UpdateIfNecessary(
994 ui_zoom::ZoomController::FromWebContents(web_contents), 1002 ui_zoom::ZoomController::FromWebContents(web_contents),
995 default_zoom_changed, IsLocationBarDark()); 1003 default_zoom_changed, IsLocationBarDark());
996 } 1004 }
997 1005
998 void LocationBarViewMac::OnDefaultZoomLevelChanged() { 1006 void LocationBarViewMac::OnDefaultZoomLevelChanged() {
999 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) 1007 if (UpdateZoomDecoration(/*default_zoom_changed=*/true))
1000 OnDecorationsChanged(); 1008 OnDecorationsChanged();
1001 } 1009 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698