Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/vr_shell/textures/insecure_content_permanent_te xture.h" | 5 #include "chrome/browser/android/vr_shell/textures/insecure_content_permanent_te xture.h" |
| 6 | 6 |
| 7 #include "cc/paint/skia_paint_canvas.h" | 7 #include "cc/paint/skia_paint_canvas.h" |
| 8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/font_list.h" | |
| 11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 12 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
| 13 #include "ui/gfx/paint_vector_icon.h" | 14 #include "ui/gfx/paint_vector_icon.h" |
| 14 #include "ui/gfx/vector_icon_types.h" | 15 #include "ui/gfx/vector_icon_types.h" |
| 15 #include "ui/vector_icons/vector_icons.h" | 16 #include "ui/vector_icons/vector_icons.h" |
| 16 | 17 |
| 17 namespace vr_shell { | 18 namespace vr_shell { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 32 height_ = texture_size_ / 4; | 33 height_ = texture_size_ / 4; |
| 33 } | 34 } |
| 34 | 35 |
| 35 InsecureContentPermanentTexture::~InsecureContentPermanentTexture() = default; | 36 InsecureContentPermanentTexture::~InsecureContentPermanentTexture() = default; |
| 36 | 37 |
| 37 void InsecureContentPermanentTexture::Draw(gfx::Canvas* canvas) { | 38 void InsecureContentPermanentTexture::Draw(gfx::Canvas* canvas) { |
| 38 cc::PaintFlags flags; | 39 cc::PaintFlags flags; |
| 39 flags.setColor(kBackgroundColor); | 40 flags.setColor(kBackgroundColor); |
| 40 canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1, | 41 canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1, |
| 41 flags); | 42 flags); |
| 43 | |
| 44 // TODO(acondor): Layout icon on the right for RTL languages. | |
| 42 canvas->Save(); | 45 canvas->Save(); |
| 43 canvas->Translate({height_ * 0.1, height_ * 0.1}); | 46 canvas->Translate({height_ * 0.1, height_ * 0.1}); |
| 44 PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.8, | 47 PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.8, |
| 45 kForegroundColor); | 48 kForegroundColor); |
| 46 canvas->Restore(); | 49 canvas->Restore(); |
| 50 | |
| 47 canvas->Save(); | 51 canvas->Save(); |
| 48 canvas->Translate({height_, height_ * 0.1}); | 52 canvas->Translate({height_, height_ * 0.1}); |
| 49 // TODO(acondor): Draw text IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_PERMANENT. | 53 // TODO(acondor): Measure text width to remove empty space. |
| 54 int text_flags = gfx::Canvas::TEXT_ALIGN_CENTER; | |
| 55 auto text = | |
| 56 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_PERMANENT); | |
| 57 canvas->DrawStringRectWithFlags( | |
| 58 text, GetFontList(height_ * 0.3, text), kForegroundColor, | |
|
mthiesse
2017/04/18 21:30:35
Can you make constants for the magic numbers (like
acondor_
2017/04/18 23:48:46
Done.
| |
| 59 {0, 0, 2.9 * height_, 0.8 * height_}, text_flags); | |
| 50 canvas->Restore(); | 60 canvas->Restore(); |
| 51 } | 61 } |
| 52 | 62 |
| 53 void InsecureContentPermanentTexture::SetSize() { | 63 void InsecureContentPermanentTexture::SetSize() { |
| 54 size_.SetSize(texture_size_, height_); | 64 size_.SetSize(texture_size_, height_); |
| 55 } | 65 } |
| 56 | 66 |
| 57 } // namespace vr_shell | 67 } // namespace vr_shell |
| OLD | NEW |