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

Side by Side Diff: chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc

Issue 2818553002: Rendering Insecure WebVR Warnings into a texture with Skia. (Closed)
Patch Set: 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_permanent_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 kPermanentWarningBgColor = SK_ColorWHITE;
cjgrant 2017/04/12 20:38:53 Since this file is permanent warning specific, you
acondor_ 2017/04/12 21:21:45 Done.
22 const SkColor kPermanentWarningFgColor = 0xFF444444;
23
24 } // namespace
25
26 InsecureContentPermanentTexture::InsecureContentPermanentTexture(
27 int texture_handle,
28 int texture_size)
29 : UITexture(texture_handle, texture_size) {
30 DCHECK(texture_size_ % 4 == 0);
31 height_ = texture_size_ / 4;
32 }
33
34 InsecureContentPermanentTexture::~InsecureContentPermanentTexture() = default;
35
36 void InsecureContentPermanentTexture::Draw(gfx::Canvas* canvas) {
37 cc::PaintFlags flags;
38 flags.setColor(kPermanentWarningBgColor);
39 canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1,
40 flags);
41 canvas->Save();
42 canvas->Translate({height_ * 0.1, height_ * 0.1});
43 PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.8,
44 kPermanentWarningFgColor);
45 canvas->Restore();
46 canvas->Save();
47 canvas->Translate({height_, height_ * 0.5});
48 flags.setColor(kPermanentWarningFgColor);
49 flags.setTextSize(height_ * 0.4);
50 auto text =
51 l10n_util::GetStringUTF8(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_PERMANENT);
52 DrawText(canvas, text, flags, height_ * 2.9, true);
53 canvas->Restore();
54 }
55
56 void InsecureContentPermanentTexture::SetSize() {
57 size_.SetSize(texture_size_, height_);
58 }
59
60 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698