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

Side by Side Diff: chrome/browser/chromeos/display/display_preferences.cc

Issue 12438016: Save display preference when all display configuration changes has been completed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: replace dcheck Created 7 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 | Annotate | Revision Log
OLDNEW
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/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ash::DisplayController* display_controller = GetDisplayController(); 173 ash::DisplayController* display_controller = GetDisplayController();
174 ash::DisplayLayout display_layout = 174 ash::DisplayLayout display_layout =
175 display_controller->GetCurrentDisplayLayout(); 175 display_controller->GetCurrentDisplayLayout();
176 ash::DisplayIdPair pair = display_controller->GetCurrentDisplayIdPair(); 176 ash::DisplayIdPair pair = display_controller->GetCurrentDisplayIdPair();
177 177
178 StoreDisplayLayoutPref(pair.first, pair.second, display_layout); 178 StoreDisplayLayoutPref(pair.first, pair.second, display_layout);
179 } 179 }
180 180
181 181
182 void StorePrimaryDisplayIDPref(int64 display_id) { 182 void StorePrimaryDisplayIDPref(int64 display_id) {
183 if (!IsValidUser()) 183 if (!IsValidUser() || gfx::Screen::GetNativeScreen()->GetNumDisplays() < 2)
184 return; 184 return;
185 185
186 PrefService* local_state = g_browser_process->local_state(); 186 PrefService* local_state = g_browser_process->local_state();
187 if (GetDisplayManager()->IsInternalDisplayId(display_id)) 187 if (GetDisplayManager()->IsInternalDisplayId(display_id))
188 local_state->ClearPref(prefs::kPrimaryDisplayID); 188 local_state->ClearPref(prefs::kPrimaryDisplayID);
189 else 189 else
190 local_state->SetInt64(prefs::kPrimaryDisplayID, display_id); 190 local_state->SetInt64(prefs::kPrimaryDisplayID, display_id);
191 } 191 }
192 192
193 } // namespace 193 } // namespace
(...skipping 10 matching lines...) Expand all
204 204
205 // Primary output name. 205 // Primary output name.
206 registry->RegisterInt64Pref(prefs::kPrimaryDisplayID, 206 registry->RegisterInt64Pref(prefs::kPrimaryDisplayID,
207 gfx::Display::kInvalidDisplayID); 207 gfx::Display::kInvalidDisplayID);
208 208
209 // Display overscan preference. 209 // Display overscan preference.
210 registry->RegisterDictionaryPref(prefs::kDisplayOverscans); 210 registry->RegisterDictionaryPref(prefs::kDisplayOverscans);
211 } 211 }
212 212
213 void StoreDisplayPrefs() { 213 void StoreDisplayPrefs() {
214 StorePrimaryDisplayIDPref(ash::Shell::GetScreen()->GetPrimaryDisplay().id()); 214 if (!IsValidUser())
215 StoreCurrentDisplayLayoutPrefs(); 215 return;
216 if (gfx::Screen::GetNativeScreen()->GetNumDisplays() == 2) {
217 StorePrimaryDisplayIDPref(
218 ash::Shell::GetScreen()->GetPrimaryDisplay().id());
219 StoreCurrentDisplayLayoutPrefs();
220 }
216 } 221 }
217 222
218 void SetAndStoreDisplayLayoutPref(int layout, int offset) { 223 void SetAndStoreDisplayLayoutPref(int layout, int offset) {
219 ash::DisplayLayout display_layout( 224 ash::DisplayLayout display_layout(
220 static_cast<ash::DisplayLayout::Position>(layout), offset); 225 static_cast<ash::DisplayLayout::Position>(layout), offset);
221 ash::Shell::GetInstance()->display_controller()-> 226 ash::Shell::GetInstance()->display_controller()->
222 SetLayoutForCurrentDisplays(display_layout); 227 SetLayoutForCurrentDisplays(display_layout);
223 StoreCurrentDisplayLayoutPrefs(); 228 StoreCurrentDisplayLayoutPrefs();
224 } 229 }
225 230
(...skipping 29 matching lines...) Expand all
255 260
256 void NotifyDisplayLocalStatePrefChanged() { 261 void NotifyDisplayLocalStatePrefChanged() {
257 PrefService* local_state = g_browser_process->local_state(); 262 PrefService* local_state = g_browser_process->local_state();
258 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( 263 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId(
259 local_state->GetInt64(prefs::kPrimaryDisplayID)); 264 local_state->GetInt64(prefs::kPrimaryDisplayID));
260 NotifyDisplayLayoutChanged(); 265 NotifyDisplayLayoutChanged();
261 NotifyDisplayOverscans(); 266 NotifyDisplayOverscans();
262 } 267 }
263 268
264 } // namespace chromeos 269 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698