| 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 preferred_width, | 
|  | 23                const base::Callback<void(UiUnsupportedMode)>& failure_callback) | 
| 23     : TexturedElement(preferred_width), | 24     : TexturedElement(preferred_width), | 
| 24       texture_(base::MakeUnique<UrlBarTexture>()) {} | 25       texture_(base::MakeUnique<UrlBarTexture>(failure_callback)) {} | 
| 25 | 26 | 
| 26 UrlBar::~UrlBar() = default; | 27 UrlBar::~UrlBar() = default; | 
| 27 | 28 | 
| 28 void UrlBar::UpdateTexture() { | 29 void UrlBar::UpdateTexture() { | 
| 29   TexturedElement::UpdateTexture(); | 30   TexturedElement::UpdateTexture(); | 
| 30   last_update_time_ = last_begin_frame_time_; | 31   last_update_time_ = last_begin_frame_time_; | 
| 31 } | 32 } | 
| 32 | 33 | 
| 33 UiTexture* UrlBar::GetTexture() const { | 34 UiTexture* UrlBar::GetTexture() const { | 
| 34   return texture_.get(); | 35   return texture_.get(); | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93 void UrlBar::OnStateUpdated(const gfx::PointF& position) { | 94 void UrlBar::OnStateUpdated(const gfx::PointF& position) { | 
| 94   const bool hovered = texture_->HitsBackButton(position); | 95   const bool hovered = texture_->HitsBackButton(position); | 
| 95   const bool pressed = hovered ? down_ : false; | 96   const bool pressed = hovered ? down_ : false; | 
| 96 | 97 | 
| 97   texture_->SetHovered(hovered); | 98   texture_->SetHovered(hovered); | 
| 98   texture_->SetPressed(pressed); | 99   texture_->SetPressed(pressed); | 
| 99   UpdateTexture(); | 100   UpdateTexture(); | 
| 100 } | 101 } | 
| 101 | 102 | 
| 102 }  // namespace vr_shell | 103 }  // namespace vr_shell | 
| OLD | NEW | 
|---|