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

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

Issue 2945173006: VR: Enforce LTR directionality on rendered URL text. (Closed)
Patch Set: Add a test to ensure that a malicious RTL URL cannot spoof a hostname. Created 3 years, 6 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" 14 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
14 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" 15 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h"
15 #include "components/security_state/core/security_state.h" 16 #include "components/security_state/core/security_state.h"
16 #include "ui/gfx/geometry/rect_f.h" 17 #include "ui/gfx/geometry/rect_f.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace gfx { 20 namespace gfx {
20 class PointF; 21 class PointF;
21 class RenderText; 22 class RenderText;
22 } // namespace gfx 23 } // namespace gfx
(...skipping 21 matching lines...) Expand all
44 void SetHistoryButtonsEnabled(bool can_go_back); 45 void SetHistoryButtonsEnabled(bool can_go_back);
45 void SetSecurityInfo(security_state::SecurityLevel level, bool malware); 46 void SetSecurityInfo(security_state::SecurityLevel level, bool malware);
46 47
47 bool HitsBackButton(const gfx::PointF& position) const; 48 bool HitsBackButton(const gfx::PointF& position) const;
48 bool HitsUrlBar(const gfx::PointF& position) const; 49 bool HitsUrlBar(const gfx::PointF& position) const;
49 bool HitsSecurityRegion(const gfx::PointF& position) const; 50 bool HitsSecurityRegion(const gfx::PointF& position) const;
50 51
51 void SetBackButtonHovered(bool hovered); 52 void SetBackButtonHovered(bool hovered);
52 void SetBackButtonPressed(bool pressed); 53 void SetBackButtonPressed(bool pressed);
53 54
54 // Public for testability. 55 protected:
55 static void ApplyUrlStyling(const base::string16& formatted_url, 56 static void ApplyUrlStyling(const base::string16& formatted_url,
56 const url::Parsed& parsed, 57 const url::Parsed& parsed,
57 security_state::SecurityLevel security_level, 58 security_state::SecurityLevel security_level,
58 vr_shell::RenderTextWrapper* render_text, 59 vr_shell::RenderTextWrapper* render_text,
59 const ColorScheme& color_scheme); 60 const ColorScheme& color_scheme);
60 61
62 std::unique_ptr<gfx::RenderText> url_render_text_;
63 base::string16 url_text_;
64
61 private: 65 private:
62 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override; 66 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override;
63 float ToPixels(float meters) const; 67 float ToPixels(float meters) const;
64 float ToMeters(float pixels) const; 68 float ToMeters(float pixels) const;
65 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; 69 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const;
66 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds); 70 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds);
67 void OnSetMode() override; 71 void OnSetMode() override;
68 SkColor GetLeftCornerColor() const; 72 SkColor GetLeftCornerColor() const;
69 73
70 gfx::SizeF size_; 74 gfx::SizeF size_;
71 bool back_hovered_ = false; 75 bool back_hovered_ = false;
72 bool back_pressed_ = false; 76 bool back_pressed_ = false;
73 bool can_go_back_ = false; 77 bool can_go_back_ = false;
74 78
75 GURL gurl_; 79 GURL gurl_;
76 security_state::SecurityLevel security_level_ = 80 security_state::SecurityLevel security_level_ =
77 security_state::SecurityLevel::NONE; 81 security_state::SecurityLevel::NONE;
78 bool malware_ = false; 82 bool malware_ = false;
79 83
80 std::unique_ptr<gfx::RenderText> url_render_text_;
81 GURL last_drawn_gurl_; 84 GURL last_drawn_gurl_;
82 bool has_back_button_ = true; 85 bool has_back_button_ = true;
83 bool has_security_chip_ = true; 86 bool has_security_chip_ = true;
84 security_state::SecurityLevel last_drawn_security_level_; 87 security_state::SecurityLevel last_drawn_security_level_;
85 base::Callback<void(UiUnsupportedMode)> failure_callback_; 88 base::Callback<void(UiUnsupportedMode)> failure_callback_;
86 gfx::RectF security_hit_region_ = gfx::RectF(0, 0, 0, 0); 89 gfx::RectF security_hit_region_ = gfx::RectF(0, 0, 0, 0);
87 gfx::RectF back_button_hit_region_ = gfx::RectF(0, 0, 0, 0); 90 gfx::RectF back_button_hit_region_ = gfx::RectF(0, 0, 0, 0);
88 91
89 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); 92 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture);
90 }; 93 };
91 94
92 } // namespace vr_shell 95 } // namespace vr_shell
93 96
94 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ 97 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698