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

Unified Diff: chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc

Issue 2865003003: Put OOBE UI on touch display if no keyboard detected (Closed)
Patch Set: 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/ui/webui/chromeos/login/oobe_display_chooser.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3792498485e6a76290ad05d7f458ddcea88c578f
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 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/ui/webui/chromeos/login/oobe_display_chooser.h"
+
+#include "ash/display/display_configuration_controller.h"
+#include "ash/shell.h"
+#include "ui/display/display.h"
+#include "ui/display/manager/display_manager.h"
+#include "ui/display/screen.h"
+
+namespace chromeos {
+
+namespace {
+
+bool TouchSupportAvailable(const display::Display& display) {
+ return display.touch_support() ==
+ display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE;
+}
+
+} // namespace
+
+// static
+std::unique_ptr<OobeDisplayChooser> OobeDisplayChooser::CreateDefault() {
+ return base::MakeUnique<OobeDisplayChooser>(
+ ash::Shell::Get()->display_configuration_controller(),
+ ash::Shell::Get()->display_manager(), display::Screen::GetScreen());
+}
+
+OobeDisplayChooser::OobeDisplayChooser(
+ ash::DisplayConfigurationController* configuration_controller,
+ display::DisplayManager* display_manager,
+ display::Screen* screen)
+ : configuration_controller_(configuration_controller),
+ display_manager_(display_manager),
+ screen_(screen) {}
oshima 2017/05/09 05:58:45 Just getting these from Shell in the methods below
Felix Ekblom 2017/05/09 08:54:50 Yes, fixed now. I was hoping to mock them for the
+
+OobeDisplayChooser::~OobeDisplayChooser() {}
+
+void OobeDisplayChooser::TryToPlaceUIOnTouchDisplay() {
jdufault 2017/05/08 17:44:57 nit: UI -> Ui
+ auto primary_display = screen_->GetPrimaryDisplay();
jdufault 2017/05/08 17:44:58 nit: auto type is not obvious
+ if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) {
+ MoveToTouchDisplay();
jdufault 2017/05/08 17:44:58 nit: drop {}
+ }
+}
+
+void OobeDisplayChooser::OnDisplayAdded(const display::Display& new_display) {
jdufault 2017/05/08 17:44:57 |new_display| is never used, so remove this functi
+ TryToPlaceUIOnTouchDisplay();
+}
+
+void OobeDisplayChooser::MoveToTouchDisplay() {
+ auto& displays = display_manager_->active_only_display_list();
jdufault 2017/05/08 17:44:57 nit: auto type is not obvious
+
+ if (displays.size() <= 1) {
jdufault 2017/05/08 17:44:57 nit: drop {}
+ return;
+ }
+
+ for (auto& display : displays) {
+ if (TouchSupportAvailable(display)) {
+ configuration_controller_->SetPrimaryDisplayId(display.id());
+ return;
jdufault 2017/05/08 17:44:57 break?
+ }
+ }
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698