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

Unified Diff: chrome/browser/android/vr_shell/toolbar_helper.cc

Issue 2960903002: VR: Use ToolbarModel to drive VR URL bar state. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/toolbar_helper.cc
diff --git a/chrome/browser/android/vr_shell/toolbar_helper.cc b/chrome/browser/android/vr_shell/toolbar_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8513bc3a089688fca2540d07fc69944d1c5f5cbe
--- /dev/null
+++ b/chrome/browser/android/vr_shell/toolbar_helper.cc
@@ -0,0 +1,39 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/toolbar_helper.h"
+
+#include "base/memory/ptr_util.h"
+#include "components/toolbar/toolbar_model_impl.h"
+
+class ToolbarModelDelegate;
+
+namespace vr_shell {
+
+namespace {
+constexpr int kMaxURLDisplayChars = 1024;
mthiesse 2017/06/28 00:27:08 Why 1024? Do we intend for the URL to never get tr
cjgrant 2017/06/28 15:14:34 ToolbarModelImpl can truncate, that's fine. The c
mthiesse 2017/06/28 15:46:41 1K just seems strange. I was wondering if we were
cjgrant 2017/06/28 19:41:51 Is it less strange than 32K that desktop uses? :)
mthiesse 2017/06/28 19:50:13 I'm just asking for a comment saying "This is arbi
cjgrant 2017/06/28 20:21:02 SGTM. Done.
+}
+
+ToolbarHelper::ToolbarHelper(UiInterface* ui, ToolbarModelDelegate* delegate)
+ : ui_(ui),
+ toolbar_model_(
+ base::MakeUnique<ToolbarModelImpl>(delegate, kMaxURLDisplayChars)) {}
+
+ToolbarHelper::~ToolbarHelper() {}
+
+void ToolbarHelper::Update() {
+ ToolbarState state;
+ state.gurl = toolbar_model_->GetURL();
+ state.security_level = toolbar_model_->GetSecurityLevel(true);
+ state.vector_icon = &(toolbar_model_->GetVectorIcon());
mthiesse 2017/06/28 00:27:08 nit: unnecessary parens
cjgrant 2017/06/28 15:14:33 Done.
+ state.secure_verbose_text = toolbar_model_->GetSecureVerboseText();
+ state.should_display_url = toolbar_model_->ShouldDisplayURL();
+
+ if (current_state_ == state)
+ return;
+ current_state_ = state;
+ ui_->SetToolbarState(state);
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698