| 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 { |
| 19 return texture_.get(); |
| 20 } |
| 21 |
| 18 void UrlBar::OnHoverEnter() { | 22 void UrlBar::OnHoverEnter() { |
| 19 texture_->SetHover(true); | 23 texture_->SetHover(true); |
| 20 Update(); | 24 Update(); |
| 21 } | 25 } |
| 22 | 26 |
| 23 void UrlBar::OnHoverLeave() { | 27 void UrlBar::OnHoverLeave() { |
| 24 texture_->SetHover(false); | 28 texture_->SetHover(false); |
| 25 Update(); | 29 Update(); |
| 26 } | 30 } |
| 27 | 31 |
| 28 UiTexture* UrlBar::GetTexture() const { | 32 void UrlBar::OnButtonUp() { |
| 29 return texture_.get(); | 33 back_button_callback_.Run(); |
| 34 } |
| 35 |
| 36 void UrlBar::SetEnabled(bool enabled) { |
| 37 if (enabled && !enabled_) { |
| 38 Update(); |
| 39 } |
| 40 enabled_ = enabled; |
| 30 } | 41 } |
| 31 | 42 |
| 32 void UrlBar::SetURL(const GURL& gurl) { | 43 void UrlBar::SetURL(const GURL& gurl) { |
| 44 // TODO(cjgrant): See if we get duplicate security level numbers, despite the |
| 45 // source of this information being called "on changed". Also, consider |
| 46 // delaying the texture update slighly, such that back-to-back URL and |
| 47 // security state changes generate a single texture update instead of two. |
| 33 texture_->SetURL(gurl); | 48 texture_->SetURL(gurl); |
| 49 if (enabled_) |
| 50 Update(); |
| 51 } |
| 52 |
| 53 void UrlBar::SetSecurityLevel(int level) { |
| 54 texture_->SetSecurityLevel(level); |
| 55 if (enabled_) |
| 56 Update(); |
| 57 } |
| 58 |
| 59 void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) { |
| 60 back_button_callback_ = callback; |
| 34 } | 61 } |
| 35 | 62 |
| 36 } // namespace vr_shell | 63 } // namespace vr_shell |
| OLD | NEW |