| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 namespace { | 81 namespace { |
| 82 | 82 |
| 83 // Vertical space between the bottom edge of the location_bar and the first run | 83 // Vertical space between the bottom edge of the location_bar and the first run |
| 84 // bubble arrow point. | 84 // bubble arrow point. |
| 85 const static int kFirstRunBubbleYOffset = 1; | 85 const static int kFirstRunBubbleYOffset = 1; |
| 86 | 86 |
| 87 const int kDefaultIconSize = 16; | 87 const int kDefaultIconSize = 16; |
| 88 | 88 |
| 89 // Color of the vector graphic icons when the location bar is dark. | 89 // Color of the vector graphic icons when the location bar is dark. |
| 90 // SkColorSetARGB(0xCC, 0xFF, 0xFF 0xFF); | 90 // SkColorSetARGB(0xCC, 0xFF, 0xFF 0xFF); |
| 91 const SkColor kMaterialDarkVectorIconColor = 0xCCFFFFFF; | 91 const SkColor kMaterialDarkVectorIconColor = SK_ColorWHITE; |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 // A temporary class that draws hardcoded HTTP graphic icons for Material | 95 // A temporary class that draws hardcoded HTTP graphic icons for Material |
| 96 // design. This class will be removed once the Material icons are available | 96 // design. This class will be removed once the Material icons are available |
| 97 // in M53. | 97 // in M53. |
| 98 @interface LocationBarImageRep : NSCustomImageRep | 98 @interface LocationBarImageRep : NSCustomImageRep |
| 99 @property(assign, nonatomic) gfx::VectorIconId iconId; | 99 @property(assign, nonatomic) gfx::VectorIconId iconId; |
| 100 @property(retain, nonatomic) NSColor* fillColor; | 100 @property(retain, nonatomic) NSColor* fillColor; |
| 101 | 101 |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 Update(nullptr); | 714 Update(nullptr); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void LocationBarViewMac::UpdateLocationIcon() { | 717 void LocationBarViewMac::UpdateLocationIcon() { |
| 718 bool in_dark_mode = IsLocationBarDark(); | 718 bool in_dark_mode = IsLocationBarDark(); |
| 719 | 719 |
| 720 SkColor vector_icon_color = gfx::kPlaceholderColor; | 720 SkColor vector_icon_color = gfx::kPlaceholderColor; |
| 721 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; | 721 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; |
| 722 if (ShouldShowEVBubble()) { | 722 if (ShouldShowEVBubble()) { |
| 723 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; | 723 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; |
| 724 vector_icon_color = in_dark_mode | 724 vector_icon_color = gfx::kGoogleGreen700; |
| 725 ? kMaterialDarkVectorIconColor | |
| 726 : gfx::kGoogleGreen700; | |
| 727 } else { | 725 } else { |
| 728 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode); | 726 vector_icon_id = omnibox_view_->GetVectorIcon(); |
| 729 if (in_dark_mode) { | 727 security_state::SecurityStateModel::SecurityLevel security_level = |
| 730 vector_icon_color = SK_ColorWHITE; | 728 GetToolbarModel()->GetSecurityLevel(false); |
| 729 if (security_level == security_state::SecurityStateModel::NONE) { |
| 730 vector_icon_color = gfx::kChromeIconGrey; |
| 731 } else { | 731 } else { |
| 732 vector_icon_color = OmniboxViewMac::BaseTextColorSkia(in_dark_mode); | 732 NSColor* sRGBColor = |
| 733 OmniboxViewMac::GetSecureTextColor(security_level, in_dark_mode); |
| 734 NSColor* deviceColor = |
| 735 [sRGBColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; |
| 736 vector_icon_color = skia::NSDeviceColorToSkColor(deviceColor); |
| 733 } | 737 } |
| 734 } | 738 } |
| 735 | 739 |
| 740 // If the theme is dark, then the color should always be |
| 741 // kMaterialDarkVectorIconColor. |
| 742 if (in_dark_mode) |
| 743 vector_icon_color = kMaterialDarkVectorIconColor; |
| 744 |
| 736 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); | 745 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); |
| 737 NSImage* image = | 746 NSImage* image = |
| 738 [LocationBarImageRep imageForId:vector_icon_id color:vector_icon_color]; | 747 [LocationBarImageRep imageForId:vector_icon_id color:vector_icon_color]; |
| 739 | 748 |
| 740 location_icon_decoration_->SetImage(image); | 749 location_icon_decoration_->SetImage(image); |
| 741 ev_bubble_decoration_->SetImage(image); | 750 ev_bubble_decoration_->SetImage(image); |
| 742 Layout(); | 751 Layout(); |
| 743 } | 752 } |
| 744 | 753 |
| 745 void LocationBarViewMac::UpdateColorsToMatchTheme() { | 754 void LocationBarViewMac::UpdateColorsToMatchTheme() { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 972 |
| 964 return zoom_decoration_->UpdateIfNecessary( | 973 return zoom_decoration_->UpdateIfNecessary( |
| 965 ui_zoom::ZoomController::FromWebContents(web_contents), | 974 ui_zoom::ZoomController::FromWebContents(web_contents), |
| 966 default_zoom_changed, IsLocationBarDark()); | 975 default_zoom_changed, IsLocationBarDark()); |
| 967 } | 976 } |
| 968 | 977 |
| 969 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 978 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
| 970 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 979 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
| 971 OnDecorationsChanged(); | 980 OnDecorationsChanged(); |
| 972 } | 981 } |
| OLD | NEW |