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

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

Issue 2902393002: [vr] Bail on unhandled code points. (Closed)
Patch Set: histograms Created 3 years, 7 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
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/url_bar_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "cc/paint/skia_paint_canvas.h" 8 #include "cc/paint/skia_paint_canvas.h"
9 #include "components/security_state/core/security_state.h" 9 #include "components/security_state/core/security_state.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return kWarningIconColor; 77 return kWarningIconColor;
78 } 78 }
79 } 79 }
80 80
81 gfx::PointF percentToMeters(const gfx::PointF& percent) { 81 gfx::PointF percentToMeters(const gfx::PointF& percent) {
82 return gfx::PointF(percent.x() * kWidth, percent.y() * kHeight); 82 return gfx::PointF(percent.x() * kWidth, percent.y() * kHeight);
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 UrlBarTexture::UrlBarTexture() : security_level_(SecurityLevel::DANGEROUS) {} 87 UrlBarTexture::UrlBarTexture(
88 const base::Callback<void(UiUnsupportedMode)>& failure_callback)
89 : security_level_(SecurityLevel::DANGEROUS),
90 failure_callback_(failure_callback) {}
88 91
89 UrlBarTexture::~UrlBarTexture() = default; 92 UrlBarTexture::~UrlBarTexture() = default;
90 93
91 void UrlBarTexture::SetURL(const GURL& gurl) { 94 void UrlBarTexture::SetURL(const GURL& gurl) {
92 if (gurl_ != gurl) 95 if (gurl_ != gurl)
93 set_dirty(); 96 set_dirty();
94 gurl_ = gurl; 97 gurl_ = gurl;
95 } 98 }
96 99
97 void UrlBarTexture::SetSecurityLevel(int level) { 100 void UrlBarTexture::SetSecurityLevel(int level) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 206
204 if (!gurl_.is_empty()) { 207 if (!gurl_.is_empty()) {
205 if (last_drawn_gurl_ != gurl_) { 208 if (last_drawn_gurl_ != gurl_) {
206 // Draw text based on pixel sizes rather than meters, for correct font 209 // Draw text based on pixel sizes rather than meters, for correct font
207 // sizing. 210 // sizing.
208 int pixel_font_height = texture_size.height() * kFontHeight / kHeight; 211 int pixel_font_height = texture_size.height() * kFontHeight / kHeight;
209 float url_x = kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth; 212 float url_x = kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth;
210 float url_width = kWidth - url_x - kUrlRightMargin; 213 float url_width = kWidth - url_x - kUrlRightMargin;
211 gfx::Rect text_bounds(ToPixels(url_x), 0, ToPixels(url_width), 214 gfx::Rect text_bounds(ToPixels(url_x), 0, ToPixels(url_width),
212 ToPixels(kHeight)); 215 ToPixels(kHeight));
216 base::string16 text = base::UTF8ToUTF16(gurl_.spec());
217 if (!CheckFontList(pixel_font_height, text))
218 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint);
213 gurl_render_texts_ = PrepareDrawStringRect( 219 gurl_render_texts_ = PrepareDrawStringRect(
cjgrant 2017/05/26 18:52:00 This needs some non-trivial rebasing, as we don't
Ian Vollick 2017/05/26 20:20:28 Done. Also, since we're now using GetFontList, I w
214 base::UTF8ToUTF16(gurl_.spec()), 220 text, GetDefaultFontList(pixel_font_height), SK_ColorBLACK,
215 GetDefaultFontList(pixel_font_height), SK_ColorBLACK, &text_bounds, 221 &text_bounds, kTextAlignmentLeft, kWrappingBehaviorNoWrap);
216 kTextAlignmentLeft, kWrappingBehaviorNoWrap);
217 last_drawn_gurl_ = gurl_; 222 last_drawn_gurl_ = gurl_;
218 } 223 }
219 for (auto& render_text : gurl_render_texts_) 224 for (auto& render_text : gurl_render_texts_)
220 render_text->Draw(&gfx_canvas); 225 render_text->Draw(&gfx_canvas);
221 } 226 }
222 } 227 }
223 228
224 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 229 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
225 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 230 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
226 } 231 }
227 232
228 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 233 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
229 return size_; 234 return size_;
230 } 235 }
231 236
232 } // namespace vr_shell 237 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698