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

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: . 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
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 e4e811110d59cdc2928112f44408ab44c6fa83df..323116eee166a92193fdd3c199412045e44613df 100644
--- a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
+++ b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
@@ -57,6 +57,14 @@ SkColor GetSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) {
}
}
+SkColor GetSecurityChipColor(SecurityLevel level,
+ bool offline_page,
+ const ColorScheme& color_scheme) {
+ if (offline_page)
+ return color_scheme.url_emphasized;
fgorski 2017/07/06 20:01:33 per our discussion I am concerned about putting th
cjgrant 2017/07/06 20:13:00 Noted. I'll follow up with Josh Carpenter (our UX
+ return GetSchemeColor(level, color_scheme);
+}
+
void setEmphasis(vr_shell::RenderTextWrapper* render_text,
bool emphasis,
const gfx::Range& range,
@@ -80,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;
@@ -219,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();
@@ -229,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,13 +247,14 @@ 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) {
+ if (state_.offline_page && state_.should_display_url) {
fgorski 2017/07/06 20:01:34 this will only kick in for offline pages if you &&
cjgrant 2017/07/06 20:13:00 Yes. We added chip support for "Secure" and "Not
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());
@@ -299,9 +308,14 @@ 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;
+
+ url_formatter::FormatUrlTypes format_types = url_formatter::kFormatUrlOmitAll;
+ if (state_.offline_page)
+ format_types |= url_formatter::kFormatUrlExperimentalOmitHTTPS;
+
const base::string16 text = url_formatter::FormatUrl(
- state_.gurl, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL,
- &parsed, nullptr, nullptr);
+ state_.gurl, format_types, net::UnescapeRule::NORMAL, &parsed, nullptr,
+ nullptr);
int pixel_font_height = texture_size.height() * kFontHeight / kHeight;

Powered by Google App Engine
This is Rietveld 408576698