| 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 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // We will often get spammed with many updates. We will also get security and | 14 // We will often get spammed with many updates. We will also get security and |
| 15 // url updates out of sync. To address both these problems, we will hang onto | 15 // url updates out of sync. To address both these problems, we will hang onto |
| 16 // dirtyness for |kUpdateDelay| before updating our texture to reduce visual | 16 // dirtyness for |kUpdateDelay| before updating our texture to reduce visual |
| 17 // churn. | 17 // churn. |
| 18 constexpr int64_t kUpdateDelayMS = 50; | 18 constexpr int64_t kUpdateDelayMS = 50; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 UrlBar::UrlBar(int preferred_width, | 22 UrlBar::UrlBar(int id, |
| 23 int preferred_width, |
| 23 const base::Callback<void()>& back_button_callback, | 24 const base::Callback<void()>& back_button_callback, |
| 24 const base::Callback<void()>& security_icon_callback, | 25 const base::Callback<void()>& security_icon_callback, |
| 25 const base::Callback<void(UiUnsupportedMode)>& failure_callback) | 26 const base::Callback<void(UiUnsupportedMode)>& failure_callback) |
| 26 : TexturedElement(preferred_width), | 27 : TexturedElement(id, preferred_width), |
| 27 texture_(base::MakeUnique<UrlBarTexture>(false, failure_callback)), | 28 texture_(base::MakeUnique<UrlBarTexture>(false, failure_callback)), |
| 28 back_button_callback_(back_button_callback), | 29 back_button_callback_(back_button_callback), |
| 29 security_icon_callback_(security_icon_callback) {} | 30 security_icon_callback_(security_icon_callback) {} |
| 30 | 31 |
| 31 UrlBar::~UrlBar() = default; | 32 UrlBar::~UrlBar() = default; |
| 32 | 33 |
| 33 void UrlBar::UpdateTexture() { | 34 void UrlBar::UpdateTexture() { |
| 34 TexturedElement::UpdateTexture(); | 35 TexturedElement::UpdateTexture(); |
| 35 last_update_time_ = last_begin_frame_time_; | 36 last_update_time_ = last_begin_frame_time_; |
| 36 } | 37 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void UrlBar::OnStateUpdated(const gfx::PointF& position) { | 101 void UrlBar::OnStateUpdated(const gfx::PointF& position) { |
| 101 const bool hovered = texture_->HitsBackButton(position); | 102 const bool hovered = texture_->HitsBackButton(position); |
| 102 const bool pressed = hovered ? down_ : false; | 103 const bool pressed = hovered ? down_ : false; |
| 103 | 104 |
| 104 texture_->SetBackButtonHovered(hovered); | 105 texture_->SetBackButtonHovered(hovered); |
| 105 texture_->SetBackButtonPressed(pressed); | 106 texture_->SetBackButtonPressed(pressed); |
| 106 UpdateTexture(); | 107 UpdateTexture(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace vr_shell | 110 } // namespace vr_shell |
| OLD | NEW |