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 "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 16 #include "chrome/browser/prefs/pref_registry_simple.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "googleurl/src/url_canon.h" | 20 #include "googleurl/src/url_canon.h" |
20 #include "googleurl/src/url_util.h" | 21 #include "googleurl/src/url_util.h" |
21 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
22 #include "ui/gfx/insets.h" | 23 #include "ui/gfx/insets.h" |
23 | 24 |
24 namespace chromeos { | 25 namespace chromeos { |
25 namespace { | 26 namespace { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 LOG(WARNING) << "Can't convert the data into insets for " << *it; | 126 LOG(WARNING) << "Can't convert the data into insets for " << *it; |
126 continue; | 127 continue; |
127 } | 128 } |
128 | 129 |
129 display_controller->SetOverscanInsets(display_id, insets); | 130 display_controller->SetOverscanInsets(display_id, insets); |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 } // namespace | 134 } // namespace |
134 | 135 |
135 void RegisterDisplayLocalStatePrefs(PrefServiceSimple* local_state) { | 136 void RegisterDisplayLocalStatePrefs(PrefRegistrySimple* registry) { |
136 // The default secondary display layout. | 137 // The default secondary display layout. |
137 local_state->RegisterIntegerPref(prefs::kSecondaryDisplayLayout, | 138 registry->RegisterIntegerPref(prefs::kSecondaryDisplayLayout, |
138 static_cast<int>(ash::DisplayLayout::RIGHT)); | 139 static_cast<int>(ash::DisplayLayout::RIGHT)); |
139 // The default offset of the secondary display position from the primary | 140 // The default offset of the secondary display position from the primary |
140 // display. | 141 // display. |
141 local_state->RegisterIntegerPref(prefs::kSecondaryDisplayOffset, 0); | 142 registry->RegisterIntegerPref(prefs::kSecondaryDisplayOffset, 0); |
142 // Per-display preference. | 143 // Per-display preference. |
143 local_state->RegisterDictionaryPref(prefs::kSecondaryDisplays); | 144 registry->RegisterDictionaryPref(prefs::kSecondaryDisplays); |
144 | 145 |
145 // Primary output name. | 146 // Primary output name. |
146 local_state->RegisterInt64Pref(prefs::kPrimaryDisplayID, | 147 registry->RegisterInt64Pref(prefs::kPrimaryDisplayID, |
147 gfx::Display::kInvalidDisplayID); | 148 gfx::Display::kInvalidDisplayID); |
148 | 149 |
149 // Display overscan preference. | 150 // Display overscan preference. |
150 local_state->RegisterDictionaryPref(prefs::kDisplayOverscans); | 151 registry->RegisterDictionaryPref(prefs::kDisplayOverscans); |
151 } | 152 } |
152 | 153 |
153 void SetDisplayLayoutPref(const gfx::Display& display, | 154 void SetDisplayLayoutPref(const gfx::Display& display, |
154 int layout, | 155 int layout, |
155 int offset) { | 156 int offset) { |
156 ash::DisplayLayout display_layout( | 157 ash::DisplayLayout display_layout( |
157 static_cast<ash::DisplayLayout::Position>(layout), offset); | 158 static_cast<ash::DisplayLayout::Position>(layout), offset); |
158 if (IsValidUser()) { | 159 if (IsValidUser()) { |
159 PrefService* local_state = g_browser_process->local_state(); | 160 PrefService* local_state = g_browser_process->local_state(); |
160 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); | 161 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 217 |
217 void NotifyDisplayLocalStatePrefChanged() { | 218 void NotifyDisplayLocalStatePrefChanged() { |
218 PrefService* local_state = g_browser_process->local_state(); | 219 PrefService* local_state = g_browser_process->local_state(); |
219 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( | 220 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( |
220 local_state->GetInt64(prefs::kPrimaryDisplayID)); | 221 local_state->GetInt64(prefs::kPrimaryDisplayID)); |
221 NotifyDisplayLayoutChanged(); | 222 NotifyDisplayLayoutChanged(); |
222 NotifyDisplayOverscans(); | 223 NotifyDisplayOverscans(); |
223 } | 224 } |
224 | 225 |
225 } // namespace chromeos | 226 } // namespace chromeos |
OLD | NEW |