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

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

Issue 2872773002: VR: Render the current URL and security level on the URL bar. (Closed)
Patch Set: Revert the inclusion of the lock icon; will re-add when moved to UI. Created 3 years, 7 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 d1861dd15b2d033e4ab0b2d60d78307b5f60f5c2..e1ca6cdded8dd237445e47b9de6caa59807acfd6 100644
--- a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
+++ b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
@@ -6,6 +6,7 @@
#include "base/strings/utf_string_conversions.h"
#include "cc/paint/skia_paint_canvas.h"
+#include "components/security_state/core/security_state.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
@@ -36,9 +37,29 @@ static constexpr float kSecurityIconHeight = 0.03;
static constexpr float kUrlRightMargin = 0.02;
static constexpr float kSeparatorWidth = 0.002;
+using security_state::SecurityLevel;
+
+const struct gfx::VectorIcon& getSecurityIcon(int level) {
+ switch (level) {
+ case SecurityLevel::NONE:
+ case SecurityLevel::HTTP_SHOW_WARNING:
+ case SecurityLevel::SECURITY_WARNING:
+ return ui::kInfoOutlineIcon;
+ case SecurityLevel::SECURE:
+ case SecurityLevel::EV_SECURE:
+ // TODO(cjgrant): Use the lock icon when available.
+ // return ui::kLockIcon;
+ return ui::kInfoOutlineIcon;
+ case SecurityLevel::SECURE_WITH_POLICY_INSTALLED_CERT:
+ case SecurityLevel::DANGEROUS:
+ default:
+ return ui::kWarningIcon;
+ }
+}
+
} // namespace
-UrlBarTexture::UrlBarTexture() = default;
+UrlBarTexture::UrlBarTexture() : security_level_(SecurityLevel::DANGEROUS) {}
UrlBarTexture::~UrlBarTexture() = default;
@@ -50,6 +71,10 @@ void UrlBarTexture::SetURL(const GURL& gurl) {
gurl_ = gurl;
}
+void UrlBarTexture::SetSecurityLevel(int level) {
+ security_level_ = level;
+}
+
float UrlBarTexture::ToPixels(float meters) const {
return meters * size_.width() / kWidth;
}
@@ -99,16 +124,19 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
// Site security state icon.
// TODO(cjgrant): Plug in the correct icons based on security level.
- canvas->save();
- canvas->translate(
- kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2,
- kHeight / 2);
- canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
- icon_default_height = GetDefaultSizeOfVectorIcon(ui::kBackArrowIcon);
- icon_scale = kSecurityIconHeight / icon_default_height;
- canvas->scale(icon_scale, icon_scale);
- PaintVectorIcon(&gfx_canvas, ui::kBackArrowIcon, kForeground);
- canvas->restore();
+ if (!gurl_.spec().empty()) {
+ canvas->save();
+ canvas->translate(
+ kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2,
+ kHeight / 2);
+ canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
+ const gfx::VectorIcon& security_icon = getSecurityIcon(security_level_);
+ icon_default_height = GetDefaultSizeOfVectorIcon(security_icon);
+ icon_scale = kSecurityIconHeight / icon_default_height;
+ canvas->scale(icon_scale, icon_scale);
+ PaintVectorIcon(&gfx_canvas, security_icon, kForeground);
+ canvas->restore();
+ }
canvas->restore();
« no previous file with comments | « chrome/browser/android/vr_shell/textures/url_bar_texture.h ('k') | chrome/browser/android/vr_shell/ui_elements/url_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698