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

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

Issue 2650843002: [Mac] Security Chip Animation Edge Cases (Closed)
Patch Set: Created 3 years, 11 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 #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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { 867 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) {
868 WebContents* web_contents = GetWebContents(); 868 WebContents* web_contents = GetWebContents();
869 if (!web_contents) 869 if (!web_contents)
870 return false; 870 return false;
871 871
872 return zoom_decoration_->UpdateIfNecessary( 872 return zoom_decoration_->UpdateIfNecessary(
873 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 873 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
874 IsLocationBarDark()); 874 IsLocationBarDark());
875 } 875 }
876 876
877 // TODO(spqchan): Add tests for the security state decoration.
Robert Sesek 2017/01/24 16:52:54 Yes please :)
877 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { 878 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) {
878 using SecurityLevel = security_state::SecurityLevel; 879 using SecurityLevel = security_state::SecurityLevel;
879 SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false); 880 SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false);
880 881
882 if (tab_changed)
883 security_state_bubble_decoration_->ResetAnimation();
884
881 // If there's enough space, but the secure state decoration had animated 885 // If there's enough space, but the secure state decoration had animated
882 // out, animate it back in. Otherwise, if the security state has changed, 886 // out, animate it back in. Otherwise, if the security state has changed,
883 // animate the decoration if animation is enabled and the state changed is 887 // animate the decoration if animation is enabled and the state changed is
884 // not from a tab switch. 888 // not from a tab switch.
885 if ((ShouldShowSecurityState() || ShouldShowExtensionBubble() || 889 if ((ShouldShowSecurityState() || ShouldShowExtensionBubble() ||
886 ShouldShowChromeBubble()) && 890 ShouldShowChromeBubble()) &&
887 is_width_available_for_security_verbose_) { 891 is_width_available_for_security_verbose_) {
888 bool is_secure_to_secure = IsSecureConnection(new_security_level) && 892 bool is_secure_to_secure = IsSecureConnection(new_security_level) &&
889 IsSecureConnection(security_level_); 893 IsSecureConnection(security_level_);
890 bool is_new_security_level = 894 bool is_new_security_level =
891 security_level_ != new_security_level && !is_secure_to_secure; 895 security_level_ != new_security_level && !is_secure_to_secure;
892 if (!tab_changed && security_state_bubble_decoration_->HasAnimatedOut()) 896 if (!tab_changed && security_state_bubble_decoration_->HasAnimatedOut())
893 security_state_bubble_decoration_->AnimateIn(false); 897 security_state_bubble_decoration_->AnimateIn(false);
894 else if (tab_changed || !CanAnimateSecurityLevel(new_security_level)) 898 else if (tab_changed || !CanAnimateSecurityLevel(new_security_level))
895 security_state_bubble_decoration_->ShowWithoutAnimation(); 899 security_state_bubble_decoration_->ShowWithoutAnimation();
896 else if (is_new_security_level) 900 else if (is_new_security_level)
897 security_state_bubble_decoration_->AnimateIn(); 901 security_state_bubble_decoration_->AnimateIn();
898 } else if (!is_width_available_for_security_verbose_ || 902 } else if (!is_width_available_for_security_verbose_ ||
899 CanAnimateSecurityLevel(security_level_)) { 903 CanAnimateSecurityLevel(security_level_)) {
900 security_state_bubble_decoration_->AnimateOut(); 904 security_state_bubble_decoration_->AnimateOut();
901 } 905 }
902 906
903 security_level_ = new_security_level; 907 security_level_ = new_security_level;
904 } 908 }
905 909
906 bool LocationBarViewMac::CanAnimateSecurityLevel( 910 bool LocationBarViewMac::CanAnimateSecurityLevel(
907 security_state::SecurityLevel level) const { 911 security_state::SecurityLevel level) const {
908 return security_level_ == security_state::SecurityLevel::DANGEROUS || 912 return !GetOmniboxView()->IsEditingOrEmpty() &&
909 security_level_ == security_state::SecurityLevel::HTTP_SHOW_WARNING; 913 (security_level_ == security_state::SecurityLevel::DANGEROUS ||
914 security_level_ == security_state::SecurityLevel::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
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 }
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