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

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

Issue 2946523002: VR: Support security chip text on URL bar. (Closed)
Patch Set: 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 "chrome/browser/android/vr_shell/textures/ui_texture.h" 13 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
14 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" 14 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h"
15 #include "components/security_state/core/security_state.h" 15 #include "components/security_state/core/security_state.h"
16 #include "ui/gfx/geometry/rect_f.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 class PointF; 20 class PointF;
20 class RenderText; 21 class RenderText;
21 } // namespace gfx 22 } // namespace gfx
22 23
23 namespace vr_shell { 24 namespace vr_shell {
24 25
25 class RenderTextWrapper; 26 class RenderTextWrapper;
26 struct ColorScheme; 27 struct ColorScheme;
27 28
28 class UrlBarTexture : public UiTexture { 29 class UrlBarTexture : public UiTexture {
29 public: 30 public:
30 enum DrawFlags { 31 enum DrawFlags {
31 FLAG_BACK_HOVER = 1 << 0, 32 FLAG_BACK_HOVER = 1 << 0,
32 FLAG_BACK_DOWN = 1 << 1, 33 FLAG_BACK_DOWN = 1 << 1,
33 }; 34 };
34 35
35 UrlBarTexture( 36 UrlBarTexture(
36 bool web_vr, 37 bool web_vr,
37 const base::Callback<void(UiUnsupportedMode)>& failure_callback); 38 const base::Callback<void(UiUnsupportedMode)>& failure_callback);
38 ~UrlBarTexture() override; 39 ~UrlBarTexture() override;
39 gfx::Size GetPreferredTextureSize(int width) const override; 40 gfx::Size GetPreferredTextureSize(int width) const override;
40 gfx::SizeF GetDrawnSize() const override; 41 gfx::SizeF GetDrawnSize() const override;
41 42
42 void SetURL(const GURL& gurl); 43 void SetURL(const GURL& gurl);
43 void SetHistoryButtonsEnabled(bool can_go_back); 44 void SetHistoryButtonsEnabled(bool can_go_back);
44 void SetSecurityLevel(security_state::SecurityLevel level); 45 void SetSecurityInfo(security_state::SecurityLevel level, bool malware);
45 46
46 bool HitsBackButton(const gfx::PointF& position) const; 47 bool HitsBackButton(const gfx::PointF& position) const;
47 bool HitsUrlBar(const gfx::PointF& position) const; 48 bool HitsUrlBar(const gfx::PointF& position) const;
48 bool HitsSecurityIcon(const gfx::PointF& position) const; 49 bool HitsSecurityRegion(const gfx::PointF& position) const;
49 50
50 void SetBackButtonHovered(bool hovered); 51 void SetBackButtonHovered(bool hovered);
51 void SetBackButtonPressed(bool pressed); 52 void SetBackButtonPressed(bool pressed);
52 53
53 // Public for testability. 54 // Public for testability.
54 static void ApplyUrlStyling(const base::string16& formatted_url, 55 static void ApplyUrlStyling(const base::string16& formatted_url,
55 const url::Parsed& parsed, 56 const url::Parsed& parsed,
56 security_state::SecurityLevel security_level, 57 security_state::SecurityLevel security_level,
57 vr_shell::RenderTextWrapper* render_text, 58 vr_shell::RenderTextWrapper* render_text,
58 const ColorScheme& color_scheme); 59 const ColorScheme& color_scheme);
59 60
60 private: 61 private:
61 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override; 62 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override;
62 float ToPixels(float meters) const; 63 float ToPixels(float meters) const;
64 float ToMeters(float pixels) const;
63 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; 65 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const;
64 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds); 66 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds);
65 void OnSetMode() override; 67 void OnSetMode() override;
66 gfx::PointF SecurityIconPositionMeters() const;
67 gfx::PointF UrlBarPositionMeters() const; 68 gfx::PointF UrlBarPositionMeters() const;
ymalik 2017/06/19 14:33:05 This is no longer used.
cjgrant 2017/06/19 15:39:39 Done.
68 SkColor GetLeftCornerColor() const; 69 SkColor GetLeftCornerColor() const;
69 70
70 gfx::SizeF size_; 71 gfx::SizeF size_;
71 bool back_hovered_ = false; 72 bool back_hovered_ = false;
72 bool back_pressed_ = false; 73 bool back_pressed_ = false;
73 bool can_go_back_ = false; 74 bool can_go_back_ = false;
74 75
75 GURL gurl_; 76 GURL gurl_;
76 security_state::SecurityLevel security_level_; 77 security_state::SecurityLevel security_level_ =
78 security_state::SecurityLevel::NONE;
79 bool malware_ = false;
77 80
78 std::unique_ptr<gfx::RenderText> url_render_text_; 81 std::unique_ptr<gfx::RenderText> url_render_text_;
79 GURL last_drawn_gurl_; 82 GURL last_drawn_gurl_;
80 bool has_back_button_ = true; 83 bool has_back_button_ = true;
81 security_state::SecurityLevel last_drawn_security_level_; 84 security_state::SecurityLevel last_drawn_security_level_;
82 base::Callback<void(UiUnsupportedMode)> failure_callback_; 85 base::Callback<void(UiUnsupportedMode)> failure_callback_;
86 gfx::RectF security_hit_region_ = gfx::RectF(0, 0, 0, 0);
ymalik 2017/06/19 14:33:05 Should we do a similar thing for the back button f
cjgrant 2017/06/19 15:39:39 Done. No problem with HitsTransparentRegion. I t
83 87
84 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); 88 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture);
85 }; 89 };
86 90
87 } // namespace vr_shell 91 } // namespace vr_shell
88 92
89 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ 93 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698