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