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

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

Issue 2501753002: [Mac] Changes for the security chip (Closed)
Patch Set: Created 4 years, 1 month 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 | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | 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/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword); 525 keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword);
526 keyword_hint_decoration_->SetVisible(true); 526 keyword_hint_decoration_->SetVisible(true);
527 } else if (ShouldShowEVBubble()) { 527 } else if (ShouldShowEVBubble()) {
528 // Switch from location icon to show the EV bubble instead. 528 // Switch from location icon to show the EV bubble instead.
529 location_icon_decoration_->SetVisible(false); 529 location_icon_decoration_->SetVisible(false);
530 security_state_bubble_decoration_->SetVisible(true); 530 security_state_bubble_decoration_->SetVisible(true);
531 531
532 base::string16 label(GetToolbarModel()->GetEVCertName()); 532 base::string16 label(GetToolbarModel()->GetEVCertName());
533 security_state_bubble_decoration_->SetFullLabel( 533 security_state_bubble_decoration_->SetFullLabel(
534 base::SysUTF16ToNSString(label)); 534 base::SysUTF16ToNSString(label));
535 } else if (ShouldShowSecurityState()) { 535 } else if (ShouldShowSecurityState() ||
536 security_state_bubble_decoration_->AnimatingOut()) {
536 bool is_security_state_visible = 537 bool is_security_state_visible =
537 is_width_available_for_security_verbose_ || 538 is_width_available_for_security_verbose_ ||
538 security_state_bubble_decoration_->AnimatingOut(); 539 security_state_bubble_decoration_->AnimatingOut();
539 location_icon_decoration_->SetVisible(!is_security_state_visible); 540 location_icon_decoration_->SetVisible(!is_security_state_visible);
540 security_state_bubble_decoration_->SetVisible(is_security_state_visible); 541 security_state_bubble_decoration_->SetVisible(is_security_state_visible);
541 542
542 // Don't change the label if the bubble is in the process of animating 543 // Don't change the label if the bubble is in the process of animating
543 // out the old one. 544 // out the old one.
544 base::string16 label(GetToolbarModel()->GetSecureVerboseText()); 545 base::string16 label(GetToolbarModel()->GetSecureVerboseText());
545 if (!security_state_bubble_decoration_->AnimatingOut()) { 546 if (!security_state_bubble_decoration_->AnimatingOut()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 void LocationBarViewMac::ResetTabState(WebContents* contents) { 617 void LocationBarViewMac::ResetTabState(WebContents* contents) {
617 omnibox_view_->ResetTabState(contents); 618 omnibox_view_->ResetTabState(contents);
618 } 619 }
619 620
620 void LocationBarViewMac::Update(const WebContents* contents) { 621 void LocationBarViewMac::Update(const WebContents* contents) {
621 UpdateManagePasswordsIconAndBubble(); 622 UpdateManagePasswordsIconAndBubble();
622 UpdateBookmarkStarVisibility(); 623 UpdateBookmarkStarVisibility();
623 UpdateSaveCreditCardIcon(); 624 UpdateSaveCreditCardIcon();
624 UpdateTranslateDecoration(); 625 UpdateTranslateDecoration();
625 UpdateZoomDecoration(/*default_zoom_changed=*/false); 626 UpdateZoomDecoration(/*default_zoom_changed=*/false);
626 UpdateSecurityState(contents);
627 RefreshPageActionDecorations(); 627 RefreshPageActionDecorations();
628 RefreshContentSettingsDecorations(); 628 RefreshContentSettingsDecorations();
629 if (contents) 629 if (contents) {
630 omnibox_view_->OnTabChanged(contents); 630 omnibox_view_->OnTabChanged(contents);
631 else 631 UpdateSecurityState(contents);
632 } else {
632 omnibox_view_->Update(); 633 omnibox_view_->Update();
634 }
633 635
634 OnChanged(); 636 OnChanged();
635 } 637 }
636 638
637 void LocationBarViewMac::UpdateWithoutTabRestore() { 639 void LocationBarViewMac::UpdateWithoutTabRestore() {
638 Update(nullptr); 640 Update(nullptr);
639 } 641 }
640 642
641 void LocationBarViewMac::UpdateLocationIcon() { 643 void LocationBarViewMac::UpdateLocationIcon() {
642 SkColor vector_icon_color = GetLocationBarIconColor(); 644 SkColor vector_icon_color = GetLocationBarIconColor();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 WebContents* web_contents = GetWebContents(); 893 WebContents* web_contents = GetWebContents();
892 if (!web_contents) 894 if (!web_contents)
893 return false; 895 return false;
894 896
895 return zoom_decoration_->UpdateIfNecessary( 897 return zoom_decoration_->UpdateIfNecessary(
896 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 898 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
897 IsLocationBarDark()); 899 IsLocationBarDark());
898 } 900 }
899 901
900 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { 902 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) {
901 if (!ShouldShowSecurityState()) 903 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
902 return; 904 SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false);
903
904 security_state::SecurityStateModel::SecurityLevel new_security_level =
905 GetToolbarModel()->GetSecurityLevel(false);
906 bool is_new_level_secure = IsSecureConnection(new_security_level);
907 bool is_secure_to_secure =
908 is_new_level_secure && IsSecureConnection(security_level_);
909 bool is_new_security_level =
910 security_level_ != new_security_level && !is_secure_to_secure;
911 security_level_ = new_security_level;
912 905
913 // If there's enough space, but the secure state decoration had animated 906 // If there's enough space, but the secure state decoration had animated
914 // out, animate it back in. Otherwise, if the security state has changed, 907 // out, animate it back in. Otherwise, if the security state has changed,
915 // animate the decoration if animation is enabled and the state changed is 908 // animate the decoration if animation is enabled and the state changed is
916 // not from a tab switch. 909 // not from a tab switch.
917 if (is_width_available_for_security_verbose_) { 910 if (ShouldShowSecurityState() && is_width_available_for_security_verbose_) {
918 bool is_animated = 911 bool is_secure_to_secure = IsSecureConnection(new_security_level) &&
919 (is_new_level_secure && should_animate_secure_verbose_) || 912 IsSecureConnection(security_level_);
920 (!is_new_level_secure && should_animate_nonsecure_verbose_); 913 bool is_new_security_level =
921 914 security_level_ != new_security_level && !is_secure_to_secure;
922 if (!tab_changed && security_state_bubble_decoration_->HasAnimatedOut()) 915 if (!tab_changed && security_state_bubble_decoration_->HasAnimatedOut())
923 security_state_bubble_decoration_->AnimateIn(false); 916 security_state_bubble_decoration_->AnimateIn(false);
924 else if (tab_changed || !is_animated) 917 else if (tab_changed || !CanAnimateSecurityLevel(new_security_level))
925 security_state_bubble_decoration_->ShowWithoutAnimation(); 918 security_state_bubble_decoration_->ShowWithoutAnimation();
926 else if (is_new_security_level) 919 else if (is_new_security_level)
927 security_state_bubble_decoration_->AnimateIn(); 920 security_state_bubble_decoration_->AnimateIn();
921 } else if (!is_width_available_for_security_verbose_ ||
922 CanAnimateSecurityLevel(security_level_)) {
923 security_state_bubble_decoration_->AnimateOut();
924 }
925
926 security_level_ = new_security_level;
927 }
928
929 bool LocationBarViewMac::CanAnimateSecurityLevel(
930 security_state::SecurityStateModel::SecurityLevel level) const {
931 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
932 if (IsSecureConnection(level)) {
933 return should_animate_secure_verbose_;
934 } else if (security_level_ == SecurityLevel::DANGEROUS ||
935 security_level_ == SecurityLevel::HTTP_SHOW_WARNING) {
936 return should_animate_nonsecure_verbose_;
928 } else { 937 } else {
929 // Animate the decoration out if there's not enough space. 938 return false;
930 security_state_bubble_decoration_->AnimateOut();
931 } 939 }
932 } 940 }
933 941
934 bool LocationBarViewMac::IsSecureConnection( 942 bool LocationBarViewMac::IsSecureConnection(
935 security_state::SecurityStateModel::SecurityLevel level) const { 943 security_state::SecurityStateModel::SecurityLevel level) const {
936 return level == security_state::SecurityStateModel::SECURE || 944 return level == security_state::SecurityStateModel::SECURE ||
937 level == security_state::SecurityStateModel::EV_SECURE; 945 level == security_state::SecurityStateModel::EV_SECURE;
938 } 946 }
939 947
940 void LocationBarViewMac::UpdateAccessibilityViewPosition( 948 void LocationBarViewMac::UpdateAccessibilityViewPosition(
(...skipping 26 matching lines...) Expand all
967 OnDecorationsChanged(); 975 OnDecorationsChanged();
968 } 976 }
969 977
970 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 978 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
971 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 979 std::vector<LocationBarDecoration*> decorations = GetDecorations();
972 std::vector<NSView*> views; 980 std::vector<NSView*> views;
973 for (auto* decoration : decorations) 981 for (auto* decoration : decorations)
974 views.push_back(decoration->GetAccessibilityView()); 982 views.push_back(decoration->GetAccessibilityView());
975 return views; 983 return views;
976 } 984 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698