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

Unified Diff: chrome/browser/android/vr_shell/textures/url_bar_texture.cc

Issue 2968143003: Toolbar: Report offline state through icon and verbose text. (Closed)
Patch Set: Fix header date. Created 3 years, 5 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
« no previous file with comments | « chrome/browser/android/vr_shell/textures/url_bar_texture.h ('k') | components/omnibox_strings.grdp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/textures/url_bar_texture.cc
diff --git a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
index 30cc4440cc8ab46c9d987147dbe03786ca5d3a40..5b35f4fa3c683cbd15ce13e04d7e442686854d6d 100644
--- a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
+++ b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
@@ -58,6 +58,13 @@ SkColor GetSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) {
}
}
+SkColor GetSecurityChipColor(SecurityLevel level,
+ bool offline_page,
+ const ColorScheme& color_scheme) {
+ return offline_page ? color_scheme.url_emphasized
+ : GetSchemeColor(level, color_scheme);
+}
+
void setEmphasis(vr_shell::RenderTextWrapper* render_text,
bool emphasis,
const gfx::Range& range,
@@ -81,7 +88,6 @@ UrlBarTexture::UrlBarTexture(
bool web_vr,
const base::Callback<void(UiUnsupportedMode)>& failure_callback)
: has_back_button_(!web_vr),
- has_security_chip_(false),
failure_callback_(failure_callback) {}
UrlBarTexture::~UrlBarTexture() = default;
@@ -220,8 +226,8 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
// Site security state icon.
left_edge += kFieldSpacing;
- if (state_.security_level != security_state::NONE &&
- state_.vector_icon != nullptr) {
+ if ((state_.security_level != security_state::NONE || state_.offline_page) &&
+ state_.vector_icon != nullptr && state_.should_display_url) {
gfx::RectF icon_region(left_edge, kHeight / 2 - kSecurityIconSize / 2,
kSecurityIconSize, kSecurityIconSize);
canvas->save();
@@ -230,7 +236,8 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
float icon_scale = kSecurityIconSize / GetDefaultSizeOfVectorIcon(icon);
canvas->scale(icon_scale, icon_scale);
PaintVectorIcon(&gfx_canvas, icon,
- GetSchemeColor(state_.security_level, color_scheme()));
+ GetSecurityChipColor(state_.security_level,
+ state_.offline_page, color_scheme()));
canvas->restore();
security_hit_region_ = icon_region;
@@ -239,14 +246,21 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
canvas->restore();
- // Draw security chip text (eg. "Not secure") next to the security icon.
- if (has_security_chip_ && state_.should_display_url) {
+ // The security chip text consumes a significant percentage of URL bar text
+ // space, so they are currently disabled (see crbug.com/734206). The offline
Peter Kasting 2017/07/10 20:22:00 Nit: they are -> it is
+ // chip is an exception, and must be shown (see crbug.com/735770).
Peter Kasting 2017/07/10 20:22:00 Nit: chip -> state
+ bool draw_security_chip = state_.offline_page;
+
+ // Possibly draw security chip text (eg. "Not secure") next to the security
+ // icon.
+ if (draw_security_chip && state_.should_display_url) {
float chip_max_width = kWidth - left_edge - kUrlRightMargin;
gfx::Rect text_bounds(ToPixels(left_edge), 0, ToPixels(chip_max_width),
ToPixels(kHeight));
int pixel_font_height = texture_size.height() * kFontHeight / kHeight;
- SkColor chip_color = GetSchemeColor(state_.security_level, color_scheme());
+ SkColor chip_color = GetSecurityChipColor(
+ state_.security_level, state_.offline_page, color_scheme());
const base::string16& chip_text = state_.secure_verbose_text;
DCHECK(!chip_text.empty());
@@ -300,6 +314,7 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
void UrlBarTexture::RenderUrl(const gfx::Size& texture_size,
const gfx::Rect& bounds) {
url::Parsed parsed;
+
Peter Kasting 2017/07/10 20:22:00 Nit: Probably wouldn't add this blank line
const base::string16 text = url_formatter::FormatUrl(
state_.gurl, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL,
&parsed, nullptr, nullptr);
« no previous file with comments | « chrome/browser/android/vr_shell/textures/url_bar_texture.h ('k') | components/omnibox_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698