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