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

Side by Side Diff: services/ui/display/screen_manager_ozone_internal.cc

Issue 2760453003: Work In Progess
Patch Set: convert local_state to use pre_client_store_ Created 3 years, 9 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 | « services/ui/display/screen_manager_ozone_internal.h ('k') | services/ui/manifest.json » ('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 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 "services/service_manager/public/cpp/connector.h"
34
35 #include "components/prefs/pref_store.h"
36 #include "services/preferences/public/interfaces/preferences.mojom.h"
37
38 #include "base/values.h"
39
30 namespace display { 40 namespace display {
31 namespace { 41 namespace {
32 42
33 // Needed for DisplayConfigurator::ForceInitialConfigure. 43 // Needed for DisplayConfigurator::ForceInitialConfigure.
34 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); 44 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
35 45
36 // Recursively swaps the displays in a DisplayLayout to change the primary 46 // Recursively swaps the displays in a DisplayLayout to change the primary
37 // display but keep the same relative display layout. 47 // display but keep the same relative display layout.
38 // TODO(kylechar): This is copied from WindowTreeHostManager. The concept of 48 // TODO(kylechar): This is copied from WindowTreeHostManager. The concept of
39 // getting the same relative display layout with a different primary display id 49 // getting the same relative display layout with a different primary display id
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 delegate_->OnPrimaryDisplayChanged(primary_display_id_); 152 delegate_->OnPrimaryDisplayChanged(primary_display_id_);
143 } 153 }
144 154
145 void ScreenManagerOzoneInternal::AddInterfaces( 155 void ScreenManagerOzoneInternal::AddInterfaces(
146 service_manager::InterfaceRegistry* registry) { 156 service_manager::InterfaceRegistry* registry) {
147 registry->AddInterface<mojom::DisplayController>(this); 157 registry->AddInterface<mojom::DisplayController>(this);
148 registry->AddInterface<mojom::OutputProtection>(this); 158 registry->AddInterface<mojom::OutputProtection>(this);
149 registry->AddInterface<mojom::TestDisplayController>(this); 159 registry->AddInterface<mojom::TestDisplayController>(this);
150 } 160 }
151 161
152 void ScreenManagerOzoneInternal::Init(ScreenManagerDelegate* delegate) { 162 void ScreenManagerOzoneInternal::Init(ScreenManagerDelegate* delegate,
163 service_manager::Connector* connector) {
153 DCHECK(delegate); 164 DCHECK(delegate);
154 delegate_ = delegate; 165 delegate_ = delegate;
155 166
156 // Tests may inject a NativeDisplayDelegate, otherwise get it from 167 // Tests may inject a NativeDisplayDelegate, otherwise get it from
157 // OzonePlatform. 168 // OzonePlatform.
158 if (!native_display_delegate_) { 169 if (!native_display_delegate_) {
159 native_display_delegate_ = 170 native_display_delegate_ =
160 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(); 171 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
161 } 172 }
162 173
(...skipping 22 matching lines...) Expand all
185 display_configurator_.AddObserver(display_change_observer_.get()); 196 display_configurator_.AddObserver(display_change_observer_.get());
186 display_configurator_.set_state_controller(display_change_observer_.get()); 197 display_configurator_.set_state_controller(display_change_observer_.get());
187 display_configurator_.set_mirroring_controller(display_manager_.get()); 198 display_configurator_.set_mirroring_controller(display_manager_.get());
188 199
189 // Perform initial configuration. 200 // Perform initial configuration.
190 display_configurator_.Init(std::move(native_display_delegate_), false); 201 display_configurator_.Init(std::move(native_display_delegate_), false);
191 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); 202 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
192 203
193 touch_transform_controller_ = base::MakeUnique<TouchTransformController>( 204 touch_transform_controller_ = base::MakeUnique<TouchTransformController>(
194 &display_configurator_, display_manager_.get()); 205 &display_configurator_, display_manager_.get());
206
207 // base::Value pref_kDisplayRotationLock(prefs::kDisplayRotationLock);
208 // base::Value pref_kSecondaryDisplays(prefs::kSecondaryDisplays);
209 // base::Value pref_kDisplayProperties(prefs::kDisplayProperties);
210 // base::Value pref_kDisplayPowerState(prefs::kDisplayPowerState);
211
212 // auto prefs = base::MakeUnique<base::DictionaryValue>();
213
214 // prefs->Set(prefs::kDisplayRotationLock,
215 // pref_kDisplayRotationLock.CreateDeepCopy());
216 // prefs->Set(prefs::kSecondaryDisplays,
217 // pref_kSecondaryDisplays.CreateDeepCopy());
218 // prefs->Set(prefs::kDisplayProperties,
219 // pref_kDisplayProperties.CreateDeepCopy());
220 // prefs->Set(prefs::kDisplayPowerState,
221 // pref_kDisplayPowerState.CreateDeepCopy());
222
223 connector_ = connector;
224 connector_->BindInterface(prefs::mojom::kServiceName, &pref_factory_ptr);
225 pref_client_store_ =
226 new preferences::PrefClientStore(std::move(pref_factory_ptr));
227
228 pref_client_store_->AddObserver(this);
229
230 //display::LoadDisplayPreferences(true, &display_configurator_,
231 //display_manager_.get(), pref_client_store_.get());
232
233 pref_client_store_->Subscribe(
234 {prefs::kDisplayRotationLock, prefs::kSecondaryDisplays,
235 prefs::kDisplayProperties, prefs::kDisplayProperties});
236
237 // if (pref_client_store_->IsInitializationComplete()) {
238 // LOG(ERROR) << "display::ScreenManagerOzoneInternal::Init() 6";
239 // OnInitializationCompleted(true);
240 //}
241 // OnPrefValueChanged(prefs::kDisplayRotationLock);
242 // OnPrefValueChanged(prefs::kSecondaryDisplays);
243 // OnPrefValueChanged(prefs::kDisplayProperties);
244 // OnPrefValueChanged(prefs::kDisplayPowerState);
245 }
246
247 void ScreenManagerOzoneInternal::OnInitializationCompleted(bool succeeded) {
248 DCHECK(!initialization_completed_);
249 DCHECK(succeeded);
250 DCHECK(pref_client_store_->IsInitializationComplete());
251 initialization_completed_ = true;
252
253 LOG(ERROR)
254 << "OnInitializationCompleted true----------------------------------";
255 pref_client_store_->SetValue(prefs::kDisplayRotationLock,
256 base::MakeUnique<base::Value>(10), 1);
257 // LOG(ERROR) << "--------
258 // pref_client_store_->GetValue(prefs::kDisplayRotationLock):" << temp;
259 // display::LoadDisplayPreferences(true, &display_configurator_,
260 // display_manager_.get(), pref_client_store_.get());
261 }
262
263 void ScreenManagerOzoneInternal::OnPrefValueChanged(const std::string& key) {
264 const base::Value* value = NULL;
265 DCHECK(pref_client_store_->GetValue(key, &value));
266 LOG(ERROR) << "-------- ScreenManagerOzoneInternal::OnPrefValueChanged: "
267 << value;
268 changed_prefs_.Set(key, value->DeepCopy());
195 } 269 }
196 270
197 void ScreenManagerOzoneInternal::RequestCloseDisplay(int64_t display_id) { 271 void ScreenManagerOzoneInternal::RequestCloseDisplay(int64_t display_id) {
198 if (!fake_display_controller_) 272 if (!fake_display_controller_)
199 return; 273 return;
200 274
201 // Tell the NDD to remove the display. ScreenManager will get an update 275 // 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. 276 // that the display configuration has changed and the display will be gone.
203 fake_display_controller_->RemoveDisplay(display_id); 277 fake_display_controller_->RemoveDisplay(display_id);
204 } 278 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 std::move(request)); 471 std::move(request));
398 } 472 }
399 473
400 void ScreenManagerOzoneInternal::Create( 474 void ScreenManagerOzoneInternal::Create(
401 const service_manager::Identity& remote_identity, 475 const service_manager::Identity& remote_identity,
402 mojom::TestDisplayControllerRequest request) { 476 mojom::TestDisplayControllerRequest request) {
403 test_bindings_.AddBinding(this, std::move(request)); 477 test_bindings_.AddBinding(this, std::move(request));
404 } 478 }
405 479
406 } // namespace display 480 } // namespace display
OLDNEW
« no previous file with comments | « services/ui/display/screen_manager_ozone_internal.h ('k') | services/ui/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698