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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 2144903004: New location security strings and animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor responses Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 7ffa3e9e7d73a16df4e74ffa17c4b9c1c0b02f7e..0dbfc8f4601863c675c9e712a70be448a558735c 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -326,10 +326,10 @@ SkColor LocationBarView::GetColor(
case DEEMPHASIZED_TEXT:
return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128);
- case EV_BUBBLE_TEXT_AND_BORDER:
+ case SECURITY_CHIP_TEXT:
return ui::MaterialDesignController::IsModeMaterial()
? GetSecureTextColor(
- security_state::SecurityStateModel::EV_SECURE)
+ GetToolbarModel()->GetSecurityLevel(false))
: SkColorSetRGB(7, 149, 0);
}
NOTREACHED();
@@ -358,7 +358,7 @@ SkColor LocationBarView::GetSecureTextColor(
security_state::SecurityStateModel::SECURITY_ERROR) {
text_color = SkColorSetRGB(162, 0, 0);
} else {
- text_color = GetColor(EV_BUBBLE_TEXT_AND_BORDER);
+ text_color = GetColor(SECURITY_CHIP_TEXT);
}
}
return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND));
@@ -532,11 +532,11 @@ gfx::Size LocationBarView::GetPreferredSize() const {
int leading_width = edge_thickness;
if (ShouldShowKeywordBubble()) {
// The selected keyword view can collapse completely.
- } else if (ShouldShowEVBubble()) {
- leading_width += GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
- location_icon_view_->GetMinimumSizeForLabelText(
- GetToolbarModel()->GetEVCertName())
- .width();
+ } else if (ShouldShowSecurityChip()) {
+ base::string16 security_text = GetSecurityText();
+ leading_width +=
+ GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
+ location_icon_view_->GetMinimumSizeForLabelText(security_text).width();
} else {
leading_width += padding + location_icon_view_->GetMinimumSize().width();
}
@@ -612,8 +612,8 @@ void LocationBarView::Layout() {
selected_keyword_view_->set_is_extension_icon(false);
}
}
- } else if (ShouldShowEVBubble()) {
- location_icon_view_->SetLabel(GetToolbarModel()->GetEVCertName());
+ } else if (ShouldShowSecurityChip()) {
+ location_icon_view_->SetLabel(GetSecurityText());
location_icon_view_->SetBackground(true);
// The largest fraction of the omnibox that can be taken by the EV bubble.
const double kMaxBubbleFraction = 0.5;
@@ -790,7 +790,7 @@ void LocationBarView::Update(const WebContents* contents) {
RefreshTranslateIcon();
RefreshSaveCreditCardIconView();
RefreshManagePasswordsIconView();
- content::WebContents* web_contents_for_sub_views =
+ WebContents* web_contents_for_sub_views =
GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents();
open_pdf_in_reader_view_->Update(web_contents_for_sub_views);
@@ -802,6 +802,9 @@ void LocationBarView::Update(const WebContents* contents) {
else
omnibox_view_->Update();
+ bool should_show = ShouldShowSecurityChip();
+ location_icon_view_->SetSecurityState(should_show, should_show && !contents);
+
OnChanged(); // NOTE: Calls Layout().
}
@@ -1038,6 +1041,11 @@ bool LocationBarView::HasValidSuggestText() const {
!suggested_text_view_->size().IsEmpty();
}
+base::string16 LocationBarView::GetSecurityText() const {
+ return ShouldShowEVBubble() ? GetToolbarModel()->GetEVCertName()
+ : GetToolbarModel()->GetSecureVerboseText();
+}
+
bool LocationBarView::ShouldShowKeywordBubble() const {
return !omnibox_view_->model()->keyword().empty() &&
!omnibox_view_->model()->is_keyword_hint();
@@ -1048,6 +1056,13 @@ bool LocationBarView::ShouldShowEVBubble() const {
security_state::SecurityStateModel::EV_SECURE);
}
+bool LocationBarView::ShouldShowSecurityChip() const {
+ using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
+ SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
+ return level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE ||
+ level == SecurityLevel::SECURITY_ERROR;
+}
+
////////////////////////////////////////////////////////////////////////////////
// LocationBarView, private LocationBar implementation:
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/location_bar/location_icon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698