Index: chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc |
diff --git a/chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc b/chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc |
index ef4c0c416195155da802af8cee21dd40de9d3e25..c645c75edbdce3ec0c8c4df7903907d2b61bb2a0 100644 |
--- a/chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc |
+++ b/chrome/browser/android/vr_shell/textures/insecure_content_permanent_texture.cc |
@@ -8,6 +8,7 @@ |
#include "chrome/grit/generated_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/gfx/canvas.h" |
+#include "ui/gfx/font_list.h" |
#include "ui/gfx/geometry/rect.h" |
#include "ui/gfx/geometry/vector2d.h" |
#include "ui/gfx/paint_vector_icon.h" |
@@ -20,6 +21,11 @@ namespace { |
const SkColor kBackgroundColor = SK_ColorWHITE; |
const SkColor kForegroundColor = 0xFF444444; |
+constexpr float kBorderFactor = 0.1; |
+constexpr float kIconSizeFactor = 0.7; |
+constexpr float kFontSizeFactor = 0.45; |
+constexpr float kTextHeightFactor = 1.0 - 2 * kBorderFactor; |
+constexpr float kTextWidthFactor = 4.0 - 3 * kBorderFactor - kIconSizeFactor; |
} // namespace |
@@ -37,21 +43,44 @@ InsecureContentPermanentTexture::~InsecureContentPermanentTexture() = default; |
void InsecureContentPermanentTexture::Draw(gfx::Canvas* canvas) { |
cc::PaintFlags flags; |
flags.setColor(kBackgroundColor); |
- canvas->DrawRoundRect(gfx::Rect(texture_size_, height_), height_ * 0.1, |
+ |
+ int text_flags = gfx::Canvas::TEXT_ALIGN_CENTER | gfx::Canvas::NO_ELLIPSIS; |
+ auto text = |
+ l10n_util::GetStringUTF16(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_PERMANENT); |
+ auto fonts = GetFontList(height_ * kFontSizeFactor, text); |
+ int text_height = kTextHeightFactor * height_; |
+ int text_width = kTextWidthFactor * height_; |
+ gfx::Canvas::SizeStringInt(text, fonts, &text_width, &text_height, 0, |
+ text_flags); |
+ // Giving some extra width without reaching the texture limit. |
+ text_width = static_cast<int>(std::min( |
+ text_width + 2 * kBorderFactor * height_, kTextWidthFactor * height_)); |
+ width_ = static_cast<int>( |
+ ceil((3 * kBorderFactor + kIconSizeFactor) * height_ + text_width)); |
+ |
+ canvas->DrawRoundRect(gfx::Rect(width_, height_), height_ * kBorderFactor, |
flags); |
+ |
canvas->Save(); |
- canvas->Translate({height_ * 0.1, height_ * 0.1}); |
- PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * 0.8, |
+ canvas->Translate({IsRTL() ? 2 * kBorderFactor * height_ + text_width |
+ : height_ * kBorderFactor, |
+ height_ * (1.0 - kIconSizeFactor) / 2.0}); |
+ PaintVectorIcon(canvas, ui::kInfoOutlineIcon, height_ * kIconSizeFactor, |
kForegroundColor); |
canvas->Restore(); |
+ |
canvas->Save(); |
- canvas->Translate({height_, height_ * 0.1}); |
- // TODO(acondor): Draw text IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_PERMANENT. |
+ canvas->Translate({height_ * (IsRTL() ? kBorderFactor |
+ : 2 * kBorderFactor + kIconSizeFactor), |
+ height_ * kBorderFactor}); |
+ canvas->DrawStringRectWithFlags( |
+ text, fonts, kForegroundColor, |
+ gfx::Rect(text_width, kTextHeightFactor * height_), text_flags); |
canvas->Restore(); |
} |
void InsecureContentPermanentTexture::SetSize() { |
- size_.SetSize(texture_size_, height_); |
+ size_.SetSize(width_, height_); |
} |
} // namespace vr_shell |