Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 | 818 |
| 819 void LocationBarView::RefreshLocationIcon() { | 819 void LocationBarView::RefreshLocationIcon() { |
| 820 // |omnibox_view_| may not be ready yet if Init() has not been called. The | 820 // |omnibox_view_| may not be ready yet if Init() has not been called. The |
| 821 // icon will be set soon by OnChanged(). | 821 // icon will be set soon by OnChanged(). |
| 822 if (!omnibox_view_) | 822 if (!omnibox_view_) |
| 823 return; | 823 return; |
| 824 | 824 |
| 825 security_state::SecurityStateModel::SecurityLevel security_level = | 825 security_state::SecurityStateModel::SecurityLevel security_level = |
| 826 GetToolbarModel()->GetSecurityLevel(false); | 826 GetToolbarModel()->GetSecurityLevel(false); |
| 827 SkColor icon_color = | 827 SkColor icon_color = |
| 828 (security_level == security_state::SecurityStateModel::NONE) | 828 (security_level == security_state::SecurityStateModel::NONE || |
| 829 security_level == security_state::SecurityStateModel::HTTP_SHOW_WARNING) | |
|
Peter Kasting
2016/10/17 20:56:39
Hmm, should SHOW_WARNING really use the text color
felt
2016/10/17 22:56:58
That's correct. It intentionally is set to show as
| |
| 829 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) | 830 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) |
| 830 : GetSecureTextColor(security_level); | 831 : GetSecureTextColor(security_level); |
| 831 location_icon_view_->SetImage(gfx::CreateVectorIcon( | 832 location_icon_view_->SetImage(gfx::CreateVectorIcon( |
| 832 omnibox_view_->GetVectorIcon(), kIconWidth, icon_color)); | 833 omnibox_view_->GetVectorIcon(), kIconWidth, icon_color)); |
| 833 } | 834 } |
| 834 | 835 |
| 835 bool LocationBarView::RefreshContentSettingViews() { | 836 bool LocationBarView::RefreshContentSettingViews() { |
| 836 bool visibility_changed = false; | 837 bool visibility_changed = false; |
| 837 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 838 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 838 i != content_setting_views_.end(); ++i) { | 839 i != content_setting_views_.end(); ++i) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 security_state::SecurityStateModel::EV_SECURE) && | 1012 security_state::SecurityStateModel::EV_SECURE) && |
| 1012 should_show_secure_state_; | 1013 should_show_secure_state_; |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 bool LocationBarView::ShouldShowSecurityChip() const { | 1016 bool LocationBarView::ShouldShowSecurityChip() const { |
| 1016 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1017 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1017 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1018 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1018 return ((level == SecurityLevel::SECURE || | 1019 return ((level == SecurityLevel::SECURE || |
| 1019 level == SecurityLevel::EV_SECURE) && | 1020 level == SecurityLevel::EV_SECURE) && |
| 1020 should_show_secure_state_) || | 1021 should_show_secure_state_) || |
| 1021 level == SecurityLevel::DANGEROUS; | 1022 level == SecurityLevel::DANGEROUS || |
| 1023 level == SecurityLevel::HTTP_SHOW_WARNING; | |
|
Peter Kasting
2016/10/17 20:56:39
Nit: Shorter, and seems more readable:
using Se
felt
2016/10/17 22:56:58
Done.
| |
| 1022 } | 1024 } |
| 1023 | 1025 |
| 1024 bool LocationBarView::ShouldAnimateSecurityChip() const { | 1026 bool LocationBarView::ShouldAnimateSecurityChip() const { |
| 1025 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1027 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1026 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1028 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1027 bool is_secure_level = | 1029 bool is_secure_level = |
| 1028 level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE; | 1030 level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE; |
| 1029 return ShouldShowSecurityChip() && | 1031 return ShouldShowSecurityChip() && |
| 1030 ((level == SecurityLevel::DANGEROUS && | 1032 (((level == SecurityLevel::DANGEROUS || |
| 1033 level == SecurityLevel::HTTP_SHOW_WARNING) && | |
| 1031 should_animate_nonsecure_state_) || | 1034 should_animate_nonsecure_state_) || |
| 1032 (is_secure_level && should_animate_secure_state_)); | 1035 (is_secure_level && should_animate_secure_state_)); |
|
Peter Kasting
2016/10/17 20:56:39
Nit: Feels more readable to me, and is parallel to
felt
2016/10/17 22:56:58
Done.
| |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 //////////////////////////////////////////////////////////////////////////////// | 1038 //////////////////////////////////////////////////////////////////////////////// |
| 1036 // LocationBarView, private LocationBar implementation: | 1039 // LocationBarView, private LocationBar implementation: |
| 1037 | 1040 |
| 1038 void LocationBarView::ShowFirstRunBubble() { | 1041 void LocationBarView::ShowFirstRunBubble() { |
| 1039 // Wait until search engines have loaded to show the first run bubble. | 1042 // Wait until search engines have loaded to show the first run bubble. |
| 1040 TemplateURLService* url_service = | 1043 TemplateURLService* url_service = |
| 1041 TemplateURLServiceFactory::GetForProfile(profile()); | 1044 TemplateURLServiceFactory::GetForProfile(profile()); |
| 1042 if (!url_service->loaded()) { | 1045 if (!url_service->loaded()) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1340 // LocationBarView, private TemplateURLServiceObserver implementation: | 1343 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1341 | 1344 |
| 1342 void LocationBarView::OnTemplateURLServiceChanged() { | 1345 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1343 template_url_service_->RemoveObserver(this); | 1346 template_url_service_->RemoveObserver(this); |
| 1344 template_url_service_ = nullptr; | 1347 template_url_service_ = nullptr; |
| 1345 // If the browser is no longer active, let's not show the info bubble, as this | 1348 // If the browser is no longer active, let's not show the info bubble, as this |
| 1346 // would make the browser the active window again. | 1349 // would make the browser the active window again. |
| 1347 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1350 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1348 ShowFirstRunBubble(); | 1351 ShowFirstRunBubble(); |
| 1349 } | 1352 } |
| OLD | NEW |