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

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: 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..bcee6e91f4b4373f34edfae35de2e7d79ead756e 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,8 @@
#include "base/strings/utf_string_conversions.h"
#include "cc/paint/skia_paint_canvas.h"
+#include "chrome/app/vector_icons/vector_icons.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 +38,27 @@ 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:
+ return kLockIcon;
+ 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 +70,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 +123,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.
tiborg 2017/05/09 15:00:35 Can this TODO go away now?
- 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);
mthiesse 2017/05/08 21:39:30 Why not just use the 4-arg variant like our other
cjgrant 2017/05/09 00:57:42 Reason: Since the UX spec gives all dimensions in
+ canvas->restore();
+ }
canvas->restore();

Powered by Google App Engine
This is Rietveld 408576698