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

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

Issue 2977293002: Revert of Remove confusing keyboard test & focus on input device (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/chromeos/login/oobe_display_chooser.h" 5 #include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
6 6
7 #include <stdint.h>
8
9 #include "ash/display/window_tree_host_manager.h" 7 #include "ash/display/window_tree_host_manager.h"
10 #include "ash/shell.h" 8 #include "ash/shell.h"
11 #include "base/stl_util.h"
12 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
13 #include "ui/display/display.h" 10 #include "ui/display/display.h"
11 #include "ui/display/display_layout.h"
14 #include "ui/display/manager/display_manager.h" 12 #include "ui/display/manager/display_manager.h"
15 #include "ui/display/screen.h" 13 #include "ui/display/screen.h"
16 #include "ui/events/devices/device_data_manager.h"
17 #include "ui/events/devices/touchscreen_device.h"
18 14
19 using content::BrowserThread; 15 using content::BrowserThread;
20 16
21 namespace chromeos { 17 namespace chromeos {
22 18
23 namespace { 19 namespace {
24 20
25 bool TouchSupportAvailable(const display::Display& display) { 21 bool TouchSupportAvailable(const display::Display& display) {
26 return display.touch_support() == 22 return display.touch_support() ==
27 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE; 23 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE;
28 } 24 }
29 25
30 // TODO(felixe): More context at crbug.com/738885
31 const uint16_t kDeviceIds[] = {0x0457, 0x266e};
32
33 } // namespace 26 } // namespace
34 27
35 OobeDisplayChooser::OobeDisplayChooser() : weak_ptr_factory_(this) {} 28 OobeDisplayChooser::OobeDisplayChooser() : weak_ptr_factory_(this) {}
36 29
37 OobeDisplayChooser::~OobeDisplayChooser() {} 30 OobeDisplayChooser::~OobeDisplayChooser() {}
38 31
39 void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() { 32 void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 34
42 // Don't (potentially) queue a second task to run MoveToTouchDisplay if one 35 // Don't (potentially) queue a second task to run MoveToTouchDisplay if one
43 // already is queued. 36 // already is queued.
44 if (weak_ptr_factory_.HasWeakPtrs()) 37 if (weak_ptr_factory_.HasWeakPtrs())
45 return; 38 return;
46 39
47 display::Display primary_display = 40 display::Display primary_display =
48 display::Screen::GetScreen()->GetPrimaryDisplay(); 41 display::Screen::GetScreen()->GetPrimaryDisplay();
49 42
50 if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) { 43 if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) {
51 BrowserThread::PostTask( 44 BrowserThread::PostTask(
52 BrowserThread::UI, FROM_HERE, 45 BrowserThread::UI, FROM_HERE,
53 base::BindOnce(&OobeDisplayChooser::MoveToTouchDisplay, 46 base::BindOnce(&OobeDisplayChooser::MoveToTouchDisplay,
54 weak_ptr_factory_.GetWeakPtr())); 47 weak_ptr_factory_.GetWeakPtr()));
55 } 48 }
56 } 49 }
57 50
58 void OobeDisplayChooser::MoveToTouchDisplay() { 51 void OobeDisplayChooser::MoveToTouchDisplay() {
59 DCHECK_CURRENTLY_ON(BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
60 53
61 const ui::DeviceDataManager* device_manager = 54 const display::Displays& displays =
62 ui::DeviceDataManager::GetInstance(); 55 ash::Shell::Get()->display_manager()->active_only_display_list();
63 for (const ui::TouchscreenDevice& device :
64 device_manager->GetTouchscreenDevices()) {
65 if (!base::ContainsValue(kDeviceIds, device.vendor_id))
66 continue;
67 56
68 int64_t display_id = 57 if (displays.size() <= 1)
69 device_manager->GetTargetDisplayForTouchDevice(device.id); 58 return;
70 if (display_id == display::kInvalidDisplayId)
71 continue;
72 59
73 ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId( 60 for (const display::Display& display : displays) {
74 display_id); 61 if (TouchSupportAvailable(display)) {
75 break; 62 ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
63 display.id());
64 break;
65 }
76 } 66 }
77 } 67 }
78 68
79 } // namespace chromeos 69 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698