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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/oobe_ui.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/chromeos/login/oobe_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" 44 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
45 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" 45 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
46 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" 46 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
47 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" 47 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h"
48 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" 48 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
49 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler .h" 49 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler .h"
50 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h" 50 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h"
51 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h" 51 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
52 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" 52 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
53 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" 53 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
54 #include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
54 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" 55 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
55 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 56 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
56 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h" 57 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h"
57 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler .h" 58 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler .h"
58 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" 59 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
59 #include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h" 60 #include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h"
60 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" 61 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
61 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" 62 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
62 #include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_pro vider.h" 63 #include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_pro vider.h"
63 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" 64 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
64 #include "chrome/browser/ui/webui/test_files_request_filter.h" 65 #include "chrome/browser/ui/webui/test_files_request_filter.h"
65 #include "chrome/browser/ui/webui/theme_source.h" 66 #include "chrome/browser/ui/webui/theme_source.h"
66 #include "chrome/common/chrome_constants.h" 67 #include "chrome/common/chrome_constants.h"
67 #include "chrome/common/chrome_switches.h" 68 #include "chrome/common/chrome_switches.h"
68 #include "chrome/common/pref_names.h" 69 #include "chrome/common/pref_names.h"
69 #include "chrome/common/url_constants.h" 70 #include "chrome/common/url_constants.h"
70 #include "chrome/grit/browser_resources.h" 71 #include "chrome/grit/browser_resources.h"
71 #include "chrome/grit/chrome_unscaled_resources.h" 72 #include "chrome/grit/chrome_unscaled_resources.h"
72 #include "chrome/grit/component_extension_resources.h" 73 #include "chrome/grit/component_extension_resources.h"
73 #include "chromeos/chromeos_switches.h" 74 #include "chromeos/chromeos_switches.h"
74 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 75 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
75 #include "components/prefs/pref_service.h" 76 #include "components/prefs/pref_service.h"
76 #include "content/public/browser/web_ui.h" 77 #include "content/public/browser/web_ui.h"
77 #include "content/public/browser/web_ui_data_source.h" 78 #include "content/public/browser/web_ui_data_source.h"
78 #include "content/public/common/content_switches.h" 79 #include "content/public/common/content_switches.h"
79 #include "ui/base/resource/resource_bundle.h" 80 #include "ui/base/resource/resource_bundle.h"
80 #include "ui/base/webui/web_ui_util.h" 81 #include "ui/base/webui/web_ui_util.h"
82 #include "ui/display/display.h"
83 #include "ui/events/devices/input_device.h"
84 #include "ui/events/devices/input_device_manager.h"
81 85
82 namespace chromeos { 86 namespace chromeos {
83 87
84 namespace { 88 namespace {
85 89
86 const char* kKnownDisplayTypes[] = {OobeUI::kOobeDisplay, 90 const char* kKnownDisplayTypes[] = {OobeUI::kOobeDisplay,
87 OobeUI::kLoginDisplay, 91 OobeUI::kLoginDisplay,
88 OobeUI::kLockDisplay, 92 OobeUI::kLockDisplay,
89 OobeUI::kUserAddingDisplay, 93 OobeUI::kUserAddingDisplay,
90 OobeUI::kAppLaunchSplashDisplay, 94 OobeUI::kAppLaunchSplashDisplay,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 std::string path = url.path().size() ? url.path().substr(1) : ""; 204 std::string path = url.path().size() ? url.path().substr(1) : "";
201 if (std::find(kKnownDisplayTypes, 205 if (std::find(kKnownDisplayTypes,
202 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), 206 kKnownDisplayTypes + arraysize(kKnownDisplayTypes),
203 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { 207 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) {
204 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; 208 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default.";
205 return OobeUI::kLoginDisplay; 209 return OobeUI::kLoginDisplay;
206 } 210 }
207 return path; 211 return path;
208 } 212 }
209 213
214 bool IsKeyboardConnected() {
215 auto& keyboards = ui::InputDeviceManager::GetInstance()->GetKeyboardDevices();
jdufault 2017/05/08 17:44:58 nit: auto type is not obvious
216 for (auto& keyboard : keyboards) {
217 if (keyboard.type == ui::INPUT_DEVICE_INTERNAL ||
218 keyboard.type == ui::INPUT_DEVICE_EXTERNAL) {
219 return true;
220 }
221 }
222
223 return false;
224 }
225
210 } // namespace 226 } // namespace
211 227
212 // static 228 // static
213 const char OobeUI::kOobeDisplay[] = "oobe"; 229 const char OobeUI::kOobeDisplay[] = "oobe";
214 const char OobeUI::kLoginDisplay[] = "login"; 230 const char OobeUI::kLoginDisplay[] = "login";
215 const char OobeUI::kLockDisplay[] = "lock"; 231 const char OobeUI::kLockDisplay[] = "lock";
216 const char OobeUI::kUserAddingDisplay[] = "user-adding"; 232 const char OobeUI::kUserAddingDisplay[] = "user-adding";
217 const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash"; 233 const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash";
218 const char OobeUI::kArcKioskSplashDisplay[] = "arc-kiosk-splash"; 234 const char OobeUI::kArcKioskSplashDisplay[] = "arc-kiosk-splash";
219 235
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 network_element::AddLocalizedStrings(html_source); 346 network_element::AddLocalizedStrings(html_source);
331 347
332 // Set up the chrome://userimage/ source. 348 // Set up the chrome://userimage/ source.
333 options::UserImageSource* user_image_source = 349 options::UserImageSource* user_image_source =
334 new options::UserImageSource(); 350 new options::UserImageSource();
335 content::URLDataSource::Add(profile, user_image_source); 351 content::URLDataSource::Add(profile, user_image_source);
336 352
337 // TabHelper is required for OOBE webui to make webview working on it. 353 // TabHelper is required for OOBE webui to make webview working on it.
338 content::WebContents* contents = web_ui->GetWebContents(); 354 content::WebContents* contents = web_ui->GetWebContents();
339 extensions::TabHelper::CreateForWebContents(contents); 355 extensions::TabHelper::CreateForWebContents(contents);
356
357 if (!IsKeyboardConnected() &&
358 base::CommandLine::ForCurrentProcess()->HasSwitch(
359 switches::kOobePreferTouchDisplay)) {
360 oobe_display_chooser_ = OobeDisplayChooser::CreateDefault();
361 }
340 } 362 }
341 363
342 OobeUI::~OobeUI() { 364 OobeUI::~OobeUI() {
343 network_dropdown_handler_->RemoveObserver(GetView<ErrorScreenHandler>()); 365 network_dropdown_handler_->RemoveObserver(GetView<ErrorScreenHandler>());
344 if (ash_util::IsRunningInMash()) { 366 if (ash_util::IsRunningInMash()) {
345 // TODO: Ash needs to expose screen dimming api. See 367 // TODO: Ash needs to expose screen dimming api. See
346 // http://crbug.com/646034. 368 // http://crbug.com/646034.
347 NOTIMPLEMENTED(); 369 NOTIMPLEMENTED();
348 } 370 }
349 } 371 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 575 }
554 576
555 bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) { 577 bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) {
556 if (!ready_) 578 if (!ready_)
557 ready_callbacks_.push_back(display_is_ready_callback); 579 ready_callbacks_.push_back(display_is_ready_callback);
558 return ready_; 580 return ready_;
559 } 581 }
560 582
561 void OobeUI::ShowOobeUI(bool show) { 583 void OobeUI::ShowOobeUI(bool show) {
562 core_handler_->ShowOobeUI(show); 584 core_handler_->ShowOobeUI(show);
585
586 if (show && oobe_display_chooser_) {
587 oobe_display_chooser_->TryToPlaceUIOnTouchDisplay();
jdufault 2017/05/08 17:44:58 nit: no {}
588 }
563 } 589 }
564 590
565 void OobeUI::ShowSigninScreen(const LoginScreenContext& context, 591 void OobeUI::ShowSigninScreen(const LoginScreenContext& context,
566 SigninScreenHandlerDelegate* delegate, 592 SigninScreenHandlerDelegate* delegate,
567 NativeWindowDelegate* native_window_delegate) { 593 NativeWindowDelegate* native_window_delegate) {
568 // Check our device mode. 594 // Check our device mode.
569 policy::BrowserPolicyConnectorChromeOS* connector = 595 policy::BrowserPolicyConnectorChromeOS* connector =
570 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 596 g_browser_process->platform_part()->browser_policy_connector_chromeos();
571 if (connector->GetDeviceMode() == policy::DEVICE_MODE_LEGACY_RETAIL_MODE) { 597 if (connector->GetDeviceMode() == policy::DEVICE_MODE_LEGACY_RETAIL_MODE) {
572 // If we're in legacy retail mode, the best thing we can do is launch the 598 // If we're in legacy retail mode, the best thing we can do is launch the
(...skipping 28 matching lines...) Expand all
601 if (oobe_ui_md_mode_ == 627 if (oobe_ui_md_mode_ ==
602 g_browser_process->local_state()->GetBoolean(prefs::kOobeMdMode)) { 628 g_browser_process->local_state()->GetBoolean(prefs::kOobeMdMode)) {
603 return; 629 return;
604 } 630 }
605 631
606 base::DictionaryValue localized_strings; 632 base::DictionaryValue localized_strings;
607 GetLocalizedStrings(&localized_strings); 633 GetLocalizedStrings(&localized_strings);
608 static_cast<CoreOobeView*>(core_handler_)->ReloadContent(localized_strings); 634 static_cast<CoreOobeView*>(core_handler_)->ReloadContent(localized_strings);
609 } 635 }
610 636
637 void OobeUI::OnDisplayAdded(const display::Display& new_display) {
638 if (oobe_display_chooser_) {
639 oobe_display_chooser_->OnDisplayAdded(new_display);
jdufault 2017/05/08 17:44:58 nit: no {}
640 }
641 }
642
611 } // namespace chromeos 643 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698