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

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: Rebased 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::kSecurityVerboseDecoration)) {
150 std::string security_verbose_flag = 151 std::string security_verbose_flag =
151 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); 152 command_line->GetSwitchValueASCII(switches::kSecurityVerboseDecoration);
152 153
153 should_show_secure_verbose_ = 154 should_show_secure_verbose_ =
154 security_verbose_flag == 155 security_verbose_flag ==
155 switches::kMaterialSecurityVerboseShowAllAnimated || 156 switches::kSecurityVerboseDecorationShowAllAnimated ||
156 security_verbose_flag == 157 security_verbose_flag ==
157 switches::kMaterialSecurityVerboseShowAllNonAnimated; 158 switches::kSecurityVerboseDecorationShowAllNonAnimated ||
159 security_verbose_flag ==
160 switches::
161 kSecurityVerboseDecorationShowAllWithOnlyNonSecureAnimated;
158 162
159 should_animate_security_verbose_ = 163 should_animate_secure_verbose_ =
160 security_verbose_flag == 164 security_verbose_flag ==
161 switches::kMaterialSecurityVerboseShowAllAnimated || 165 switches::kSecurityVerboseDecorationShowAllAnimated;
166
167 should_animate_nonsecure_verbose_ =
162 security_verbose_flag == 168 security_verbose_flag ==
163 switches::kMaterialSecurityVerboseShowNonSecureAnimated; 169 switches::kSecurityVerboseDecorationShowAllAnimated ||
170 security_verbose_flag ==
171 switches::kSecurityVerboseDecorationShowNonSecureAnimated ||
172 security_verbose_flag ==
173 switches::
174 kSecurityVerboseDecorationShowAllWithOnlyNonSecureAnimated;
164 } 175 }
165 176
166 // Sets images for the decorations, and performs a layout. This call ensures 177 // Sets images for the decorations, and performs a layout. This call ensures
167 // that this class is in a consistent state after initialization. 178 // that this class is in a consistent state after initialization.
168 OnChanged(); 179 OnChanged();
169 } 180 }
170 181
171 LocationBarViewMac::~LocationBarViewMac() { 182 LocationBarViewMac::~LocationBarViewMac() {
172 // Disconnect from cell in case it outlives us. 183 // Disconnect from cell in case it outlives us.
173 [[field_ cell] clearDecorations]; 184 [[field_ cell] clearDecorations];
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 874 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
864 IsLocationBarDark()); 875 IsLocationBarDark());
865 } 876 }
866 877
867 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) { 878 void LocationBarViewMac::UpdateSecurityState(bool tab_changed) {
868 if (!ShouldShowSecurityState()) 879 if (!ShouldShowSecurityState())
869 return; 880 return;
870 881
871 security_state::SecurityStateModel::SecurityLevel new_security_level = 882 security_state::SecurityStateModel::SecurityLevel new_security_level =
872 GetToolbarModel()->GetSecurityLevel(false); 883 GetToolbarModel()->GetSecurityLevel(false);
873 bool is_secure_to_secure = IsSecureConnection(new_security_level) && 884 bool is_new_level_secure = IsSecureConnection(new_security_level);
874 IsSecureConnection(security_level_); 885 bool is_secure_to_secure =
886 is_new_level_secure && IsSecureConnection(security_level_);
875 bool is_new_security_level = 887 bool is_new_security_level =
876 security_level_ != new_security_level && !is_secure_to_secure; 888 security_level_ != new_security_level && !is_secure_to_secure;
877 security_level_ = new_security_level; 889 security_level_ = new_security_level;
878 890
879 // If there's enough space, but the secure state decoration had animated 891 // 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, 892 // 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 893 // animate the decoration if animation is enabled and the state changed is
882 // not from a tab switch. 894 // not from a tab switch.
883 if (is_width_available_for_security_verbose_) { 895 if (is_width_available_for_security_verbose_) {
896 bool is_animated =
897 (is_new_level_secure && should_animate_secure_verbose_) ||
898 (!is_new_level_secure && should_animate_nonsecure_verbose_);
899
884 if (security_state_bubble_decoration_->HasAnimatedOut()) 900 if (security_state_bubble_decoration_->HasAnimatedOut())
885 security_state_bubble_decoration_->AnimateIn(false); 901 security_state_bubble_decoration_->AnimateIn(false);
886 else if (!should_animate_security_verbose_ || tab_changed) 902 else if (tab_changed || !is_animated)
887 security_state_bubble_decoration_->ShowWithoutAnimation(); 903 security_state_bubble_decoration_->ShowWithoutAnimation();
888 else if (is_new_security_level) 904 else if (is_new_security_level)
889 security_state_bubble_decoration_->AnimateIn(); 905 security_state_bubble_decoration_->AnimateIn();
890 } else { 906 } else {
891 // Animate the decoration out if there's not enough space. 907 // Animate the decoration out if there's not enough space.
892 security_state_bubble_decoration_->AnimateOut(); 908 security_state_bubble_decoration_->AnimateOut();
893 } 909 }
894 } 910 }
895 911
896 bool LocationBarViewMac::IsSecureConnection( 912 bool LocationBarViewMac::IsSecureConnection(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 OnDecorationsChanged(); 945 OnDecorationsChanged();
930 } 946 }
931 947
932 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 948 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
933 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 949 std::vector<LocationBarDecoration*> decorations = GetDecorations();
934 std::vector<NSView*> views; 950 std::vector<NSView*> views;
935 for (auto* decoration : decorations) 951 for (auto* decoration : decorations)
936 views.push_back(decoration->GetAccessibilityView()); 952 views.push_back(decoration->GetAccessibilityView());
937 return views; 953 return views;
938 } 954 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698