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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 2560203003: Remove SecurityChips experiment and flags (Closed)
Patch Set: pkasting comments Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h"
11 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
12 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 13 #include "build/build_config.h"
15 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/command_updater.h" 15 #include "chrome/browser/command_updater.h"
17 #include "chrome/browser/defaults.h" 16 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
19 #include "chrome/browser/extensions/extension_action.h" 18 #include "chrome/browser/extensions/extension_action.h"
20 #include "chrome/browser/extensions/extension_action_manager.h" 19 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 24 matching lines...) Expand all
45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 44 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
46 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 45 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
47 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 46 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
48 #include "chrome/browser/ui/views/location_bar/star_view.h" 47 #include "chrome/browser/ui/views/location_bar/star_view.h"
49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 48 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
50 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 49 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 50 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" 51 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 52 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
54 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 53 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
55 #include "chrome/common/chrome_features.h"
56 #include "chrome/common/chrome_switches.h"
57 #include "chrome/grit/generated_resources.h" 54 #include "chrome/grit/generated_resources.h"
58 #include "chrome/grit/theme_resources.h" 55 #include "chrome/grit/theme_resources.h"
59 #include "components/bookmarks/common/bookmark_pref_names.h" 56 #include "components/bookmarks/common/bookmark_pref_names.h"
60 #include "components/favicon/content/content_favicon_driver.h" 57 #include "components/favicon/content/content_favicon_driver.h"
61 #include "components/grit/components_scaled_resources.h" 58 #include "components/grit/components_scaled_resources.h"
62 #include "components/omnibox/browser/omnibox_popup_model.h" 59 #include "components/omnibox/browser/omnibox_popup_model.h"
63 #include "components/omnibox/browser/omnibox_popup_view.h" 60 #include "components/omnibox/browser/omnibox_popup_view.h"
64 #include "components/prefs/pref_service.h" 61 #include "components/prefs/pref_service.h"
65 #include "components/search_engines/template_url.h" 62 #include "components/search_engines/template_url.h"
66 #include "components/search_engines/template_url_service.h" 63 #include "components/search_engines/template_url_service.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 zoom_view_(nullptr), 130 zoom_view_(nullptr),
134 open_pdf_in_reader_view_(nullptr), 131 open_pdf_in_reader_view_(nullptr),
135 manage_passwords_icon_view_(nullptr), 132 manage_passwords_icon_view_(nullptr),
136 save_credit_card_icon_view_(nullptr), 133 save_credit_card_icon_view_(nullptr),
137 translate_icon_view_(nullptr), 134 translate_icon_view_(nullptr),
138 star_view_(nullptr), 135 star_view_(nullptr),
139 size_animation_(this), 136 size_animation_(this),
140 is_popup_mode_(is_popup_mode), 137 is_popup_mode_(is_popup_mode),
141 show_focus_rect_(false), 138 show_focus_rect_(false),
142 template_url_service_(NULL), 139 template_url_service_(NULL),
143 web_contents_null_at_last_refresh_(true), 140 web_contents_null_at_last_refresh_(true) {
144 should_show_secure_state_(false),
145 should_show_nonsecure_state_(false),
146 should_animate_secure_state_(false),
147 should_animate_nonsecure_state_(false) {
148 edit_bookmarks_enabled_.Init( 141 edit_bookmarks_enabled_.Init(
149 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 142 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
150 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 143 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
151 base::Unretained(this))); 144 base::Unretained(this)));
152 145
153 zoom::ZoomEventManager::GetForBrowserContext(profile) 146 zoom::ZoomEventManager::GetForBrowserContext(profile)
154 ->AddZoomEventManagerObserver(this); 147 ->AddZoomEventManagerObserver(this);
155
156 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
157 std::string security_chip_visibility;
158 if (command_line->HasSwitch(switches::kSecurityChip)) {
159 security_chip_visibility =
160 command_line->GetSwitchValueASCII(switches::kSecurityChip);
161 } else if (base::FeatureList::IsEnabled(features::kSecurityChip)) {
162 security_chip_visibility =
163 variations::GetVariationParamValueByFeature(
164 features::kSecurityChip, kSecurityChipFeatureVisibilityParam);
165 }
166
167 should_show_secure_state_ =
168 security_chip_visibility == switches::kSecurityChipShowAll;
169 should_show_nonsecure_state_ =
170 should_show_secure_state_ ||
171 security_chip_visibility == switches::kSecurityChipShowNonSecureOnly;
172
173 std::string security_chip_animation;
174 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) {
175 security_chip_animation =
176 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation);
177 } else if (base::FeatureList::IsEnabled(features::kSecurityChip)) {
178 security_chip_animation = variations::GetVariationParamValueByFeature(
179 features::kSecurityChip, kSecurityChipFeatureAnimationParam);
180 }
181
182 should_animate_secure_state_ =
183 security_chip_animation == switches::kSecurityChipAnimationAll;
184 should_animate_nonsecure_state_ =
185 should_animate_secure_state_ ||
186 security_chip_animation == switches::kSecurityChipAnimationNonSecureOnly;
187 } 148 }
188 149
189 LocationBarView::~LocationBarView() { 150 LocationBarView::~LocationBarView() {
190 if (template_url_service_) 151 if (template_url_service_)
191 template_url_service_->RemoveObserver(this); 152 template_url_service_->RemoveObserver(this);
192 153
193 zoom::ZoomEventManager::GetForBrowserContext(profile()) 154 zoom::ZoomEventManager::GetForBrowserContext(profile())
194 ->RemoveZoomEventManagerObserver(this); 155 ->RemoveZoomEventManagerObserver(this);
195 } 156 }
196 157
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 885 }
925 886
926 bool LocationBarView::ShouldShowKeywordBubble() const { 887 bool LocationBarView::ShouldShowKeywordBubble() const {
927 return !omnibox_view_->model()->keyword().empty() && 888 return !omnibox_view_->model()->keyword().empty() &&
928 !omnibox_view_->model()->is_keyword_hint(); 889 !omnibox_view_->model()->is_keyword_hint();
929 } 890 }
930 891
931 bool LocationBarView::ShouldShowSecurityChip() const { 892 bool LocationBarView::ShouldShowSecurityChip() const {
932 using SecurityLevel = security_state::SecurityLevel; 893 using SecurityLevel = security_state::SecurityLevel;
933 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 894 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
934 if (level == SecurityLevel::EV_SECURE) { 895 return level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE ||
935 return true; 896 level == SecurityLevel::DANGEROUS ||
936 } else if (level == SecurityLevel::SECURE) { 897 level == SecurityLevel::HTTP_SHOW_WARNING;
937 return should_show_secure_state_;
938 } else {
939 return should_show_nonsecure_state_ &&
940 (level == SecurityLevel::DANGEROUS ||
941 level == SecurityLevel::HTTP_SHOW_WARNING);
942 }
943 } 898 }
944 899
945 bool LocationBarView::ShouldAnimateSecurityChip() const { 900 bool LocationBarView::ShouldAnimateSecurityChip() const {
946 using SecurityLevel = security_state::SecurityLevel; 901 using SecurityLevel = security_state::SecurityLevel;
947 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 902 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
948 if (!ShouldShowSecurityChip()) 903 return level == SecurityLevel::DANGEROUS ||
949 return false; 904 level == SecurityLevel::HTTP_SHOW_WARNING;
950 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE)
951 return should_animate_secure_state_;
952 return should_animate_nonsecure_state_ &&
953 (level == SecurityLevel::DANGEROUS ||
954 level == SecurityLevel::HTTP_SHOW_WARNING);
955 } 905 }
956 906
957 //////////////////////////////////////////////////////////////////////////////// 907 ////////////////////////////////////////////////////////////////////////////////
958 // LocationBarView, private LocationBar implementation: 908 // LocationBarView, private LocationBar implementation:
959 909
960 void LocationBarView::ShowFirstRunBubble() { 910 void LocationBarView::ShowFirstRunBubble() {
961 // Wait until search engines have loaded to show the first run bubble. 911 // Wait until search engines have loaded to show the first run bubble.
962 TemplateURLService* url_service = 912 TemplateURLService* url_service =
963 TemplateURLServiceFactory::GetForProfile(profile()); 913 TemplateURLServiceFactory::GetForProfile(profile());
964 if (!url_service->loaded()) { 914 if (!url_service->loaded()) {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 // LocationBarView, private TemplateURLServiceObserver implementation: 1211 // LocationBarView, private TemplateURLServiceObserver implementation:
1262 1212
1263 void LocationBarView::OnTemplateURLServiceChanged() { 1213 void LocationBarView::OnTemplateURLServiceChanged() {
1264 template_url_service_->RemoveObserver(this); 1214 template_url_service_->RemoveObserver(this);
1265 template_url_service_ = nullptr; 1215 template_url_service_ = nullptr;
1266 // If the browser is no longer active, let's not show the info bubble, as this 1216 // If the browser is no longer active, let's not show the info bubble, as this
1267 // would make the browser the active window again. 1217 // would make the browser the active window again.
1268 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1218 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1269 ShowFirstRunBubble(); 1219 ShowFirstRunBubble();
1270 } 1220 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698