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

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 10870036: Allow storing display preferences per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/chromeos/chromeos_version.h" 9 #include "base/chromeos/chromeos_version.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/string_split.h" 13 #include "base/string_split.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/api/prefs/pref_member.h" 16 #include "chrome/browser/api/prefs/pref_member.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/display_preferences.h"
18 #include "chrome/browser/chromeos/gdata/gdata_util.h" 19 #include "chrome/browser/chromeos/gdata/gdata_util.h"
19 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 20 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
20 #include "chrome/browser/chromeos/input_method/input_method_util.h" 21 #include "chrome/browser/chromeos/input_method/input_method_util.h"
21 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 22 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
22 #include "chrome/browser/chromeos/login/login_utils.h" 23 #include "chrome/browser/chromeos/login/login_utils.h"
23 #include "chrome/browser/chromeos/system/drm_settings.h" 24 #include "chrome/browser/chromeos/system/drm_settings.h"
24 #include "chrome/browser/chromeos/system/input_device_settings.h" 25 #include "chrome/browser/chromeos/system/input_device_settings.h"
25 #include "chrome/browser/chromeos/system/power_manager_settings.h" 26 #include "chrome/browser/chromeos/system/power_manager_settings.h"
26 #include "chrome/browser/chromeos/system/statistics_provider.h" 27 #include "chrome/browser/chromeos/system/statistics_provider.h"
27 #include "chrome/browser/download/download_util.h" 28 #include "chrome/browser/download/download_util.h"
(...skipping 14 matching lines...) Expand all
42 // TODO(achuith): Use a cmd-line flag + use flags for this instead. 43 // TODO(achuith): Use a cmd-line flag + use flags for this instead.
43 bool IsLumpy() { 44 bool IsLumpy() {
44 std::string board; 45 std::string board;
45 system::StatisticsProvider::GetInstance()->GetMachineStatistic( 46 system::StatisticsProvider::GetInstance()->GetMachineStatistic(
46 "CHROMEOS_RELEASE_BOARD", &board); 47 "CHROMEOS_RELEASE_BOARD", &board);
47 return StartsWithASCII(board, "lumpy", false); 48 return StartsWithASCII(board, "lumpy", false);
48 } 49 }
49 50
50 } // namespace 51 } // namespace
51 52
52 using ash::internal::DisplayController; 53 using ash::internal::DisplayLayout;
53 54
54 static const char kFallbackInputMethodLocale[] = "en-US"; 55 static const char kFallbackInputMethodLocale[] = "en-US";
55 56
56 Preferences::Preferences() 57 Preferences::Preferences()
57 : prefs_(NULL), 58 : prefs_(NULL),
58 input_method_manager_(input_method::InputMethodManager::GetInstance()) { 59 input_method_manager_(input_method::InputMethodManager::GetInstance()) {
59 } 60 }
60 61
61 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) 62 Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
62 : input_method_manager_(input_method_manager) { 63 : input_method_manager_(input_method_manager) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 PrefService::UNSYNCABLE_PREF); 242 PrefService::UNSYNCABLE_PREF);
242 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, 243 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval,
243 language_prefs::kXkbAutoRepeatIntervalInMs, 244 language_prefs::kXkbAutoRepeatIntervalInMs,
244 PrefService::UNSYNCABLE_PREF); 245 PrefService::UNSYNCABLE_PREF);
245 246
246 // Screen lock default to off. 247 // Screen lock default to off.
247 prefs->RegisterBooleanPref(prefs::kEnableScreenLock, 248 prefs->RegisterBooleanPref(prefs::kEnableScreenLock,
248 false, 249 false,
249 PrefService::SYNCABLE_PREF); 250 PrefService::SYNCABLE_PREF);
250 251
251 // Secondary display layout.
252 prefs->RegisterIntegerPref(prefs::kSecondaryDisplayLayout,
253 static_cast<int>(DisplayController::RIGHT),
254 PrefService::UNSYNCABLE_PREF);
255 // The offset of the secondary display position from the primary display.
256 prefs->RegisterIntegerPref(prefs::kSecondaryDisplayOffset,
257 0,
258 PrefService::UNSYNCABLE_PREF);
259
260 // Mobile plan notifications default to on. 252 // Mobile plan notifications default to on.
261 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, 253 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications,
262 true, 254 true,
263 PrefService::SYNCABLE_PREF); 255 PrefService::SYNCABLE_PREF);
264 256
265 // 3G first-time usage promo will be shown at least once. 257 // 3G first-time usage promo will be shown at least once.
266 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, 258 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification,
267 true, 259 true,
268 PrefService::UNSYNCABLE_PREF); 260 PrefService::UNSYNCABLE_PREF);
269 261
(...skipping 13 matching lines...) Expand all
283 275
284 // TODO(wad): Once UI is connected, a final default can be set. At that point 276 // TODO(wad): Once UI is connected, a final default can be set. At that point
285 // change this pref from UNSYNCABLE to SYNCABLE. 277 // change this pref from UNSYNCABLE to SYNCABLE.
286 prefs->RegisterBooleanPref(prefs::kEnableCrosDRM, 278 prefs->RegisterBooleanPref(prefs::kEnableCrosDRM,
287 true, 279 true,
288 PrefService::UNSYNCABLE_PREF); 280 PrefService::UNSYNCABLE_PREF);
289 281
290 prefs->RegisterBooleanPref(prefs::kExternalStorageDisabled, 282 prefs->RegisterBooleanPref(prefs::kExternalStorageDisabled,
291 false, 283 false,
292 PrefService::UNSYNCABLE_PREF); 284 PrefService::UNSYNCABLE_PREF);
285
286 RegisterDisplayPrefs(prefs);
293 } 287 }
294 288
295 void Preferences::InitUserPrefs(PrefService* prefs) { 289 void Preferences::InitUserPrefs(PrefService* prefs) {
296 prefs_ = prefs; 290 prefs_ = prefs;
297 291
298 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this); 292 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this);
299 three_finger_click_enabled_.Init(prefs::kEnableTouchpadThreeFingerClick, 293 three_finger_click_enabled_.Init(prefs::kEnableTouchpadThreeFingerClick,
300 prefs, this); 294 prefs, this);
301 natural_scroll_.Init(prefs::kNaturalScroll, prefs, this); 295 natural_scroll_.Init(prefs::kNaturalScroll, prefs, this);
302 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, prefs, this); 296 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, prefs, this);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 351 }
358 xkb_auto_repeat_enabled_.Init( 352 xkb_auto_repeat_enabled_.Init(
359 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); 353 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this);
360 xkb_auto_repeat_delay_pref_.Init( 354 xkb_auto_repeat_delay_pref_.Init(
361 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); 355 prefs::kLanguageXkbAutoRepeatDelay, prefs, this);
362 xkb_auto_repeat_interval_pref_.Init( 356 xkb_auto_repeat_interval_pref_.Init(
363 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); 357 prefs::kLanguageXkbAutoRepeatInterval, prefs, this);
364 358
365 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); 359 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this);
366 360
367 secondary_display_layout_.Init(prefs::kSecondaryDisplayLayout, prefs, this);
368 secondary_display_offset_.Init(prefs::kSecondaryDisplayOffset, prefs, this);
369
370 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); 361 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this);
371 } 362 }
372 363
373 void Preferences::Init(PrefService* prefs) { 364 void Preferences::Init(PrefService* prefs) {
374 InitUserPrefs(prefs); 365 InitUserPrefs(prefs);
375 366
376 // Initialize preferences to currently saved state. 367 // Initialize preferences to currently saved state.
377 NotifyPrefChanged(NULL); 368 NotifyPrefChanged(NULL);
378 369
379 // If a guest is logged in, initialize the prefs as if this is the first 370 // If a guest is logged in, initialize the prefs as if this is the first
380 // login. 371 // login.
381 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { 372 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) {
382 LoginUtils::Get()->SetFirstLoginPrefs(prefs); 373 LoginUtils::Get()->SetFirstLoginPrefs(prefs);
383 } 374 }
375
376 NotifyDisplayPrefChanged(prefs);
384 } 377 }
385 378
386 void Preferences::InitUserPrefsForTesting(PrefService* prefs) { 379 void Preferences::InitUserPrefsForTesting(PrefService* prefs) {
387 InitUserPrefs(prefs); 380 InitUserPrefs(prefs);
388 } 381 }
389 382
390 void Preferences::SetInputMethodListForTesting() { 383 void Preferences::SetInputMethodListForTesting() {
391 SetInputMethodList(); 384 SetInputMethodList();
392 } 385 }
393 386
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 mozc_integer_prefs_[i].GetValue()); 570 mozc_integer_prefs_[i].GetValue());
578 } 571 }
579 } 572 }
580 573
581 // Init or update power manager config. 574 // Init or update power manager config.
582 if (!pref_name || *pref_name == prefs::kEnableScreenLock) { 575 if (!pref_name || *pref_name == prefs::kEnableScreenLock) {
583 system::power_manager_settings::EnableScreenLock( 576 system::power_manager_settings::EnableScreenLock(
584 enable_screen_lock_.GetValue()); 577 enable_screen_lock_.GetValue());
585 } 578 }
586 579
587 if (!pref_name || *pref_name == prefs::kSecondaryDisplayLayout) {
588 int layout = secondary_display_layout_.GetValue();
589 if (static_cast<int>(DisplayController::TOP) <= layout &&
590 layout <= static_cast<int>(DisplayController::LEFT)) {
591 ash::Shell::GetInstance()->display_controller()->
592 SetSecondaryDisplayLayout(
593 static_cast<DisplayController::SecondaryDisplayLayout>(layout));
594 }
595 }
596
597 if (!pref_name || *pref_name == prefs::kSecondaryDisplayOffset) {
598 ash::Shell::GetInstance()->display_controller()->
599 SetSecondaryDisplayOffset(secondary_display_offset_.GetValue());
600 }
601
602 // Init or update protected content (DRM) support. 580 // Init or update protected content (DRM) support.
603 if (!pref_name || *pref_name == prefs::kEnableCrosDRM) { 581 if (!pref_name || *pref_name == prefs::kEnableCrosDRM) {
604 system::ToggleDrm(enable_drm_.GetValue()); 582 system::ToggleDrm(enable_drm_.GetValue());
605 } 583 }
606 584
607 // Change the download directory to the default value if a GData directory is 585 // Change the download directory to the default value if a GData directory is
608 // selected and GData is disabled. 586 // selected and GData is disabled.
609 if (!pref_name || *pref_name == prefs::kDisableGData) { 587 if (!pref_name || *pref_name == prefs::kDisableGData) {
610 if (disable_gdata_.GetValue()) { 588 if (disable_gdata_.GetValue()) {
611 const FilePath download_path = 589 const FilePath download_path =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 687
710 input_method::AutoRepeatRate rate; 688 input_method::AutoRepeatRate rate;
711 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); 689 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue();
712 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); 690 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue();
713 DCHECK(rate.initial_delay_in_ms > 0); 691 DCHECK(rate.initial_delay_in_ms > 0);
714 DCHECK(rate.repeat_interval_in_ms > 0); 692 DCHECK(rate.repeat_interval_in_ms > 0);
715 input_method::XKeyboard::SetAutoRepeatRate(rate); 693 input_method::XKeyboard::SetAutoRepeatRate(rate);
716 } 694 }
717 695
718 } // namespace chromeos 696 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698