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

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

Issue 2491403002: Add a feature flag for the security verbose (Closed)
Patch Set: Fix compile issues Created 4 years, 1 month 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" 10 #include "base/command_line.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 45 #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" 46 #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" 47 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
48 #include "chrome/browser/ui/views/location_bar/star_view.h" 48 #include "chrome/browser/ui/views/location_bar/star_view.h"
49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
50 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 50 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" 52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
54 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 54 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
55 #include "chrome/common/chrome_features.h"
55 #include "chrome/common/chrome_switches.h" 56 #include "chrome/common/chrome_switches.h"
56 #include "chrome/grit/generated_resources.h" 57 #include "chrome/grit/generated_resources.h"
57 #include "chrome/grit/theme_resources.h" 58 #include "chrome/grit/theme_resources.h"
58 #include "components/bookmarks/common/bookmark_pref_names.h" 59 #include "components/bookmarks/common/bookmark_pref_names.h"
59 #include "components/favicon/content/content_favicon_driver.h" 60 #include "components/favicon/content/content_favicon_driver.h"
60 #include "components/grit/components_scaled_resources.h" 61 #include "components/grit/components_scaled_resources.h"
61 #include "components/omnibox/browser/omnibox_popup_model.h" 62 #include "components/omnibox/browser/omnibox_popup_model.h"
62 #include "components/omnibox/browser/omnibox_popup_view.h" 63 #include "components/omnibox/browser/omnibox_popup_view.h"
63 #include "components/prefs/pref_service.h" 64 #include "components/prefs/pref_service.h"
64 #include "components/search_engines/template_url.h" 65 #include "components/search_engines/template_url.h"
65 #include "components/search_engines/template_url_service.h" 66 #include "components/search_engines/template_url_service.h"
66 #include "components/toolbar/toolbar_model.h" 67 #include "components/toolbar/toolbar_model.h"
67 #include "components/translate/core/browser/language_state.h" 68 #include "components/translate/core/browser/language_state.h"
69 #include "components/variations/variations_associated_data.h"
68 #include "components/zoom/zoom_controller.h" 70 #include "components/zoom/zoom_controller.h"
69 #include "components/zoom/zoom_event_manager.h" 71 #include "components/zoom/zoom_event_manager.h"
70 #include "content/public/browser/render_widget_host_view.h" 72 #include "content/public/browser/render_widget_host_view.h"
71 #include "content/public/browser/web_contents.h" 73 #include "content/public/browser/web_contents.h"
72 #include "extensions/browser/extension_registry.h" 74 #include "extensions/browser/extension_registry.h"
73 #include "extensions/common/feature_switch.h" 75 #include "extensions/common/feature_switch.h"
74 #include "ui/accessibility/ax_view_state.h" 76 #include "ui/accessibility/ax_view_state.h"
75 #include "ui/base/dragdrop/drag_drop_types.h" 77 #include "ui/base/dragdrop/drag_drop_types.h"
76 #include "ui/base/resource/resource_bundle.h" 78 #include "ui/base/resource/resource_bundle.h"
77 #include "ui/base/theme_provider.h" 79 #include "ui/base/theme_provider.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 save_credit_card_icon_view_(nullptr), 137 save_credit_card_icon_view_(nullptr),
136 translate_icon_view_(nullptr), 138 translate_icon_view_(nullptr),
137 star_view_(nullptr), 139 star_view_(nullptr),
138 size_animation_(this), 140 size_animation_(this),
139 is_popup_mode_(is_popup_mode), 141 is_popup_mode_(is_popup_mode),
140 show_focus_rect_(false), 142 show_focus_rect_(false),
141 template_url_service_(NULL), 143 template_url_service_(NULL),
142 web_contents_null_at_last_refresh_(true), 144 web_contents_null_at_last_refresh_(true),
143 should_show_secure_state_(false), 145 should_show_secure_state_(false),
144 should_show_nonsecure_state_(false), 146 should_show_nonsecure_state_(false),
145 should_animate_secure_state_(false) { 147 should_animate_secure_state_(false),
148 should_animate_nonsecure_state_(false) {
146 edit_bookmarks_enabled_.Init( 149 edit_bookmarks_enabled_.Init(
147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 150 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
148 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 151 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
149 base::Unretained(this))); 152 base::Unretained(this)));
150 153
151 zoom::ZoomEventManager::GetForBrowserContext(profile) 154 zoom::ZoomEventManager::GetForBrowserContext(profile)
152 ->AddZoomEventManagerObserver(this); 155 ->AddZoomEventManagerObserver(this);
153 156
154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 157 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
155 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { 158 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) {
156 std::string security_verbose_flag = 159 std::string security_verbose_flag =
157 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); 160 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose);
158 should_show_nonsecure_state_ = true; 161 should_show_nonsecure_state_ = true;
159 should_show_secure_state_ = 162 should_show_secure_state_ =
160 security_verbose_flag == 163 security_verbose_flag ==
161 switches::kMaterialSecurityVerboseShowAllAnimated || 164 switches::kMaterialSecurityVerboseShowAllAnimated ||
162 security_verbose_flag == 165 security_verbose_flag ==
163 switches::kMaterialSecurityVerboseShowAllNonAnimated; 166 switches::kMaterialSecurityVerboseShowAllNonAnimated;
164 should_animate_secure_state_ = 167 should_animate_secure_state_ =
165 security_verbose_flag == 168 security_verbose_flag ==
166 switches::kMaterialSecurityVerboseShowAllAnimated || 169 switches::kMaterialSecurityVerboseShowAllAnimated ||
167 security_verbose_flag == 170 security_verbose_flag ==
168 switches::kMaterialSecurityVerboseShowNonSecureAnimated; 171 switches::kMaterialSecurityVerboseShowNonSecureAnimated;
172 should_animate_nonsecure_state_ = should_animate_secure_state_;
173 } else if (base::FeatureList::IsEnabled(features::kSecurityChip)) {
174 std::string security_chip_visibility =
175 variations::GetVariationParamValueByFeature(
176 features::kSecurityChip, kSecurityChipFeatureVisibilityParam);
177 should_show_secure_state_ =
178 security_chip_visibility == switches::kSecurityChipShowAll;
179 should_show_nonsecure_state_ =
180 should_show_secure_state_ ||
181 security_chip_visibility == switches::kSecurityChipShowNonSecureOnly;
182
183 std::string security_chip_animation =
184 variations::GetVariationParamValueByFeature(
185 features::kSecurityChip, kSecurityChipFeatureAnimationParam);
186 should_animate_secure_state_ =
187 security_chip_animation == switches::kSecurityChipAnimationAll;
188 should_animate_nonsecure_state_ =
189 should_animate_secure_state_ ||
190 security_chip_animation ==
191 switches::kSecurityChipAnimationNonSecureOnly;
169 } 192 }
170 } 193 }
171 194
172 LocationBarView::~LocationBarView() { 195 LocationBarView::~LocationBarView() {
173 if (template_url_service_) 196 if (template_url_service_)
174 template_url_service_->RemoveObserver(this); 197 template_url_service_->RemoveObserver(this);
175 198
176 zoom::ZoomEventManager::GetForBrowserContext(profile()) 199 zoom::ZoomEventManager::GetForBrowserContext(profile())
177 ->RemoveZoomEventManagerObserver(this); 200 ->RemoveZoomEventManagerObserver(this);
178 } 201 }
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 if (star_view_) 788 if (star_view_)
766 UpdateBookmarkStarVisibility(); 789 UpdateBookmarkStarVisibility();
767 790
768 if (contents) 791 if (contents)
769 omnibox_view_->OnTabChanged(contents); 792 omnibox_view_->OnTabChanged(contents);
770 else 793 else
771 omnibox_view_->Update(); 794 omnibox_view_->Update();
772 795
773 bool should_show = ShouldShowSecurityChip(); 796 bool should_show = ShouldShowSecurityChip();
774 location_icon_view_->SetSecurityState( 797 location_icon_view_->SetSecurityState(
775 should_show, should_show && !contents && should_animate_secure_state_); 798 should_show, should_show && !contents && ShouldAnimateSecurityChip());
776 799
777 OnChanged(); // NOTE: Calls Layout(). 800 OnChanged(); // NOTE: Calls Layout().
778 } 801 }
779 802
780 void LocationBarView::ResetTabState(WebContents* contents) { 803 void LocationBarView::ResetTabState(WebContents* contents) {
781 omnibox_view_->ResetTabState(contents); 804 omnibox_view_->ResetTabState(contents);
782 } 805 }
783 806
784 //////////////////////////////////////////////////////////////////////////////// 807 ////////////////////////////////////////////////////////////////////////////////
785 // LocationBarView, public OmniboxEditController implementation: 808 // LocationBarView, public OmniboxEditController implementation:
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 if (level == SecurityLevel::EV_SECURE) { 1035 if (level == SecurityLevel::EV_SECURE) {
1013 return true; 1036 return true;
1014 } else if (level == SecurityLevel::SECURE) { 1037 } else if (level == SecurityLevel::SECURE) {
1015 return should_show_secure_state_; 1038 return should_show_secure_state_;
1016 } else { 1039 } else {
1017 return should_show_nonsecure_state_ && 1040 return should_show_nonsecure_state_ &&
1018 level == SecurityLevel::DANGEROUS; 1041 level == SecurityLevel::DANGEROUS;
1019 } 1042 }
1020 } 1043 }
1021 1044
1045 bool LocationBarView::ShouldAnimateSecurityChip() const {
1046 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1047 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1048 if (!ShouldShowSecurityChip())
1049 return false;
1050 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE)
1051 return should_animate_secure_state_;
1052 return should_animate_nonsecure_state_ &&
1053 (level == SecurityLevel::DANGEROUS ||
1054 level == SecurityLevel::HTTP_SHOW_WARNING);
1055 }
1056
1022 //////////////////////////////////////////////////////////////////////////////// 1057 ////////////////////////////////////////////////////////////////////////////////
1023 // LocationBarView, private LocationBar implementation: 1058 // LocationBarView, private LocationBar implementation:
1024 1059
1025 void LocationBarView::ShowFirstRunBubble() { 1060 void LocationBarView::ShowFirstRunBubble() {
1026 // Wait until search engines have loaded to show the first run bubble. 1061 // Wait until search engines have loaded to show the first run bubble.
1027 TemplateURLService* url_service = 1062 TemplateURLService* url_service =
1028 TemplateURLServiceFactory::GetForProfile(profile()); 1063 TemplateURLServiceFactory::GetForProfile(profile());
1029 if (!url_service->loaded()) { 1064 if (!url_service->loaded()) {
1030 template_url_service_ = url_service; 1065 template_url_service_ = url_service;
1031 template_url_service_->AddObserver(this); 1066 template_url_service_->AddObserver(this);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // LocationBarView, private TemplateURLServiceObserver implementation: 1362 // LocationBarView, private TemplateURLServiceObserver implementation:
1328 1363
1329 void LocationBarView::OnTemplateURLServiceChanged() { 1364 void LocationBarView::OnTemplateURLServiceChanged() {
1330 template_url_service_->RemoveObserver(this); 1365 template_url_service_->RemoveObserver(this);
1331 template_url_service_ = nullptr; 1366 template_url_service_ = nullptr;
1332 // If the browser is no longer active, let's not show the info bubble, as this 1367 // If the browser is no longer active, let's not show the info bubble, as this
1333 // would make the browser the active window again. 1368 // would make the browser the active window again.
1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1369 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1335 ShowFirstRunBubble(); 1370 ShowFirstRunBubble();
1336 } 1371 }
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