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 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" | 8 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" |
9 | 9 |
10 namespace vr_shell { | 10 namespace vr_shell { |
11 | 11 |
12 UrlBar::UrlBar(int preferred_width) | 12 UrlBar::UrlBar(int preferred_width) |
13 : TexturedElement(preferred_width), | 13 : TexturedElement(preferred_width), |
14 texture_(base::MakeUnique<UrlBarTexture>()) {} | 14 texture_(base::MakeUnique<UrlBarTexture>()) {} |
15 | 15 |
16 UrlBar::~UrlBar() = default; | 16 UrlBar::~UrlBar() = default; |
17 | 17 |
18 UiTexture* UrlBar::GetTexture() const { | 18 UiTexture* UrlBar::GetTexture() const { |
19 return texture_.get(); | 19 return texture_.get(); |
20 } | 20 } |
21 | 21 |
22 void UrlBar::OnHoverEnter() { | 22 void UrlBar::OnHoverEnter(gfx::PointF position) { |
23 texture_->SetHover(true); | 23 if (!texture_->SetDrawFlags(UrlBarTexture::FLAG_HOVER)) |
| 24 return; |
24 Update(); | 25 Update(); |
25 } | 26 } |
26 | 27 |
27 void UrlBar::OnHoverLeave() { | 28 void UrlBar::OnHoverLeave() { |
28 texture_->SetHover(false); | 29 if (!texture_->SetDrawFlags(0)) |
| 30 return; |
29 Update(); | 31 Update(); |
30 } | 32 } |
31 | 33 |
32 void UrlBar::OnButtonUp() { | 34 void UrlBar::OnButtonUp(gfx::PointF position) { |
33 back_button_callback_.Run(); | 35 back_button_callback_.Run(); |
34 } | 36 } |
35 | 37 |
36 void UrlBar::SetEnabled(bool enabled) { | 38 void UrlBar::SetEnabled(bool enabled) { |
37 if (enabled && !enabled_) { | 39 if (enabled && !enabled_) { |
38 Update(); | 40 Update(); |
39 } | 41 } |
40 enabled_ = enabled; | 42 enabled_ = enabled; |
41 } | 43 } |
42 | 44 |
(...skipping 11 matching lines...) Expand all Loading... |
54 texture_->SetSecurityLevel(level); | 56 texture_->SetSecurityLevel(level); |
55 if (enabled_) | 57 if (enabled_) |
56 Update(); | 58 Update(); |
57 } | 59 } |
58 | 60 |
59 void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) { | 61 void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) { |
60 back_button_callback_ = callback; | 62 back_button_callback_ = callback; |
61 } | 63 } |
62 | 64 |
63 } // namespace vr_shell | 65 } // namespace vr_shell |
OLD | NEW |