| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/display/display_layout_store.h" | |
| 10 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 11 #include "ash/display/display_pref_util.h" | 10 #include "ash/display/display_pref_util.h" |
| 12 #include "ash/display/display_util.h" | 11 #include "ash/display/display_util.h" |
| 13 #include "ash/display/json_converter.h" | 12 #include "ash/display/json_converter.h" |
| 14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 15 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 19 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 20 #include "base/values.h" | 19 #include "base/values.h" |
| 21 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 23 #include "components/prefs/pref_registry_simple.h" | 22 #include "components/prefs/pref_registry_simple.h" |
| 24 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 25 #include "components/prefs/scoped_user_pref_update.h" | 24 #include "components/prefs/scoped_user_pref_update.h" |
| 26 #include "components/user_manager/user_manager.h" | 25 #include "components/user_manager/user_manager.h" |
| 27 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 28 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 28 #include "ui/display/manager/display_layout_store.h" |
| 29 #include "ui/gfx/geometry/insets.h" | 29 #include "ui/gfx/geometry/insets.h" |
| 30 #include "url/url_canon.h" | 30 #include "url/url_canon.h" |
| 31 #include "url/url_util.h" | 31 #include "url/url_util.h" |
| 32 | 32 |
| 33 namespace chromeos { | 33 namespace chromeos { |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const char kInsetsTopKey[] = "insets_top"; | 36 const char kInsetsTopKey[] = "insets_top"; |
| 37 const char kInsetsLeftKey[] = "insets_left"; | 37 const char kInsetsLeftKey[] = "insets_left"; |
| 38 const char kInsetsBottomKey[] = "insets_bottom"; | 38 const char kInsetsBottomKey[] = "insets_bottom"; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool UserCanSaveDisplayPreference() { | 104 bool UserCanSaveDisplayPreference() { |
| 105 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 105 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 106 return user_manager->IsUserLoggedIn() && | 106 return user_manager->IsUserLoggedIn() && |
| 107 (user_manager->IsLoggedInAsUserWithGaiaAccount() || | 107 (user_manager->IsLoggedInAsUserWithGaiaAccount() || |
| 108 user_manager->IsLoggedInAsSupervisedUser() || | 108 user_manager->IsLoggedInAsSupervisedUser() || |
| 109 user_manager->IsLoggedInAsKioskApp()); | 109 user_manager->IsLoggedInAsKioskApp()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void LoadDisplayLayouts() { | 112 void LoadDisplayLayouts() { |
| 113 PrefService* local_state = g_browser_process->local_state(); | 113 PrefService* local_state = g_browser_process->local_state(); |
| 114 ash::DisplayLayoutStore* layout_store = GetDisplayManager()->layout_store(); | 114 display::DisplayLayoutStore* layout_store = |
| 115 GetDisplayManager()->layout_store(); |
| 115 | 116 |
| 116 const base::DictionaryValue* layouts = local_state->GetDictionary( | 117 const base::DictionaryValue* layouts = local_state->GetDictionary( |
| 117 prefs::kSecondaryDisplays); | 118 prefs::kSecondaryDisplays); |
| 118 for (base::DictionaryValue::Iterator it(*layouts); | 119 for (base::DictionaryValue::Iterator it(*layouts); |
| 119 !it.IsAtEnd(); it.Advance()) { | 120 !it.IsAtEnd(); it.Advance()) { |
| 120 std::unique_ptr<display::DisplayLayout> layout(new display::DisplayLayout); | 121 std::unique_ptr<display::DisplayLayout> layout(new display::DisplayLayout); |
| 121 if (!ash::JsonToDisplayLayout(it.value(), layout.get())) { | 122 if (!ash::JsonToDisplayLayout(it.value(), layout.get())) { |
| 122 LOG(WARNING) << "Invalid preference value for " << it.key(); | 123 LOG(WARNING) << "Invalid preference value for " << it.key(); |
| 123 continue; | 124 continue; |
| 124 } | 125 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 const display::DisplayLayout& layout) { | 394 const display::DisplayLayout& layout) { |
| 394 StoreDisplayLayoutPref(list, layout); | 395 StoreDisplayLayoutPref(list, layout); |
| 395 } | 396 } |
| 396 | 397 |
| 397 // Stores the given |power_state|. | 398 // Stores the given |power_state|. |
| 398 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 399 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 399 StoreDisplayPowerState(power_state); | 400 StoreDisplayPowerState(power_state); |
| 400 } | 401 } |
| 401 | 402 |
| 402 } // namespace chromeos | 403 } // namespace chromeos |
| OLD | NEW |