| 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 "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 14 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 15 #include "chrome/browser/android/vr_shell/toolbar_state.h" |
| 16 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 15 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" | 17 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" |
| 16 #include "components/security_state/core/security_state.h" | 18 #include "components/security_state/core/security_state.h" |
| 17 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
| 18 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 19 | 21 |
| 20 namespace gfx { | 22 namespace gfx { |
| 21 class PointF; | 23 class PointF; |
| 22 class RenderText; | 24 class RenderText; |
| 23 } // namespace gfx | 25 } // namespace gfx |
| 24 | 26 |
| 25 namespace vr_shell { | 27 namespace vr_shell { |
| 26 | 28 |
| 27 class RenderTextWrapper; | 29 class RenderTextWrapper; |
| 28 struct ColorScheme; | 30 struct ColorScheme; |
| 29 | 31 |
| 30 class UrlBarTexture : public UiTexture { | 32 class UrlBarTexture : public UiTexture { |
| 31 public: | 33 public: |
| 32 enum DrawFlags { | 34 enum DrawFlags { |
| 33 FLAG_BACK_HOVER = 1 << 0, | 35 FLAG_BACK_HOVER = 1 << 0, |
| 34 FLAG_BACK_DOWN = 1 << 1, | 36 FLAG_BACK_DOWN = 1 << 1, |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 UrlBarTexture( | 39 UrlBarTexture( |
| 38 bool web_vr, | 40 bool web_vr, |
| 39 const base::Callback<void(UiUnsupportedMode)>& failure_callback); | 41 const base::Callback<void(UiUnsupportedMode)>& failure_callback); |
| 40 ~UrlBarTexture() override; | 42 ~UrlBarTexture() override; |
| 41 gfx::Size GetPreferredTextureSize(int width) const override; | 43 gfx::Size GetPreferredTextureSize(int width) const override; |
| 42 gfx::SizeF GetDrawnSize() const override; | 44 gfx::SizeF GetDrawnSize() const override; |
| 43 | 45 |
| 44 void SetURL(const GURL& gurl); | 46 void SetToolbarState(const ToolbarState& state); |
| 45 void SetHistoryButtonsEnabled(bool can_go_back); | 47 void SetHistoryButtonsEnabled(bool can_go_back); |
| 46 void SetSecurityInfo(security_state::SecurityLevel level, bool malware); | |
| 47 | 48 |
| 48 bool HitsBackButton(const gfx::PointF& position) const; | 49 bool HitsBackButton(const gfx::PointF& position) const; |
| 49 bool HitsUrlBar(const gfx::PointF& position) const; | 50 bool HitsUrlBar(const gfx::PointF& position) const; |
| 50 bool HitsSecurityRegion(const gfx::PointF& position) const; | 51 bool HitsSecurityRegion(const gfx::PointF& position) const; |
| 51 | 52 |
| 52 void SetBackButtonHovered(bool hovered); | 53 void SetBackButtonHovered(bool hovered); |
| 53 void SetBackButtonPressed(bool pressed); | 54 void SetBackButtonPressed(bool pressed); |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 static void ApplyUrlStyling(const base::string16& formatted_url, | 57 static void ApplyUrlStyling(const base::string16& formatted_url, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; | 70 bool HitsTransparentRegion(const gfx::PointF& meters, bool left) const; |
| 70 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds); | 71 void RenderUrl(const gfx::Size& texture_size, const gfx::Rect& bounds); |
| 71 void OnSetMode() override; | 72 void OnSetMode() override; |
| 72 SkColor GetLeftCornerColor() const; | 73 SkColor GetLeftCornerColor() const; |
| 73 | 74 |
| 74 gfx::SizeF size_; | 75 gfx::SizeF size_; |
| 75 bool back_hovered_ = false; | 76 bool back_hovered_ = false; |
| 76 bool back_pressed_ = false; | 77 bool back_pressed_ = false; |
| 77 bool can_go_back_ = false; | 78 bool can_go_back_ = false; |
| 78 | 79 |
| 79 GURL gurl_; | 80 ToolbarState state_; |
| 80 security_state::SecurityLevel security_level_ = | |
| 81 security_state::SecurityLevel::NONE; | |
| 82 bool malware_ = false; | |
| 83 | 81 |
| 84 GURL last_drawn_gurl_; | 82 GURL last_drawn_gurl_; |
| 85 bool has_back_button_ = true; | 83 bool has_back_button_ = true; |
| 86 bool has_security_chip_ = true; | 84 bool has_security_chip_ = true; |
| 87 security_state::SecurityLevel last_drawn_security_level_; | 85 security_state::SecurityLevel last_drawn_security_level_; |
| 88 base::Callback<void(UiUnsupportedMode)> failure_callback_; | 86 base::Callback<void(UiUnsupportedMode)> failure_callback_; |
| 89 gfx::RectF security_hit_region_ = gfx::RectF(0, 0, 0, 0); | 87 gfx::RectF security_hit_region_ = gfx::RectF(0, 0, 0, 0); |
| 90 gfx::RectF back_button_hit_region_ = gfx::RectF(0, 0, 0, 0); | 88 gfx::RectF back_button_hit_region_ = gfx::RectF(0, 0, 0, 0); |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); | 90 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 } // namespace vr_shell | 93 } // namespace vr_shell |
| 96 | 94 |
| 97 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ | 95 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ |
| OLD | NEW |