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

Unified Diff: chrome/browser/android/vr_shell/ui_elements/url_bar.cc

Issue 2913633002: [vr] Clicking on the security icon should prompt the user to bail out of VR (Closed)
Patch Set: added tests + cjgrant's comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/ui_elements/url_bar.cc
diff --git a/chrome/browser/android/vr_shell/ui_elements/url_bar.cc b/chrome/browser/android/vr_shell/ui_elements/url_bar.cc
index 72dcf1c081b9628a2aace64da7ef94d1d12c7797..e64bfd25c0acf6d11b8857ad6ac70f2c4a846732 100644
--- a/chrome/browser/android/vr_shell/ui_elements/url_bar.cc
+++ b/chrome/browser/android/vr_shell/ui_elements/url_bar.cc
@@ -20,9 +20,13 @@ constexpr int64_t kUpdateDelayMS = 50;
} // namespace
UrlBar::UrlBar(int preferred_width,
+ const base::Callback<void()>& back_button_callback,
+ const base::Callback<void()>& security_icon_callback,
const base::Callback<void(UiUnsupportedMode)>& failure_callback)
: TexturedElement(preferred_width),
- texture_(base::MakeUnique<UrlBarTexture>(failure_callback)) {}
+ texture_(base::MakeUnique<UrlBarTexture>(failure_callback)),
+ back_button_callback_(back_button_callback),
+ security_icon_callback_(security_icon_callback) {}
UrlBar::~UrlBar() = default;
@@ -51,6 +55,8 @@ void UrlBar::OnMove(const gfx::PointF& position) {
void UrlBar::OnButtonDown(const gfx::PointF& position) {
if (texture_->HitsBackButton(position))
down_ = true;
+ if (texture_->HitsSecurityIcon(position))
+ security_icon_down_ = true;
OnStateUpdated(position);
}
@@ -59,6 +65,10 @@ void UrlBar::OnButtonUp(const gfx::PointF& position) {
OnStateUpdated(position);
if (texture_->HitsBackButton(position))
back_button_callback_.Run();
+ else if (security_icon_down_ && texture_->HitsSecurityIcon(position)) {
+ security_icon_callback_.Run();
+ }
+ security_icon_down_ = false;
}
bool UrlBar::HitTest(const gfx::PointF& position) const {
@@ -91,10 +101,6 @@ void UrlBar::SetSecurityLevel(security_state::SecurityLevel level) {
texture_->SetSecurityLevel(level);
}
-void UrlBar::SetBackButtonCallback(const base::Callback<void()>& callback) {
- back_button_callback_ = callback;
-}
-
void UrlBar::OnStateUpdated(const gfx::PointF& position) {
const bool hovered = texture_->HitsBackButton(position);
const bool pressed = hovered ? down_ : false;

Powered by Google App Engine
This is Rietveld 408576698