Chromium Code Reviews| Index: services/ui/display/screen_manager_ozone_internal.cc |
| diff --git a/services/ui/display/screen_manager_ozone_internal.cc b/services/ui/display/screen_manager_ozone_internal.cc |
| index d175cee4569d6ca7653470f1f146c558a5fdd354..6213684ca89f0371bd3ddd1d104f37e35ef5c118 100644 |
| --- a/services/ui/display/screen_manager_ozone_internal.cc |
| +++ b/services/ui/display/screen_manager_ozone_internal.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/command_line.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chromeos/system/devicemode.h" |
| #include "mojo/public/cpp/bindings/strong_binding.h" |
| #include "services/service_manager/public/cpp/interface_registry.h" |
| @@ -27,6 +28,13 @@ |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/ozone/public/ozone_platform.h" |
| +#include "ui/display/manager/display_preferences.h" |
| + |
| +#include "components/prefs/pref_store.h" |
| +#include "services/preferences/public/interfaces/preferences.mojom.h" |
| + |
| +#include "base/values.h" |
| + |
| namespace display { |
| namespace { |
| @@ -192,6 +200,68 @@ void ScreenManagerOzoneInternal::Init(ScreenManagerDelegate* delegate) { |
| touch_transform_controller_ = base::MakeUnique<TouchTransformController>( |
| &display_configurator_, display_manager_.get()); |
| + |
| + // base::Value pref_kDisplayRotationLock(prefs::kDisplayRotationLock); |
| + // base::Value pref_kSecondaryDisplays(prefs::kSecondaryDisplays); |
| + // base::Value pref_kDisplayProperties(prefs::kDisplayProperties); |
| + // base::Value pref_kDisplayPowerState(prefs::kDisplayPowerState); |
| + |
| + // auto prefs = base::MakeUnique<base::DictionaryValue>(); |
| + |
| + // prefs->Set(prefs::kDisplayRotationLock, |
| + // pref_kDisplayRotationLock.CreateDeepCopy()); |
| + // prefs->Set(prefs::kSecondaryDisplays, |
| + // pref_kSecondaryDisplays.CreateDeepCopy()); |
| + // prefs->Set(prefs::kDisplayProperties, |
| + // pref_kDisplayProperties.CreateDeepCopy()); |
| + // prefs->Set(prefs::kDisplayPowerState, |
| + // pref_kDisplayPowerState.CreateDeepCopy()); |
| + |
| + 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
|
| + connector_->BindInterface(prefs::mojom::kPrefStoreServiceName, |
| + &pref_factory_ptr); |
| + pref_client_store_ = |
| + new preferences::PrefClientStore(std::move(pref_factory_ptr)); |
| + |
| + pref_client_store_->Subscribe({prefs::kDisplayRotationLock}); |
| + pref_client_store_->Subscribe({prefs::kSecondaryDisplays}); |
| + pref_client_store_->Subscribe({prefs::kDisplayProperties}); |
| + 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.
|
| + |
| + 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
|
| + |
| + // if (pref_client_store_->IsInitializationComplete()) { |
| + // OnInitializationCompleted(true); |
| + // } |
| + |
| + // OnPrefValueChanged(prefs::kDisplayRotationLock); |
| + // OnPrefValueChanged(prefs::kSecondaryDisplays); |
| + // OnPrefValueChanged(prefs::kDisplayProperties); |
| + // OnPrefValueChanged(prefs::kDisplayPowerState); |
| +} |
| + |
| +void ScreenManagerOzoneInternal::OnInitializationCompleted(bool succeeded) { |
| + DCHECK(!initialization_completed_); |
| + DCHECK(succeeded); |
| + DCHECK(pref_client_store_->IsInitializationComplete()); |
| + initialization_completed_ = true; |
| + |
| + LOG(ERROR) |
| + << "OnInitializationCompleted true----------------------------------"; |
| + pref_client_store_->SetValue(prefs::kDisplayRotationLock, |
| + base::MakeUnique<base::Value>(10), 1); |
| + // LOG(ERROR) << "-------- |
| + // pref_client_store_->GetValue(prefs::kDisplayRotationLock):" << temp; |
| + // display::LoadDisplayPreferences(true, &display_configurator_, |
| + // display_manager_.get(), pref_client_store_.get()); |
| +} |
| + |
| +void ScreenManagerOzoneInternal::OnPrefValueChanged(const std::string& key) { |
| + const base::Value* value = NULL; |
| + DCHECK(pref_client_store_->GetValue(key, &value)); |
| + LOG(ERROR) << "-------- ScreenManagerOzoneInternal::OnPrefValueChanged: " |
| + << value; |
| + changed_prefs_.Set(key, value->DeepCopy()); |
| } |
| void ScreenManagerOzoneInternal::RequestCloseDisplay(int64_t display_id) { |