OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/policy/display_rotation_default_handler.h" | 5 #include "chrome/browser/chromeos/policy/display_rotation_default_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
msw
2017/03/08 19:52:23
nit: remove
sky
2017/03/08 20:26:06
Done.
| |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "chromeos/settings/cros_settings_names.h" | 18 #include "chromeos/settings/cros_settings_names.h" |
19 #include "ui/display/manager/display_manager.h" | 19 #include "ui/display/manager/display_manager.h" |
20 | 20 |
21 namespace policy { | 21 namespace policy { |
22 | 22 |
23 DisplayRotationDefaultHandler::DisplayRotationDefaultHandler() { | 23 DisplayRotationDefaultHandler::DisplayRotationDefaultHandler() { |
24 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); | 24 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
25 ash::WmShell::Get()->AddShellObserver(this); | 25 ash::Shell::GetInstance()->AddShellObserver(this); |
26 settings_observer_ = chromeos::CrosSettings::Get()->AddSettingsObserver( | 26 settings_observer_ = chromeos::CrosSettings::Get()->AddSettingsObserver( |
27 chromeos::kDisplayRotationDefault, | 27 chromeos::kDisplayRotationDefault, |
28 base::Bind(&DisplayRotationDefaultHandler::OnCrosSettingsChanged, | 28 base::Bind(&DisplayRotationDefaultHandler::OnCrosSettingsChanged, |
29 base::Unretained(this))); | 29 base::Unretained(this))); |
30 } | 30 } |
31 | 31 |
32 DisplayRotationDefaultHandler::~DisplayRotationDefaultHandler() { | 32 DisplayRotationDefaultHandler::~DisplayRotationDefaultHandler() { |
33 } | 33 } |
34 | 34 |
35 void DisplayRotationDefaultHandler::OnShellInitialized() { | 35 void DisplayRotationDefaultHandler::OnShellInitialized() { |
36 UpdateFromCrosSettings(); | 36 UpdateFromCrosSettings(); |
37 RotateDisplays(); | 37 RotateDisplays(); |
38 } | 38 } |
39 | 39 |
40 void DisplayRotationDefaultHandler::OnDisplayConfigurationChanged() { | 40 void DisplayRotationDefaultHandler::OnDisplayConfigurationChanged() { |
41 RotateDisplays(); | 41 RotateDisplays(); |
42 } | 42 } |
43 | 43 |
44 void DisplayRotationDefaultHandler::OnWindowTreeHostManagerShutdown() { | 44 void DisplayRotationDefaultHandler::OnWindowTreeHostManagerShutdown() { |
45 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); | 45 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
46 ash::WmShell::Get()->RemoveShellObserver(this); | 46 ash::Shell::GetInstance()->RemoveShellObserver(this); |
47 settings_observer_.reset(); | 47 settings_observer_.reset(); |
48 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 48 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
49 } | 49 } |
50 | 50 |
51 void DisplayRotationDefaultHandler::OnCrosSettingsChanged() { | 51 void DisplayRotationDefaultHandler::OnCrosSettingsChanged() { |
52 if (!UpdateFromCrosSettings()) | 52 if (!UpdateFromCrosSettings()) |
53 return; | 53 return; |
54 // Policy changed, so reset all displays. | 54 // Policy changed, so reset all displays. |
55 rotated_displays_.clear(); | 55 rotated_displays_.clear(); |
56 RotateDisplays(); | 56 RotateDisplays(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 (new_policy_enabled && | 103 (new_policy_enabled && |
104 new_display_rotation_default != display_rotation_default_)) { | 104 new_display_rotation_default != display_rotation_default_)) { |
105 policy_enabled_ = new_policy_enabled; | 105 policy_enabled_ = new_policy_enabled; |
106 display_rotation_default_ = new_display_rotation_default; | 106 display_rotation_default_ = new_display_rotation_default; |
107 return true; | 107 return true; |
108 } | 108 } |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 } // namespace policy | 112 } // namespace policy |
OLD | NEW |