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

Side by Side 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: Addressing suggestions 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/textures/insecure_content_transient_te xture.h"
6
7 #include "cc/paint/skia_paint_canvas.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/vector2d.h"
13 #include "ui/gfx/paint_vector_icon.h"
14 #include "ui/gfx/vector_icon_types.h"
15 #include "ui/vector_icons/vector_icons.h"
16
17 namespace vr_shell {
18
19 namespace {
20
21 const SkColor kBackgroundColor = 0xCC1A1A1A;
22 const SkColor kForegroundColor = SK_ColorWHITE;
23
24 } // namespace
25
26 InsecureContentTransientTexture::InsecureContentTransientTexture(
27 int texture_handle,
28 int texture_size)
29 : UITexture(texture_handle, texture_size) {
30 DCHECK(texture_size_ % 2 == 0);
mthiesse 2017/04/13 15:31:37 Comment on why the DCHECK
31 height_ = texture_size_ / 2;
32 }
33
34 InsecureContentTransientTexture::~InsecureContentTransientTexture() = default;
35
36 void InsecureContentTransientTexture::Draw(gfx::Canvas* canvas) {
37 cc::PaintFlags flags;
38 flags.setColor(kBackgroundColor);
39 canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1,
40 flags);
41 canvas->Save();
42 canvas->Translate({height_ * 0.1, height_ * 0.25});
43 PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.5,
44 kForegroundColor);
45 canvas->Restore();
46 canvas->Save();
47 canvas->Translate({height_ * 0.7, height_ * 0.5});
48 flags.setColor(kForegroundColor);
49 flags.setTextSize(height_ * 0.1);
50 auto text =
51 l10n_util::GetStringUTF8(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_TRANSIENT);
52 DrawText(canvas, text, flags, height_ * 1.2, true);
53 canvas->Restore();
54 }
55
56 void InsecureContentTransientTexture::SetSize() {
57 size_.SetSize(texture_size_, height_);
58 }
59
60 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698