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

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

Issue 2435493003: [Views][Mac] Security Chip Default Value (Closed)
Patch Set: Fix for pkasting 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
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 open_pdf_in_reader_view_(nullptr), 133 open_pdf_in_reader_view_(nullptr),
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_(false),
144 should_show_nonsecure_state_(false),
144 should_animate_secure_state_(false), 145 should_animate_secure_state_(false),
145 should_animate_nonsecure_state_(false) { 146 should_animate_nonsecure_state_(false) {
146 edit_bookmarks_enabled_.Init( 147 edit_bookmarks_enabled_.Init(
147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 148 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
148 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 149 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
149 base::Unretained(this))); 150 base::Unretained(this)));
150 151
151 zoom::ZoomEventManager::GetForBrowserContext(profile) 152 zoom::ZoomEventManager::GetForBrowserContext(profile)
152 ->AddZoomEventManagerObserver(this); 153 ->AddZoomEventManagerObserver(this);
153 154
154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 155 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
155 if (command_line->HasSwitch(switches::kSecurityChip)) { 156 if (command_line->HasSwitch(switches::kSecurityChip)) {
156 std::string security_chip_flag = 157 std::string security_chip_flag =
157 command_line->GetSwitchValueASCII(switches::kSecurityChip); 158 command_line->GetSwitchValueASCII(switches::kSecurityChip);
158 should_show_secure_state_ = 159 should_show_secure_state_ =
159 security_chip_flag == switches::kSecurityChipShowAll; 160 security_chip_flag == switches::kSecurityChipShowAll;
161 should_show_nonsecure_state_ =
162 security_chip_flag == switches::kSecurityChipShowAll ||
163 security_chip_flag == switches::kSecurityChipShowNonSecureOnly;
160 } 164 }
161 165
162 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { 166 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) {
163 std::string security_chip_animation_flag = 167 std::string security_chip_animation_flag =
164 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); 168 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation);
165 should_animate_secure_state_ = 169 should_animate_secure_state_ =
166 security_chip_animation_flag == switches::kSecurityChipAnimationAll; 170 security_chip_animation_flag == switches::kSecurityChipAnimationAll;
167 171
168 should_animate_nonsecure_state_ = 172 should_animate_nonsecure_state_ =
169 security_chip_animation_flag == 173 security_chip_animation_flag ==
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 FirstRunBubble::ShowBubble(browser, location_icon_view_); 995 FirstRunBubble::ShowBubble(browser, location_icon_view_);
992 #endif 996 #endif
993 } 997 }
994 998
995 bool LocationBarView::HasValidSuggestText() const { 999 bool LocationBarView::HasValidSuggestText() const {
996 return suggested_text_view_->visible() && 1000 return suggested_text_view_->visible() &&
997 !suggested_text_view_->size().IsEmpty(); 1001 !suggested_text_view_->size().IsEmpty();
998 } 1002 }
999 1003
1000 base::string16 LocationBarView::GetSecurityText() const { 1004 base::string16 LocationBarView::GetSecurityText() const {
1001 return ShouldShowEVBubble() ? GetToolbarModel()->GetEVCertName() 1005 bool has_ev_cert = (GetToolbarModel()->GetSecurityLevel(false) ==
1002 : GetToolbarModel()->GetSecureVerboseText(); 1006 security_state::SecurityStateModel::EV_SECURE);
1007 return has_ev_cert ? GetToolbarModel()->GetEVCertName()
1008 : GetToolbarModel()->GetSecureVerboseText();
1003 } 1009 }
1004 1010
1005 bool LocationBarView::ShouldShowKeywordBubble() const { 1011 bool LocationBarView::ShouldShowKeywordBubble() const {
1006 return !omnibox_view_->model()->keyword().empty() && 1012 return !omnibox_view_->model()->keyword().empty() &&
1007 !omnibox_view_->model()->is_keyword_hint(); 1013 !omnibox_view_->model()->is_keyword_hint();
1008 } 1014 }
1009 1015
1010 bool LocationBarView::ShouldShowEVBubble() const {
1011 return (GetToolbarModel()->GetSecurityLevel(false) ==
1012 security_state::SecurityStateModel::EV_SECURE) &&
1013 should_show_secure_state_;
1014 }
1015
1016 bool LocationBarView::ShouldShowSecurityChip() const { 1016 bool LocationBarView::ShouldShowSecurityChip() const {
1017 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; 1017 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1018 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 1018 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1019 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) 1019 if (level == SecurityLevel::EV_SECURE) {
1020 return true;
1021 } else if (level == SecurityLevel::SECURE) {
1020 return should_show_secure_state_; 1022 return should_show_secure_state_;
1021 return level == SecurityLevel::DANGEROUS || 1023 } else {
1022 level == SecurityLevel::HTTP_SHOW_WARNING; 1024 return should_show_nonsecure_state_ &&
1025 (level == SecurityLevel::DANGEROUS ||
1026 level == SecurityLevel::HTTP_SHOW_WARNING);
1027 }
1023 } 1028 }
1024 1029
1025 bool LocationBarView::ShouldAnimateSecurityChip() const { 1030 bool LocationBarView::ShouldAnimateSecurityChip() const {
1026 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; 1031 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1027 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 1032 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1028 if (!ShouldShowSecurityChip()) 1033 if (!ShouldShowSecurityChip())
1029 return false; 1034 return false;
1030 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) 1035 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE)
1031 return should_animate_secure_state_; 1036 return should_animate_secure_state_;
1032 return should_animate_nonsecure_state_ && 1037 return should_animate_nonsecure_state_ &&
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 // LocationBarView, private TemplateURLServiceObserver implementation: 1347 // LocationBarView, private TemplateURLServiceObserver implementation:
1343 1348
1344 void LocationBarView::OnTemplateURLServiceChanged() { 1349 void LocationBarView::OnTemplateURLServiceChanged() {
1345 template_url_service_->RemoveObserver(this); 1350 template_url_service_->RemoveObserver(this);
1346 template_url_service_ = nullptr; 1351 template_url_service_ = nullptr;
1347 // If the browser is no longer active, let's not show the info bubble, as this 1352 // If the browser is no longer active, let's not show the info bubble, as this
1348 // would make the browser the active window again. 1353 // would make the browser the active window again.
1349 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1354 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1350 ShowFirstRunBubble(); 1355 ShowFirstRunBubble();
1351 } 1356 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698