OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/display/screen_manager_ozone_internal.h" | 5 #include "services/ui/display/screen_manager_ozone_internal.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "chrome/common/pref_names.h" | |
13 #include "chromeos/system/devicemode.h" | 14 #include "chromeos/system/devicemode.h" |
14 #include "mojo/public/cpp/bindings/strong_binding.h" | 15 #include "mojo/public/cpp/bindings/strong_binding.h" |
15 #include "services/service_manager/public/cpp/interface_registry.h" | 16 #include "services/service_manager/public/cpp/interface_registry.h" |
16 #include "services/ui/display/output_protection.h" | 17 #include "services/ui/display/output_protection.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/display/manager/chromeos/display_change_observer.h" | 19 #include "ui/display/manager/chromeos/display_change_observer.h" |
19 #include "ui/display/manager/chromeos/touch_transform_controller.h" | 20 #include "ui/display/manager/chromeos/touch_transform_controller.h" |
20 #include "ui/display/manager/display_layout_store.h" | 21 #include "ui/display/manager/display_layout_store.h" |
21 #include "ui/display/manager/display_manager_utilities.h" | 22 #include "ui/display/manager/display_manager_utilities.h" |
22 #include "ui/display/screen.h" | 23 #include "ui/display/screen.h" |
23 #include "ui/display/screen_base.h" | 24 #include "ui/display/screen_base.h" |
24 #include "ui/display/types/display_snapshot.h" | 25 #include "ui/display/types/display_snapshot.h" |
25 #include "ui/display/types/fake_display_controller.h" | 26 #include "ui/display/types/fake_display_controller.h" |
26 #include "ui/display/types/native_display_delegate.h" | 27 #include "ui/display/types/native_display_delegate.h" |
27 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
28 #include "ui/ozone/public/ozone_platform.h" | 29 #include "ui/ozone/public/ozone_platform.h" |
29 | 30 |
31 #include "ui/display/manager/display_preferences.h" | |
32 | |
33 #include "components/prefs/pref_store.h" | |
34 #include "services/preferences/public/interfaces/preferences.mojom.h" | |
35 | |
36 #include "base/values.h" | |
37 | |
30 namespace display { | 38 namespace display { |
31 namespace { | 39 namespace { |
32 | 40 |
33 // Needed for DisplayConfigurator::ForceInitialConfigure. | 41 // Needed for DisplayConfigurator::ForceInitialConfigure. |
34 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); | 42 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); |
35 | 43 |
36 // Recursively swaps the displays in a DisplayLayout to change the primary | 44 // Recursively swaps the displays in a DisplayLayout to change the primary |
37 // display but keep the same relative display layout. | 45 // display but keep the same relative display layout. |
38 // TODO(kylechar): This is copied from WindowTreeHostManager. The concept of | 46 // TODO(kylechar): This is copied from WindowTreeHostManager. The concept of |
39 // getting the same relative display layout with a different primary display id | 47 // getting the same relative display layout with a different primary display id |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 display_configurator_.AddObserver(display_change_observer_.get()); | 193 display_configurator_.AddObserver(display_change_observer_.get()); |
186 display_configurator_.set_state_controller(display_change_observer_.get()); | 194 display_configurator_.set_state_controller(display_change_observer_.get()); |
187 display_configurator_.set_mirroring_controller(display_manager_.get()); | 195 display_configurator_.set_mirroring_controller(display_manager_.get()); |
188 | 196 |
189 // Perform initial configuration. | 197 // Perform initial configuration. |
190 display_configurator_.Init(std::move(native_display_delegate_), false); | 198 display_configurator_.Init(std::move(native_display_delegate_), false); |
191 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); | 199 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); |
192 | 200 |
193 touch_transform_controller_ = base::MakeUnique<TouchTransformController>( | 201 touch_transform_controller_ = base::MakeUnique<TouchTransformController>( |
194 &display_configurator_, display_manager_.get()); | 202 &display_configurator_, display_manager_.get()); |
203 | |
204 // base::Value pref_kDisplayRotationLock(prefs::kDisplayRotationLock); | |
205 // base::Value pref_kSecondaryDisplays(prefs::kSecondaryDisplays); | |
206 // base::Value pref_kDisplayProperties(prefs::kDisplayProperties); | |
207 // base::Value pref_kDisplayPowerState(prefs::kDisplayPowerState); | |
208 | |
209 // auto prefs = base::MakeUnique<base::DictionaryValue>(); | |
210 | |
211 // prefs->Set(prefs::kDisplayRotationLock, | |
212 // pref_kDisplayRotationLock.CreateDeepCopy()); | |
213 // prefs->Set(prefs::kSecondaryDisplays, | |
214 // pref_kSecondaryDisplays.CreateDeepCopy()); | |
215 // prefs->Set(prefs::kDisplayProperties, | |
216 // pref_kDisplayProperties.CreateDeepCopy()); | |
217 // prefs->Set(prefs::kDisplayPowerState, | |
218 // pref_kDisplayPowerState.CreateDeepCopy()); | |
219 | |
220 connector_ = service_manager::Connector::Create(&connector_request); | |
jonross
2017/03/16 23:59:16
You should not be trying to create a new Connector
thanhph
2017/03/17 19:11:43
Thanks! I use connector() in window_manager and pa
| |
221 connector_->BindInterface(prefs::mojom::kPrefStoreServiceName, | |
222 &pref_factory_ptr); | |
223 pref_client_store_ = | |
224 new preferences::PrefClientStore(std::move(pref_factory_ptr)); | |
225 | |
226 pref_client_store_->Subscribe({prefs::kDisplayRotationLock}); | |
227 pref_client_store_->Subscribe({prefs::kSecondaryDisplays}); | |
228 pref_client_store_->Subscribe({prefs::kDisplayProperties}); | |
229 pref_client_store_->Subscribe({prefs::kDisplayPowerState}); | |
jonross
2017/03/16 23:59:16
These should be enqueued in a vector and only one
thanhph
2017/03/17 19:11:43
Done.
| |
230 | |
231 pref_client_store_->AddObserver(this); | |
jonross
2017/03/16 23:59:16
This should be done before subscribing.
See the e
thanhph
2017/03/17 19:11:43
Thanks! I realize preferences::PrefObserverStore n
jonross
2017/03/17 19:18:34
PrefObserverStore was renamed PrefClientStore
| |
232 | |
233 // if (pref_client_store_->IsInitializationComplete()) { | |
234 // OnInitializationCompleted(true); | |
235 // } | |
236 | |
237 // OnPrefValueChanged(prefs::kDisplayRotationLock); | |
238 // OnPrefValueChanged(prefs::kSecondaryDisplays); | |
239 // OnPrefValueChanged(prefs::kDisplayProperties); | |
240 // OnPrefValueChanged(prefs::kDisplayPowerState); | |
241 } | |
242 | |
243 void ScreenManagerOzoneInternal::OnInitializationCompleted(bool succeeded) { | |
244 DCHECK(!initialization_completed_); | |
245 DCHECK(succeeded); | |
246 DCHECK(pref_client_store_->IsInitializationComplete()); | |
247 initialization_completed_ = true; | |
248 | |
249 LOG(ERROR) | |
250 << "OnInitializationCompleted true----------------------------------"; | |
251 pref_client_store_->SetValue(prefs::kDisplayRotationLock, | |
252 base::MakeUnique<base::Value>(10), 1); | |
253 // LOG(ERROR) << "-------- | |
254 // pref_client_store_->GetValue(prefs::kDisplayRotationLock):" << temp; | |
255 // display::LoadDisplayPreferences(true, &display_configurator_, | |
256 // display_manager_.get(), pref_client_store_.get()); | |
257 } | |
258 | |
259 void ScreenManagerOzoneInternal::OnPrefValueChanged(const std::string& key) { | |
260 const base::Value* value = NULL; | |
261 DCHECK(pref_client_store_->GetValue(key, &value)); | |
262 LOG(ERROR) << "-------- ScreenManagerOzoneInternal::OnPrefValueChanged: " | |
263 << value; | |
264 changed_prefs_.Set(key, value->DeepCopy()); | |
195 } | 265 } |
196 | 266 |
197 void ScreenManagerOzoneInternal::RequestCloseDisplay(int64_t display_id) { | 267 void ScreenManagerOzoneInternal::RequestCloseDisplay(int64_t display_id) { |
198 if (!fake_display_controller_) | 268 if (!fake_display_controller_) |
199 return; | 269 return; |
200 | 270 |
201 // Tell the NDD to remove the display. ScreenManager will get an update | 271 // Tell the NDD to remove the display. ScreenManager will get an update |
202 // that the display configuration has changed and the display will be gone. | 272 // that the display configuration has changed and the display will be gone. |
203 fake_display_controller_->RemoveDisplay(display_id); | 273 fake_display_controller_->RemoveDisplay(display_id); |
204 } | 274 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 std::move(request)); | 469 std::move(request)); |
400 } | 470 } |
401 | 471 |
402 void ScreenManagerOzoneInternal::Create( | 472 void ScreenManagerOzoneInternal::Create( |
403 const service_manager::Identity& remote_identity, | 473 const service_manager::Identity& remote_identity, |
404 mojom::TestDisplayControllerRequest request) { | 474 mojom::TestDisplayControllerRequest request) { |
405 test_bindings_.AddBinding(this, std::move(request)); | 475 test_bindings_.AddBinding(this, std::move(request)); |
406 } | 476 } |
407 | 477 |
408 } // namespace display | 478 } // namespace display |
OLD | NEW |