| 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/macros.h" | 12 #include "base/macros.h" |
| 12 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 13 #include "chrome/browser/android/vr_shell/textures/ui_texture.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 explicit UrlBarTexture(const base::Callback<void()>& failure_callback); |
| 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(int 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; |
| 47 | 48 |
| 48 gfx::SizeF size_; | 49 gfx::SizeF size_; |
| 49 int security_level_; | 50 int security_level_; |
| 50 bool hovered_ = false; | 51 bool hovered_ = false; |
| 51 bool pressed_ = false; | 52 bool pressed_ = false; |
| 52 GURL gurl_; | 53 GURL gurl_; |
| 53 GURL last_drawn_gurl_; | 54 GURL last_drawn_gurl_; |
| 54 std::vector<std::unique_ptr<gfx::RenderText>> gurl_render_texts_; | 55 std::vector<std::unique_ptr<gfx::RenderText>> gurl_render_texts_; |
| 56 base::Callback<void()> failure_callback_; |
| 55 | 57 |
| 56 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); | 58 DISALLOW_COPY_AND_ASSIGN(UrlBarTexture); |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 } // namespace vr_shell | 61 } // namespace vr_shell |
| 60 | 62 |
| 61 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ | 63 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_URL_BAR_TEXTURE_H_ |
| OLD | NEW |