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

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

Issue 2378623007: [Material] Update Material Security Verbose Decoration Flag (Closed)
Patch Set: Comment nit Created 4 years, 2 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 save_credit_card_decoration_( 114 save_credit_card_decoration_(
115 new SaveCreditCardDecoration(command_updater)), 115 new SaveCreditCardDecoration(command_updater)),
116 star_decoration_(new StarDecoration(command_updater)), 116 star_decoration_(new StarDecoration(command_updater)),
117 translate_decoration_(new TranslateDecoration(command_updater)), 117 translate_decoration_(new TranslateDecoration(command_updater)),
118 zoom_decoration_(new ZoomDecoration(this)), 118 zoom_decoration_(new ZoomDecoration(this)),
119 keyword_hint_decoration_(new KeywordHintDecoration()), 119 keyword_hint_decoration_(new KeywordHintDecoration()),
120 manage_passwords_decoration_( 120 manage_passwords_decoration_(
121 new ManagePasswordsDecoration(command_updater, this)), 121 new ManagePasswordsDecoration(command_updater, this)),
122 browser_(browser), 122 browser_(browser),
123 location_bar_visible_(true), 123 location_bar_visible_(true),
124 should_show_secure_verbose_(false), 124 should_show_secure_verbose_(true),
125 should_animate_security_verbose_(false), 125 should_animate_secure_verbose_(false),
126 should_animate_nonsecure_verbose_(false),
126 is_width_available_for_security_verbose_(false), 127 is_width_available_for_security_verbose_(false),
127 weak_ptr_factory_(this) { 128 weak_ptr_factory_(this) {
128 ScopedVector<ContentSettingImageModel> models = 129 ScopedVector<ContentSettingImageModel> models =
129 ContentSettingImageModel::GenerateContentSettingImageModels(); 130 ContentSettingImageModel::GenerateContentSettingImageModels();
130 for (ContentSettingImageModel* model : models.get()) { 131 for (ContentSettingImageModel* model : models.get()) {
131 // ContentSettingDecoration takes ownership of its model. 132 // ContentSettingDecoration takes ownership of its model.
132 content_setting_decorations_.push_back( 133 content_setting_decorations_.push_back(
133 new ContentSettingDecoration(model, this, profile)); 134 new ContentSettingDecoration(model, this, profile));
134 } 135 }
135 models.weak_clear(); 136 models.weak_clear();
136 137
137 edit_bookmarks_enabled_.Init( 138 edit_bookmarks_enabled_.Init(
138 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 139 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
139 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, 140 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged,
140 base::Unretained(this))); 141 base::Unretained(this)));
141 142
142 zoom::ZoomEventManager::GetForBrowserContext(profile) 143 zoom::ZoomEventManager::GetForBrowserContext(profile)
143 ->AddZoomEventManagerObserver(this); 144 ->AddZoomEventManagerObserver(this);
144 145
145 [[field_ cell] setIsPopupMode: 146 [[field_ cell] setIsPopupMode:
146 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; 147 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)];
147 148
148 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
149 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { 150 if (command_line->HasSwitch(switches::kSecurityChip)) {
150 std::string security_verbose_flag = 151 std::string security_chip_flag =
151 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); 152 command_line->GetSwitchValueASCII(switches::kSecurityChip);
153 should_show_secure_verbose_ =
154 security_chip_flag == switches::kSecurityChipShowAll;
155 }
152 156
153 should_show_secure_verbose_ = 157 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) {
154 security_verbose_flag == 158 std::string security_chip_animation_flag =
155 switches::kMaterialSecurityVerboseShowAllAnimated || 159 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation);
156 security_verbose_flag == 160 should_animate_secure_verbose_ =
157 switches::kMaterialSecurityVerboseShowAllNonAnimated; 161 security_chip_animation_flag == switches::kSecurityChipAnimationAll;
158 162
159 should_animate_security_verbose_ = 163 should_animate_nonsecure_verbose_ =
160 security_verbose_flag == 164 security_chip_animation_flag ==
161 switches::kMaterialSecurityVerboseShowAllAnimated || 165 switches::kSecurityChipAnimationNonSecureOnly ||
162 security_verbose_flag == 166 security_chip_animation_flag == switches::kSecurityChipAnimationAll;
163 switches::kMaterialSecurityVerboseShowNonSecureAnimated;
164 } 167 }
165 168
166 // Sets images for the decorations, and performs a layout. This call ensures 169 // Sets images for the decorations, and performs a layout. This call ensures
167 // that this class is in a consistent state after initialization. 170 // that this class is in a consistent state after initialization.
168 OnChanged(); 171 OnChanged();
169 } 172 }
170 173
171 LocationBarViewMac::~LocationBarViewMac() { 174 LocationBarViewMac::~LocationBarViewMac() {
172 // Disconnect from cell in case it outlives us. 175 // Disconnect from cell in case it outlives us.
173 [[field_ cell] clearDecorations]; 176 [[field_ cell] clearDecorations];
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 866 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
864 IsLocationBarDark()); 867 IsLocationBarDark());
865 } 868 }
866 869
867 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { 870 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) {
868 if (!ShouldShowSecurityState()) 871 if (!ShouldShowSecurityState())
869 return; 872 return;
870 873
871 security_state::SecurityStateModel::SecurityLevel new_security_level = 874 security_state::SecurityStateModel::SecurityLevel new_security_level =
872 GetToolbarModel()->GetSecurityLevel(false); 875 GetToolbarModel()->GetSecurityLevel(false);
873 bool is_secure_to_secure = IsSecureConnection(new_security_level) && 876 bool is_new_level_secure = IsSecureConnection(new_security_level);
874 IsSecureConnection(security_level_); 877 bool is_secure_to_secure =
878 is_new_level_secure && IsSecureConnection(security_level_);
875 bool is_new_security_level = 879 bool is_new_security_level =
876 security_level_ != new_security_level && !is_secure_to_secure; 880 security_level_ != new_security_level && !is_secure_to_secure;
877 security_level_ = new_security_level; 881 security_level_ = new_security_level;
878 882
879 // If there's enough space, but the secure state decoration had animated 883 // If there's enough space, but the secure state decoration had animated
880 // out, animate it back in. Otherwise, if the security state has changed, 884 // out, animate it back in. Otherwise, if the security state has changed,
881 // animate the decoration if animation is enabled and the state changed is 885 // animate the decoration if animation is enabled and the state changed is
882 // not from a tab switch. 886 // not from a tab switch.
883 if (is_width_available_for_security_verbose_) { 887 if (is_width_available_for_security_verbose_) {
888 bool is_animated =
889 (is_new_level_secure && should_animate_secure_verbose_) ||
890 (!is_new_level_secure && should_animate_nonsecure_verbose_);
891
884 if (security_state_bubble_decoration_->HasAnimatedOut()) 892 if (security_state_bubble_decoration_->HasAnimatedOut())
885 security_state_bubble_decoration_->AnimateIn(false); 893 security_state_bubble_decoration_->AnimateIn(false);
886 else if (!should_animate_security_verbose_ || tab_changed) 894 else if (tab_changed || !is_animated)
887 security_state_bubble_decoration_->ShowWithoutAnimation(); 895 security_state_bubble_decoration_->ShowWithoutAnimation();
888 else if (is_new_security_level) 896 else if (is_new_security_level)
889 security_state_bubble_decoration_->AnimateIn(); 897 security_state_bubble_decoration_->AnimateIn();
890 } else { 898 } else {
891 // Animate the decoration out if there's not enough space. 899 // Animate the decoration out if there's not enough space.
892 security_state_bubble_decoration_->AnimateOut(); 900 security_state_bubble_decoration_->AnimateOut();
893 } 901 }
894 } 902 }
895 903
896 bool LocationBarViewMac::IsSecureConnection( 904 bool LocationBarViewMac::IsSecureConnection(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 OnDecorationsChanged(); 937 OnDecorationsChanged();
930 } 938 }
931 939
932 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 940 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
933 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 941 std::vector<LocationBarDecoration*> decorations = GetDecorations();
934 std::vector<NSView*> views; 942 std::vector<NSView*> views;
935 for (auto* decoration : decorations) 943 for (auto* decoration : decorations)
936 views.push_back(decoration->GetAccessibilityView()); 944 views.push_back(decoration->GetAccessibilityView());
937 return views; 945 return views;
938 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698