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

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

Issue 2818553002: Rendering Insecure WebVR Warnings into a texture with Skia. (Closed)
Patch Set: Adding comments Created 3 years, 8 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/insecure_content_transient_texture.cc
diff --git a/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc b/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f215587252df04122e570355383087ba38bf306c
--- /dev/null
+++ b/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.h"
+
+#include "cc/paint/skia_paint_canvas.h"
+#include "chrome/grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/vector2d.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icon_types.h"
+#include "ui/vector_icons/vector_icons.h"
+
+namespace vr_shell {
+
+namespace {
+
+const SkColor kBackgroundColor = 0xCC1A1A1A;
+const SkColor kForegroundColor = SK_ColorWHITE;
+
+} // namespace
+
+InsecureContentTransientTexture::InsecureContentTransientTexture(
+ int texture_handle,
+ int texture_size)
+ : UITexture(texture_handle, texture_size) {
+ // Ensuring height is half the width.
+ DCHECK(texture_size_ % 2 == 0);
+ height_ = texture_size_ / 2;
+}
+
+InsecureContentTransientTexture::~InsecureContentTransientTexture() = default;
+
+void InsecureContentTransientTexture::Draw(gfx::Canvas* canvas) {
+ cc::PaintFlags flags;
+ flags.setColor(kBackgroundColor);
+ canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1,
+ flags);
+ canvas->Save();
+ canvas->Translate({height_ * 0.1, height_ * 0.25});
+ PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.5,
+ kForegroundColor);
+ canvas->Restore();
+ canvas->Save();
+ canvas->Translate({height_ * 0.7, height_ * 0.1});
+ // TODO(acondor): Draw text IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_TRANSIENT.
+ canvas->Restore();
+}
+
+void InsecureContentTransientTexture::SetSize() {
+ size_.SetSize(texture_size_, height_);
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698