Chromium Code Reviews| 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..dbfaa5ddab6a105aac86d6a5a412661394560ce9 |
| --- /dev/null |
| +++ b/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc |
| @@ -0,0 +1,60 @@ |
| +// 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) { |
| + DCHECK(texture_size_ % 2 == 0); |
|
mthiesse
2017/04/13 15:31:37
Comment on why the DCHECK
|
| + 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.5}); |
| + flags.setColor(kForegroundColor); |
| + flags.setTextSize(height_ * 0.1); |
| + auto text = |
| + l10n_util::GetStringUTF8(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_TRANSIENT); |
| + DrawText(canvas, text, flags, height_ * 1.2, true); |
| + canvas->Restore(); |
| +} |
| + |
| +void InsecureContentTransientTexture::SetSize() { |
| + size_.SetSize(texture_size_, height_); |
| +} |
| + |
| +} // namespace vr_shell |