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

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

Issue 2378623007: [Material] Update Material Security Verbose Decoration Flag (Closed)
Patch Set: Rebased again 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 (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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 manage_passwords_icon_view_(nullptr), 134 manage_passwords_icon_view_(nullptr),
135 save_credit_card_icon_view_(nullptr), 135 save_credit_card_icon_view_(nullptr),
136 translate_icon_view_(nullptr), 136 translate_icon_view_(nullptr),
137 star_view_(nullptr), 137 star_view_(nullptr),
138 size_animation_(this), 138 size_animation_(this),
139 is_popup_mode_(is_popup_mode), 139 is_popup_mode_(is_popup_mode),
140 show_focus_rect_(false), 140 show_focus_rect_(false),
141 template_url_service_(NULL), 141 template_url_service_(NULL),
142 web_contents_null_at_last_refresh_(true), 142 web_contents_null_at_last_refresh_(true),
143 should_show_secure_state_(true), 143 should_show_secure_state_(true),
144 should_animate_secure_state_(true) { 144 should_animate_secure_state_(false),
145 should_animate_nonsecure_state_(false) {
145 edit_bookmarks_enabled_.Init( 146 edit_bookmarks_enabled_.Init(
146 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
147 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 148 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
148 base::Unretained(this))); 149 base::Unretained(this)));
149 150
150 zoom::ZoomEventManager::GetForBrowserContext(profile) 151 zoom::ZoomEventManager::GetForBrowserContext(profile)
151 ->AddZoomEventManagerObserver(this); 152 ->AddZoomEventManagerObserver(this);
152 153
153 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
154 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { 155 if (command_line->HasSwitch(switches::kSecurityChip)) {
155 std::string security_verbose_flag = 156 std::string security_chip_flag =
156 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); 157 command_line->GetSwitchValueASCII(switches::kSecurityChip);
158 should_show_secure_state_ =
159 security_chip_flag == switches::kSecurityChipShowAll;
160 }
157 161
158 should_show_secure_state_ = 162 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) {
159 security_verbose_flag == 163 std::string security_chip_animation_flag =
160 switches::kMaterialSecurityVerboseShowAllAnimated || 164 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation);
161 security_verbose_flag == 165 should_animate_secure_state_ =
162 switches::kMaterialSecurityVerboseShowAllNonAnimated; 166 security_chip_animation_flag == switches::kSecurityChipAnimationAll;
163 167
164 should_animate_secure_state_ = 168 should_animate_nonsecure_state_ =
165 security_verbose_flag == 169 security_chip_animation_flag ==
166 switches::kMaterialSecurityVerboseShowAllAnimated || 170 switches::kSecurityChipAnimationNonSecureOnly ||
167 security_verbose_flag == 171 security_chip_animation_flag == switches::kSecurityChipAnimationAll;
168 switches::kMaterialSecurityVerboseShowNonSecureAnimated;
169 } 172 }
170 } 173 }
171 174
172 LocationBarView::~LocationBarView() { 175 LocationBarView::~LocationBarView() {
173 if (template_url_service_) 176 if (template_url_service_)
174 template_url_service_->RemoveObserver(this); 177 template_url_service_->RemoveObserver(this);
175 178
176 zoom::ZoomEventManager::GetForBrowserContext(profile()) 179 zoom::ZoomEventManager::GetForBrowserContext(profile())
177 ->RemoveZoomEventManagerObserver(this); 180 ->RemoveZoomEventManagerObserver(this);
178 } 181 }
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); 766 open_pdf_in_reader_view_->Update(web_contents_for_sub_views);
764 767
765 if (star_view_) 768 if (star_view_)
766 UpdateBookmarkStarVisibility(); 769 UpdateBookmarkStarVisibility();
767 770
768 if (contents) 771 if (contents)
769 omnibox_view_->OnTabChanged(contents); 772 omnibox_view_->OnTabChanged(contents);
770 else 773 else
771 omnibox_view_->Update(); 774 omnibox_view_->Update();
772 775
773 bool should_show = ShouldShowSecurityChip();
774 location_icon_view_->SetSecurityState( 776 location_icon_view_->SetSecurityState(
775 should_show, should_show && !contents && should_animate_secure_state_); 777 ShouldShowSecurityChip(), !contents && ShouldAnimateSecurityChip());
776 778
777 OnChanged(); // NOTE: Calls Layout(). 779 OnChanged(); // NOTE: Calls Layout().
778 } 780 }
779 781
780 void LocationBarView::ResetTabState(WebContents* contents) { 782 void LocationBarView::ResetTabState(WebContents* contents) {
781 omnibox_view_->ResetTabState(contents); 783 omnibox_view_->ResetTabState(contents);
782 } 784 }
783 785
784 //////////////////////////////////////////////////////////////////////////////// 786 ////////////////////////////////////////////////////////////////////////////////
785 // LocationBarView, public OmniboxEditController implementation: 787 // LocationBarView, public OmniboxEditController implementation:
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1014
1013 bool LocationBarView::ShouldShowSecurityChip() const { 1015 bool LocationBarView::ShouldShowSecurityChip() const {
1014 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; 1016 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1015 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 1017 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1016 return ((level == SecurityLevel::SECURE || 1018 return ((level == SecurityLevel::SECURE ||
1017 level == SecurityLevel::EV_SECURE) && 1019 level == SecurityLevel::EV_SECURE) &&
1018 should_show_secure_state_) || 1020 should_show_secure_state_) ||
1019 level == SecurityLevel::DANGEROUS; 1021 level == SecurityLevel::DANGEROUS;
1020 } 1022 }
1021 1023
1024 bool LocationBarView::ShouldAnimateSecurityChip() const {
1025 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1026 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1027 bool is_secure_level =
1028 level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE;
1029 return ShouldShowSecurityChip() &&
1030 ((level == SecurityLevel::DANGEROUS &&
1031 should_animate_nonsecure_state_) ||
1032 (is_secure_level && should_animate_secure_state_));
1033 }
1034
1022 //////////////////////////////////////////////////////////////////////////////// 1035 ////////////////////////////////////////////////////////////////////////////////
1023 // LocationBarView, private LocationBar implementation: 1036 // LocationBarView, private LocationBar implementation:
1024 1037
1025 void LocationBarView::ShowFirstRunBubble() { 1038 void LocationBarView::ShowFirstRunBubble() {
1026 // Wait until search engines have loaded to show the first run bubble. 1039 // Wait until search engines have loaded to show the first run bubble.
1027 TemplateURLService* url_service = 1040 TemplateURLService* url_service =
1028 TemplateURLServiceFactory::GetForProfile(profile()); 1041 TemplateURLServiceFactory::GetForProfile(profile());
1029 if (!url_service->loaded()) { 1042 if (!url_service->loaded()) {
1030 template_url_service_ = url_service; 1043 template_url_service_ = url_service;
1031 template_url_service_->AddObserver(this); 1044 template_url_service_->AddObserver(this);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // LocationBarView, private TemplateURLServiceObserver implementation: 1340 // LocationBarView, private TemplateURLServiceObserver implementation:
1328 1341
1329 void LocationBarView::OnTemplateURLServiceChanged() { 1342 void LocationBarView::OnTemplateURLServiceChanged() {
1330 template_url_service_->RemoveObserver(this); 1343 template_url_service_->RemoveObserver(this);
1331 template_url_service_ = nullptr; 1344 template_url_service_ = nullptr;
1332 // If the browser is no longer active, let's not show the info bubble, as this 1345 // 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. 1346 // would make the browser the active window again.
1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1347 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1335 ShowFirstRunBubble(); 1348 ShowFirstRunBubble();
1336 } 1349 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698