| 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 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { | 862 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { |
| 863 WebContents* web_contents = GetWebContents(); | 863 WebContents* web_contents = GetWebContents(); |
| 864 if (!web_contents) | 864 if (!web_contents) |
| 865 return false; | 865 return false; |
| 866 | 866 |
| 867 return zoom_decoration_->UpdateIfNecessary( | 867 return zoom_decoration_->UpdateIfNecessary( |
| 868 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, | 868 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, |
| 869 IsLocationBarDark()); | 869 IsLocationBarDark()); |
| 870 } | 870 } |
| 871 | 871 |
| 872 // TODO(spqchan): Add tests for the security state decoration. | |
| 873 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { | 872 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { |
| 874 using SecurityLevel = security_state::SecurityLevel; | 873 using SecurityLevel = security_state::SecurityLevel; |
| 875 SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false); | 874 SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false); |
| 876 | 875 |
| 877 if (tab_changed) | 876 if (tab_changed) |
| 878 security_state_bubble_decoration_->ResetAnimation(); | 877 security_state_bubble_decoration_->ResetAnimation(); |
| 879 | 878 |
| 880 // If there's enough space, but the secure state decoration had animated | 879 // If there's enough space, but the secure state decoration had animated |
| 881 // out, animate it back in. Otherwise, if the security state has changed, | 880 // out, animate it back in. Otherwise, if the security state has changed, |
| 882 // animate the decoration if animation is enabled and the state changed is | 881 // animate the decoration if animation is enabled and the state changed is |
| 883 // not from a tab switch. | 882 // not from a tab switch. |
| 884 if ((ShouldShowSecurityState() || ShouldShowExtensionBubble() || | 883 if ((ShouldShowSecurityState() || ShouldShowExtensionBubble() || |
| 885 ShouldShowChromeBubble()) && | 884 ShouldShowChromeBubble()) && |
| 886 is_width_available_for_security_verbose_) { | 885 is_width_available_for_security_verbose_) { |
| 887 bool is_secure_to_secure = IsSecureConnection(new_security_level) && | 886 if (tab_changed) { |
| 888 IsSecureConnection(security_level_); | |
| 889 bool is_new_security_level = | |
| 890 security_level_ != new_security_level && !is_secure_to_secure; | |
| 891 if (!tab_changed && security_state_bubble_decoration_->HasAnimatedOut()) | |
| 892 security_state_bubble_decoration_->AnimateIn(false); | |
| 893 else if (tab_changed || !CanAnimateSecurityLevel(new_security_level)) | |
| 894 security_state_bubble_decoration_->ShowWithoutAnimation(); | 887 security_state_bubble_decoration_->ShowWithoutAnimation(); |
| 895 else if (is_new_security_level) | 888 } else { |
| 896 security_state_bubble_decoration_->AnimateIn(); | 889 bool is_secure_to_secure = IsSecureConnection(new_security_level) && |
| 890 IsSecureConnection(security_level_); |
| 891 bool is_new_security_level = |
| 892 security_level_ != new_security_level && !is_secure_to_secure; |
| 893 if (!is_new_security_level && |
| 894 security_state_bubble_decoration_->HasAnimatedOut()) { |
| 895 security_state_bubble_decoration_->AnimateIn(false); |
| 896 } else if (!CanAnimateSecurityLevel(new_security_level)) { |
| 897 security_state_bubble_decoration_->ShowWithoutAnimation(); |
| 898 } else if (is_new_security_level) { |
| 899 security_state_bubble_decoration_->AnimateIn(); |
| 900 } |
| 901 } |
| 897 } else if (!is_width_available_for_security_verbose_ || | 902 } else if (!is_width_available_for_security_verbose_ || |
| 898 CanAnimateSecurityLevel(security_level_)) { | 903 (!tab_changed && CanAnimateSecurityLevel(security_level_))) { |
| 899 security_state_bubble_decoration_->AnimateOut(); | 904 security_state_bubble_decoration_->AnimateOut(); |
| 900 } | 905 } |
| 901 | 906 |
| 902 security_level_ = new_security_level; | 907 security_level_ = new_security_level; |
| 903 } | 908 } |
| 904 | 909 |
| 905 bool LocationBarViewMac::CanAnimateSecurityLevel( | 910 bool LocationBarViewMac::CanAnimateSecurityLevel( |
| 906 security_state::SecurityLevel level) const { | 911 security_state::SecurityLevel level) const { |
| 907 return !GetOmniboxView()->IsEditingOrEmpty() && | 912 return !GetOmniboxView()->IsEditingOrEmpty() && |
| 908 (security_level_ == security_state::SecurityLevel::DANGEROUS || | 913 (level == security_state::DANGEROUS || |
| 909 security_level_ == security_state::SecurityLevel::HTTP_SHOW_WARNING); | 914 level == security_state::HTTP_SHOW_WARNING); |
| 910 } | 915 } |
| 911 | 916 |
| 912 bool LocationBarViewMac::IsSecureConnection( | 917 bool LocationBarViewMac::IsSecureConnection( |
| 913 security_state::SecurityLevel level) const { | 918 security_state::SecurityLevel level) const { |
| 914 return level == security_state::SECURE || | 919 return level == security_state::SECURE || |
| 915 level == security_state::EV_SECURE; | 920 level == security_state::EV_SECURE; |
| 916 } | 921 } |
| 917 | 922 |
| 918 void LocationBarViewMac::UpdateAccessibilityViewPosition( | 923 void LocationBarViewMac::UpdateAccessibilityViewPosition( |
| 919 LocationBarDecoration* decoration) { | 924 LocationBarDecoration* decoration) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 945 OnDecorationsChanged(); | 950 OnDecorationsChanged(); |
| 946 } | 951 } |
| 947 | 952 |
| 948 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 953 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 949 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 954 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 950 std::vector<NSView*> views; | 955 std::vector<NSView*> views; |
| 951 for (auto* decoration : decorations) | 956 for (auto* decoration : decorations) |
| 952 views.push_back(decoration->GetAccessibilityView()); | 957 views.push_back(decoration->GetAccessibilityView()); |
| 953 return views; | 958 return views; |
| 954 } | 959 } |
| OLD | NEW |