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 #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/macros.h" | 11 #include "base/macros.h" |
12 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 12 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 13 #include "components/security_state/core/security_state.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 class PointF; | 17 class PointF; |
17 class RenderText; | 18 class RenderText; |
18 } // namespace gfx | 19 } // namespace gfx |
19 | 20 |
20 namespace vr_shell { | 21 namespace vr_shell { |
21 | 22 |
| 23 class RenderTextWrapper; |
| 24 |
22 class UrlBarTexture : public UiTexture { | 25 class UrlBarTexture : public UiTexture { |
23 public: | 26 public: |
24 enum DrawFlags { | 27 enum DrawFlags { |
25 FLAG_BACK_HOVER = 1 << 0, | 28 FLAG_BACK_HOVER = 1 << 0, |
26 FLAG_BACK_DOWN = 1 << 1, | 29 FLAG_BACK_DOWN = 1 << 1, |
27 }; | 30 }; |
28 | 31 |
29 UrlBarTexture(); | 32 UrlBarTexture(); |
30 ~UrlBarTexture() override; | 33 ~UrlBarTexture() override; |
31 gfx::Size GetPreferredTextureSize(int width) const override; | 34 gfx::Size GetPreferredTextureSize(int width) const override; |
32 gfx::SizeF GetDrawnSize() const override; | 35 gfx::SizeF GetDrawnSize() const override; |
33 | 36 |
34 void SetURL(const GURL& gurl); | 37 void SetURL(const GURL& gurl); |
35 void SetSecurityLevel(int level); | 38 void SetSecurityLevel(security_state::SecurityLevel level); |
36 | 39 |
37 bool HitsBackButton(const gfx::PointF& position) const; | 40 bool HitsBackButton(const gfx::PointF& position) const; |
38 bool HitsUrlBar(const gfx::PointF& position) const; | 41 bool HitsUrlBar(const gfx::PointF& position) const; |
39 | 42 |
40 void SetHovered(bool hovered); | 43 void SetHovered(bool hovered); |
41 void SetPressed(bool pressed); | 44 void SetPressed(bool pressed); |
42 | 45 |
| 46 // Public for testability. |
| 47 static void ApplyUrlStyling(const base::string16& formatted_url, |
| 48 const url::Parsed& parsed, |
| 49 security_state::SecurityLevel security_level, |
| 50 vr_shell::RenderTextWrapper* render_text); |
| 51 |
43 private: | 52 private: |
44 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override; | 53 void Draw(SkCanvas* canvas, const gfx::Size& texture_size) override; |
45 float ToPixels(float meters) const; | 54 float ToPixels(float meters) const; |
46 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; | 55 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; |
| 56 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds); |
47 | 57 |
48 gfx::SizeF size_; | 58 gfx::SizeF size_; |
49 int security_level_; | |
50 bool hovered_ = false; | 59 bool hovered_ = false; |
51 bool pressed_ = false; | 60 bool pressed_ = false; |
| 61 |
52 GURL gurl_; | 62 GURL gurl_; |
| 63 security_state::SecurityLevel security_level_; |
| 64 |
| 65 std::unique_ptr<gfx::RenderText> url_render_text_; |
53 GURL last_drawn_gurl_; | 66 GURL last_drawn_gurl_; |
54 std::vector<std::unique_ptr<gfx::RenderText>> gurl_render_texts_; | 67 security_state::SecurityLevel last_drawn_security_level_; |
55 | 68 |
56 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); | 69 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); |
57 }; | 70 }; |
58 | 71 |
59 } // namespace vr_shell | 72 } // namespace vr_shell |
60 | 73 |
61 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ | 74 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ |
OLD | NEW |