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

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

Issue 2946523002: VR: Support security chip text on URL bar. (Closed)
Patch Set: Address comments. Created 3 years, 6 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 std::numeric_limits<float>::max())); 48 std::numeric_limits<float>::max()));
49 } 49 }
50 50
51 void UrlBar::OnMove(const gfx::PointF& position) { 51 void UrlBar::OnMove(const gfx::PointF& position) {
52 OnStateUpdated(position); 52 OnStateUpdated(position);
53 } 53 }
54 54
55 void UrlBar::OnButtonDown(const gfx::PointF& position) { 55 void UrlBar::OnButtonDown(const gfx::PointF& position) {
56 if (texture_->HitsBackButton(position)) 56 if (texture_->HitsBackButton(position))
57 down_ = true; 57 down_ = true;
58 else if (texture_->HitsSecurityIcon(position)) 58 else if (texture_->HitsSecurityRegion(position))
59 security_icon_down_ = true; 59 security_region_down_ = true;
60 OnStateUpdated(position); 60 OnStateUpdated(position);
61 } 61 }
62 62
63 void UrlBar::OnButtonUp(const gfx::PointF& position) { 63 void UrlBar::OnButtonUp(const gfx::PointF& position) {
64 down_ = false; 64 down_ = false;
65 OnStateUpdated(position); 65 OnStateUpdated(position);
66 if (can_go_back_ && texture_->HitsBackButton(position)) 66 if (can_go_back_ && texture_->HitsBackButton(position))
67 back_button_callback_.Run(); 67 back_button_callback_.Run();
68 else if (security_icon_down_ && texture_->HitsSecurityIcon(position)) 68 else if (security_region_down_ && texture_->HitsSecurityRegion(position))
69 security_icon_callback_.Run(); 69 security_icon_callback_.Run();
70 security_icon_down_ = false; 70 security_region_down_ = false;
71 } 71 }
72 72
73 bool UrlBar::HitTest(const gfx::PointF& position) const { 73 bool UrlBar::HitTest(const gfx::PointF& position) const {
74 return texture_->HitsUrlBar(position) || texture_->HitsBackButton(position); 74 return texture_->HitsUrlBar(position) || texture_->HitsBackButton(position);
75 } 75 }
76 76
77 void UrlBar::OnBeginFrame(const base::TimeTicks& begin_frame_time) { 77 void UrlBar::OnBeginFrame(const base::TimeTicks& begin_frame_time) {
78 last_begin_frame_time_ = begin_frame_time; 78 last_begin_frame_time_ = begin_frame_time;
79 if (enabled_ && texture_->dirty()) { 79 if (enabled_ && texture_->dirty()) {
80 int64_t delta_ms = (begin_frame_time - last_update_time_).InMilliseconds(); 80 int64_t delta_ms = (begin_frame_time - last_update_time_).InMilliseconds();
81 if (delta_ms > kUpdateDelayMS) 81 if (delta_ms > kUpdateDelayMS)
82 UpdateTexture(); 82 UpdateTexture();
83 } 83 }
84 } 84 }
85 85
86 void UrlBar::SetEnabled(bool enabled) { 86 void UrlBar::SetEnabled(bool enabled) {
87 enabled_ = enabled; 87 enabled_ = enabled;
88 set_visible(enabled); 88 set_visible(enabled);
89 } 89 }
90 90
91 void UrlBar::SetURL(const GURL& gurl) { 91 void UrlBar::SetURL(const GURL& gurl) {
92 texture_->SetURL(gurl); 92 texture_->SetURL(gurl);
93 } 93 }
94 94
95 void UrlBar::SetHistoryButtonsEnabled(bool can_go_back) { 95 void UrlBar::SetHistoryButtonsEnabled(bool can_go_back) {
96 can_go_back_ = can_go_back; 96 can_go_back_ = can_go_back;
97 texture_->SetHistoryButtonsEnabled(can_go_back_); 97 texture_->SetHistoryButtonsEnabled(can_go_back_);
98 } 98 }
99 99
100 void UrlBar::SetSecurityLevel(security_state::SecurityLevel level) { 100 void UrlBar::SetSecurityInfo(security_state::SecurityLevel level,
101 texture_->SetSecurityLevel(level); 101 bool malware) {
102 texture_->SetSecurityInfo(level, malware);
102 } 103 }
103 104
104 void UrlBar::OnStateUpdated(const gfx::PointF& position) { 105 void UrlBar::OnStateUpdated(const gfx::PointF& position) {
105 const bool hovered = texture_->HitsBackButton(position); 106 const bool hovered = texture_->HitsBackButton(position);
106 const bool pressed = hovered ? down_ : false; 107 const bool pressed = hovered ? down_ : false;
107 108
108 texture_->SetBackButtonHovered(hovered); 109 texture_->SetBackButtonHovered(hovered);
109 texture_->SetBackButtonPressed(pressed); 110 texture_->SetBackButtonPressed(pressed);
110 UpdateTexture(); 111 UpdateTexture();
111 } 112 }
112 113
113 } // namespace vr_shell 114 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698