Chromium Code Reviews| 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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 save_credit_card_decoration_( | 116 save_credit_card_decoration_( |
| 117 new SaveCreditCardDecoration(command_updater)), | 117 new SaveCreditCardDecoration(command_updater)), |
| 118 star_decoration_(new StarDecoration(command_updater)), | 118 star_decoration_(new StarDecoration(command_updater)), |
| 119 translate_decoration_(new TranslateDecoration(command_updater)), | 119 translate_decoration_(new TranslateDecoration(command_updater)), |
| 120 zoom_decoration_(new ZoomDecoration(this)), | 120 zoom_decoration_(new ZoomDecoration(this)), |
| 121 keyword_hint_decoration_(new KeywordHintDecoration()), | 121 keyword_hint_decoration_(new KeywordHintDecoration()), |
| 122 manage_passwords_decoration_( | 122 manage_passwords_decoration_( |
| 123 new ManagePasswordsDecoration(command_updater, this)), | 123 new ManagePasswordsDecoration(command_updater, this)), |
| 124 browser_(browser), | 124 browser_(browser), |
| 125 location_bar_visible_(true), | 125 location_bar_visible_(true), |
| 126 should_show_secure_verbose_(false), | |
| 127 should_show_nonsecure_verbose_(false), | |
| 128 should_animate_secure_verbose_(false), | |
| 129 should_animate_nonsecure_verbose_(false), | |
| 130 is_width_available_for_security_verbose_(false), | 126 is_width_available_for_security_verbose_(false), |
| 131 security_level_(security_state::NONE), | 127 security_level_(security_state::NONE), |
| 132 weak_ptr_factory_(this) { | 128 weak_ptr_factory_(this) { |
| 133 ScopedVector<ContentSettingImageModel> models = | 129 ScopedVector<ContentSettingImageModel> models = |
| 134 ContentSettingImageModel::GenerateContentSettingImageModels(); | 130 ContentSettingImageModel::GenerateContentSettingImageModels(); |
| 135 for (ContentSettingImageModel* model : models.get()) { | 131 for (ContentSettingImageModel* model : models.get()) { |
| 136 // ContentSettingDecoration takes ownership of its model. | 132 // ContentSettingDecoration takes ownership of its model. |
| 137 content_setting_decorations_.push_back( | 133 content_setting_decorations_.push_back( |
| 138 new ContentSettingDecoration(model, this, profile)); | 134 new ContentSettingDecoration(model, this, profile)); |
| 139 } | 135 } |
| 140 models.weak_clear(); | 136 models.weak_clear(); |
| 141 | 137 |
| 142 edit_bookmarks_enabled_.Init( | 138 edit_bookmarks_enabled_.Init( |
| 143 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 139 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 144 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, | 140 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, |
| 145 base::Unretained(this))); | 141 base::Unretained(this))); |
| 146 | 142 |
| 147 zoom::ZoomEventManager::GetForBrowserContext(profile) | 143 zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 148 ->AddZoomEventManagerObserver(this); | 144 ->AddZoomEventManagerObserver(this); |
| 149 | 145 |
| 150 [[field_ cell] setIsPopupMode: | 146 [[field_ cell] setIsPopupMode: |
| 151 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; | 147 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; |
| 152 | 148 |
| 153 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 154 std::string security_chip; | |
| 155 if (command_line->HasSwitch(switches::kSecurityChip)) { | |
| 156 security_chip = command_line->GetSwitchValueASCII(switches::kSecurityChip); | |
| 157 } else if (base::FeatureList::IsEnabled(features::kSecurityChip)) { | |
| 158 security_chip = variations::GetVariationParamValueByFeature( | |
| 159 features::kSecurityChip, kSecurityChipFeatureVisibilityParam); | |
| 160 } | |
| 161 | |
| 162 if (security_chip == switches::kSecurityChipShowNonSecureOnly) { | |
| 163 should_show_nonsecure_verbose_ = true; | |
| 164 } else if (security_chip == switches::kSecurityChipShowAll) { | |
| 165 should_show_secure_verbose_ = true; | |
| 166 should_show_nonsecure_verbose_ = true; | |
| 167 } | |
| 168 | |
| 169 std::string security_chip_animation; | |
| 170 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { | |
| 171 security_chip_animation = | |
| 172 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); | |
| 173 } else if (base::FeatureList::IsEnabled(features::kSecurityChip)) { | |
| 174 security_chip_animation = variations::GetVariationParamValueByFeature( | |
| 175 features::kSecurityChip, kSecurityChipFeatureAnimationParam); | |
| 176 } | |
| 177 | |
| 178 if (security_chip_animation == | |
| 179 switches::kSecurityChipAnimationNonSecureOnly) { | |
| 180 should_animate_nonsecure_verbose_ = true; | |
| 181 } else if (security_chip_animation == switches::kSecurityChipAnimationAll) { | |
| 182 should_animate_secure_verbose_ = true; | |
| 183 should_animate_nonsecure_verbose_ = true; | |
| 184 } | |
| 185 | |
| 186 // Sets images for the decorations, and performs a layout. This call ensures | 149 // Sets images for the decorations, and performs a layout. This call ensures |
| 187 // that this class is in a consistent state after initialization. | 150 // that this class is in a consistent state after initialization. |
| 188 OnChanged(); | 151 OnChanged(); |
| 189 } | 152 } |
| 190 | 153 |
| 191 LocationBarViewMac::~LocationBarViewMac() { | 154 LocationBarViewMac::~LocationBarViewMac() { |
| 192 // Disconnect from cell in case it outlives us. | 155 // Disconnect from cell in case it outlives us. |
| 193 [[field_ cell] clearDecorations]; | 156 [[field_ cell] clearDecorations]; |
| 194 | 157 |
| 195 zoom::ZoomEventManager::GetForBrowserContext(profile()) | 158 zoom::ZoomEventManager::GetForBrowserContext(profile()) |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 | 657 |
| 695 bool LocationBarViewMac::ShouldShowSecurityState() const { | 658 bool LocationBarViewMac::ShouldShowSecurityState() const { |
| 696 if (omnibox_view_->IsEditingOrEmpty() || | 659 if (omnibox_view_->IsEditingOrEmpty() || |
| 697 omnibox_view_->model()->is_keyword_hint()) { | 660 omnibox_view_->model()->is_keyword_hint()) { |
| 698 return false; | 661 return false; |
| 699 } | 662 } |
| 700 | 663 |
| 701 security_state::SecurityLevel security = | 664 security_state::SecurityLevel security = |
| 702 GetToolbarModel()->GetSecurityLevel(false); | 665 GetToolbarModel()->GetSecurityLevel(false); |
| 703 | 666 |
| 704 if (security == security_state::EV_SECURE) | 667 return (security == security_state::EV_SECURE || |
|
spqchan
2016/12/09 22:46:50
Nit: Don't think we need the round brackets
estark
2016/12/09 22:56:25
Done.
| |
| 705 return true; | 668 security == security_state::SECURE || |
| 706 else if (security == security_state::SECURE) | 669 security == security_state::DANGEROUS || |
| 707 return should_show_secure_verbose_; | |
| 708 | |
| 709 return should_show_nonsecure_verbose_ && | |
| 710 (security == security_state::DANGEROUS || | |
| 711 security == security_state::HTTP_SHOW_WARNING); | 670 security == security_state::HTTP_SHOW_WARNING); |
| 712 } | 671 } |
| 713 | 672 |
| 714 bool LocationBarViewMac::IsLocationBarDark() const { | 673 bool LocationBarViewMac::IsLocationBarDark() const { |
| 715 return [[field_ window] inIncognitoModeWithSystemTheme]; | 674 return [[field_ window] inIncognitoModeWithSystemTheme]; |
| 716 } | 675 } |
| 717 | 676 |
| 718 LocationBarDecoration* LocationBarViewMac::GetPageInfoDecoration() const { | 677 LocationBarDecoration* LocationBarViewMac::GetPageInfoDecoration() const { |
| 719 if (security_state_bubble_decoration_->IsVisible()) | 678 if (security_state_bubble_decoration_->IsVisible()) |
| 720 return security_state_bubble_decoration_.get(); | 679 return security_state_bubble_decoration_.get(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 CanAnimateSecurityLevel(security_level_)) { | 878 CanAnimateSecurityLevel(security_level_)) { |
| 920 security_state_bubble_decoration_->AnimateOut(); | 879 security_state_bubble_decoration_->AnimateOut(); |
| 921 } | 880 } |
| 922 | 881 |
| 923 security_level_ = new_security_level; | 882 security_level_ = new_security_level; |
| 924 } | 883 } |
| 925 | 884 |
| 926 bool LocationBarViewMac::CanAnimateSecurityLevel( | 885 bool LocationBarViewMac::CanAnimateSecurityLevel( |
| 927 security_state::SecurityLevel level) const { | 886 security_state::SecurityLevel level) const { |
| 928 using SecurityLevel = security_state::SecurityLevel; | 887 using SecurityLevel = security_state::SecurityLevel; |
| 929 if (IsSecureConnection(level)) { | 888 return (IsSecureConnection(level) || |
|
spqchan
2016/12/09 22:46:50
Are we animating all? I thought the plan was to an
estark
2016/12/09 22:56:25
Hrm, where's that plan from? The server-side Finch
spqchan
2016/12/09 23:04:21
I remember hearing it from emilyschechter@ that we
| |
| 930 return should_animate_secure_verbose_; | 889 security_level_ == SecurityLevel::DANGEROUS || |
| 931 } else if (security_level_ == SecurityLevel::DANGEROUS || | 890 security_level_ == SecurityLevel::HTTP_SHOW_WARNING); |
| 932 security_level_ == SecurityLevel::HTTP_SHOW_WARNING) { | |
| 933 return should_animate_nonsecure_verbose_; | |
| 934 } else { | |
| 935 return false; | |
| 936 } | |
| 937 } | 891 } |
| 938 | 892 |
| 939 bool LocationBarViewMac::IsSecureConnection( | 893 bool LocationBarViewMac::IsSecureConnection( |
| 940 security_state::SecurityLevel level) const { | 894 security_state::SecurityLevel level) const { |
| 941 return level == security_state::SECURE || | 895 return level == security_state::SECURE || |
| 942 level == security_state::EV_SECURE; | 896 level == security_state::EV_SECURE; |
| 943 } | 897 } |
| 944 | 898 |
| 945 void LocationBarViewMac::UpdateAccessibilityViewPosition( | 899 void LocationBarViewMac::UpdateAccessibilityViewPosition( |
| 946 LocationBarDecoration* decoration) { | 900 LocationBarDecoration* decoration) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 972 OnDecorationsChanged(); | 926 OnDecorationsChanged(); |
| 973 } | 927 } |
| 974 | 928 |
| 975 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 929 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 976 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 930 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 977 std::vector<NSView*> views; | 931 std::vector<NSView*> views; |
| 978 for (auto* decoration : decorations) | 932 for (auto* decoration : decorations) |
| 979 views.push_back(decoration->GetAccessibilityView()); | 933 views.push_back(decoration->GetAccessibilityView()); |
| 980 return views; | 934 return views; |
| 981 } | 935 } |
| OLD | NEW |