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

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: removed extra line and fixed histogram.xml 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_(true), 124 should_show_secure_verbose_(true),
125 should_animate_security_verbose_(true), 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 868 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
866 IsLocationBarDark()); 869 IsLocationBarDark());
867 } 870 }
868 871
869 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { 872 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) {
870 if (!ShouldShowSecurityState()) 873 if (!ShouldShowSecurityState())
871 return; 874 return;
872 875
873 security_state::SecurityStateModel::SecurityLevel new_security_level = 876 security_state::SecurityStateModel::SecurityLevel new_security_level =
874 GetToolbarModel()->GetSecurityLevel(false); 877 GetToolbarModel()->GetSecurityLevel(false);
875 bool is_secure_to_secure = IsSecureConnection(new_security_level) && 878 bool is_new_level_secure = IsSecureConnection(new_security_level);
876 IsSecureConnection(security_level_); 879 bool is_secure_to_secure =
880 is_new_level_secure && IsSecureConnection(security_level_);
877 bool is_new_security_level = 881 bool is_new_security_level =
878 security_level_ != new_security_level && !is_secure_to_secure; 882 security_level_ != new_security_level && !is_secure_to_secure;
879 security_level_ = new_security_level; 883 security_level_ = new_security_level;
880 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 (is_width_available_for_security_verbose_) { 889 if (is_width_available_for_security_verbose_) {
890 bool is_animated =
891 (is_new_level_secure && should_animate_secure_verbose_) ||
892 (!is_new_level_secure && should_animate_nonsecure_verbose_);
893
886 if (security_state_bubble_decoration_->HasAnimatedOut()) 894 if (security_state_bubble_decoration_->HasAnimatedOut())
887 security_state_bubble_decoration_->AnimateIn(false); 895 security_state_bubble_decoration_->AnimateIn(false);
888 else if (!should_animate_security_verbose_ || tab_changed) 896 else if (tab_changed || !is_animated)
889 security_state_bubble_decoration_->ShowWithoutAnimation(); 897 security_state_bubble_decoration_->ShowWithoutAnimation();
890 else if (is_new_security_level) 898 else if (is_new_security_level)
891 security_state_bubble_decoration_->AnimateIn(); 899 security_state_bubble_decoration_->AnimateIn();
892 } else { 900 } else {
893 // Animate the decoration out if there's not enough space. 901 // Animate the decoration out if there's not enough space.
894 security_state_bubble_decoration_->AnimateOut(); 902 security_state_bubble_decoration_->AnimateOut();
895 } 903 }
896 } 904 }
897 905
898 bool LocationBarViewMac::IsSecureConnection( 906 bool LocationBarViewMac::IsSecureConnection(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 OnDecorationsChanged(); 939 OnDecorationsChanged();
932 } 940 }
933 941
934 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 942 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
935 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 943 std::vector<LocationBarDecoration*> decorations = GetDecorations();
936 std::vector<NSView*> views; 944 std::vector<NSView*> views;
937 for (auto* decoration : decorations) 945 for (auto* decoration : decorations)
938 views.push_back(decoration->GetAccessibilityView()); 946 views.push_back(decoration->GetAccessibilityView());
939 return views; 947 return views;
940 } 948 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698