Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/android/vr_shell/ui_elements/url_bar.cc

Issue 2885433003: VR: Implement Omnibox input targeting. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
(...skipping 17 matching lines...) Expand all
28 void UrlBar::UpdateTexture() { 28 void UrlBar::UpdateTexture() {
29 TexturedElement::UpdateTexture(); 29 TexturedElement::UpdateTexture();
30 last_update_time_ = last_begin_frame_time_; 30 last_update_time_ = last_begin_frame_time_;
31 } 31 }
32 32
33 UiTexture* UrlBar::GetTexture() const { 33 UiTexture* UrlBar::GetTexture() const {
34 return texture_.get(); 34 return texture_.get();
35 } 35 }
36 36
37 void UrlBar::OnHoverEnter(const gfx::PointF& position) { 37 void UrlBar::OnHoverEnter(const gfx::PointF& position) {
38 if (!texture_->SetDrawFlags(UrlBarTexture::FLAG_HOVER)) 38 OnStateUpdated(position);
39 return;
40 UpdateTexture();
41 } 39 }
42 40
43 void UrlBar::OnHoverLeave() { 41 void UrlBar::OnHoverLeave() {
44 if (!texture_->SetDrawFlags(0)) 42 OnStateUpdated(gfx::PointF(std::numeric_limits<float>::max(),
45 return; 43 std::numeric_limits<float>::max()));
46 UpdateTexture(); 44 }
45
46 void UrlBar::OnMove(const gfx::PointF& position) {
47 OnStateUpdated(position);
48 }
49
50 void UrlBar::OnButtonDown(const gfx::PointF& position) {
51 if (texture_->HitsBackButton(position))
52 down_ = true;
53 OnStateUpdated(position);
47 } 54 }
48 55
49 void UrlBar::OnButtonUp(const gfx::PointF& position) { 56 void UrlBar::OnButtonUp(const gfx::PointF& position) {
50 back_button_callback_.Run(); 57 down_ = false;
58 OnStateUpdated(position);
59 if (texture_->HitsBackButton(position))
60 back_button_callback_.Run();
61 }
62
63 bool UrlBar::HitTest(const gfx::PointF& position) const {
64 return texture_->HitsUrlBar(position) || texture_->HitsBackButton(position);
51 } 65 }
52 66
53 void UrlBar::OnBeginFrame(const base::TimeTicks& begin_frame_time) { 67 void UrlBar::OnBeginFrame(const base::TimeTicks& begin_frame_time) {
54 last_begin_frame_time_ = begin_frame_time; 68 last_begin_frame_time_ = begin_frame_time;
55 if (enabled_ && texture_->dirty()) { 69 if (enabled_ && texture_->dirty()) {
56 int64_t delta_ms = (begin_frame_time - last_update_time_).InMilliseconds(); 70 int64_t delta_ms = (begin_frame_time - last_update_time_).InMilliseconds();
57 if (delta_ms > kUpdateDelayMS) 71 if (delta_ms > kUpdateDelayMS)
58 UpdateTexture(); 72 UpdateTexture();
59 } 73 }
60 } 74 }
61 75
62 void UrlBar::SetEnabled(bool enabled) { 76 void UrlBar::SetEnabled(bool enabled) {
63 enabled_ = enabled; 77 enabled_ = enabled;
64 set_visible(enabled); 78 set_visible(enabled);
65 } 79 }
66 80
67 void UrlBar::SetURL(const GURL& gurl) { 81 void UrlBar::SetURL(const GURL& gurl) {
68 texture_->SetURL(gurl); 82 texture_->SetURL(gurl);
69 } 83 }
70 84
71 void UrlBar::SetSecurityLevel(int level) { 85 void UrlBar::SetSecurityLevel(int level) {
72 texture_->SetSecurityLevel(level); 86 texture_->SetSecurityLevel(level);
73 } 87 }
74 88
75 void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) { 89 void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) {
76 back_button_callback_ = callback; 90 back_button_callback_ = callback;
77 } 91 }
78 92
93 void UrlBar::OnStateUpdated(const gfx::PointF& position) {
94 bool hitting = texture_->HitsBackButton(position);
95 bool down = hitting ? down_ : false;
96
97 int flags = hitting ? UrlBarTexture::FLAG_BACK_HOVER : 0;
98 flags |= down ? UrlBarTexture::FLAG_BACK_DOWN : 0;
99 if (!texture_->SetDrawFlags(flags))
100 return;
101 UpdateTexture();
102 }
103
79 } // namespace vr_shell 104 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements/url_bar.h ('k') | chrome/browser/android/vr_shell/ui_scene_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698