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

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

Issue 2885153004: React to primary display change instead of removal (Closed)
Patch Set: Remove the probably unnecessary safe guards for test shutdown 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 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 "ash/display/display_configuration_controller.h" 7 #include "ash/display/window_tree_host_manager.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "content/public/browser/browser_thread.h"
9 #include "ui/display/display.h" 10 #include "ui/display/display.h"
10 #include "ui/display/display_layout.h" 11 #include "ui/display/display_layout.h"
11 #include "ui/display/manager/display_manager.h" 12 #include "ui/display/manager/display_manager.h"
12 #include "ui/display/screen.h" 13 #include "ui/display/screen.h"
13 14
15 using content::BrowserThread;
16
14 namespace chromeos { 17 namespace chromeos {
15 18
16 namespace { 19 namespace {
17 20
18 bool TouchSupportAvailable(const display::Display& display) { 21 bool TouchSupportAvailable(const display::Display& display) {
19 return display.touch_support() == 22 return display.touch_support() ==
20 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE; 23 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE;
21 } 24 }
22 25
23 } // namespace 26 } // namespace
24 27
25 OobeDisplayChooser::OobeDisplayChooser() {} 28 OobeDisplayChooser::OobeDisplayChooser() : weak_ptr_factory_(this) {}
26 29
27 OobeDisplayChooser::~OobeDisplayChooser() {} 30 OobeDisplayChooser::~OobeDisplayChooser() {}
28 31
29 void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() { 32 void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() {
33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
34
35 if (weak_ptr_factory_.HasWeakPtrs())
achuithb 2017/05/23 20:14:22 What's going on here?
Felix Ekblom 2017/05/23 20:42:19 Addressed in the form of a code comment.
36 return;
37
30 display::Display primary_display = 38 display::Display primary_display =
31 display::Screen::GetScreen()->GetPrimaryDisplay(); 39 display::Screen::GetScreen()->GetPrimaryDisplay();
32 40
33 if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) 41 if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) {
34 MoveToTouchDisplay(); 42 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
43 base::Bind(&OobeDisplayChooser::MoveToTouchDisplay,
44 weak_ptr_factory_.GetWeakPtr()));
45 }
35 } 46 }
36 47
37 void OobeDisplayChooser::MoveToTouchDisplay() { 48 void OobeDisplayChooser::MoveToTouchDisplay() {
49 DCHECK_CURRENTLY_ON(BrowserThread::UI);
50
38 const display::Displays& displays = 51 const display::Displays& displays =
39 ash::Shell::Get()->display_manager()->active_only_display_list(); 52 ash::Shell::Get()->display_manager()->active_only_display_list();
40 53
41 if (displays.size() <= 1) 54 if (displays.size() <= 1)
42 return; 55 return;
43 56
44 for (const display::Display& display : displays) { 57 for (const display::Display& display : displays) {
45 if (TouchSupportAvailable(display)) { 58 if (TouchSupportAvailable(display)) {
46 ash::Shell::Get() 59 ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
47 ->display_configuration_controller() 60 display.id());
48 ->SetPrimaryDisplayId(display.id());
49 break; 61 break;
50 } 62 }
51 } 63 }
52 } 64 }
53 65
54 } // namespace chromeos 66 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698