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/preferences.h" | 5 #include "chrome/browser/chromeos/preferences.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | |
8 #include "ash/shell.h" | |
7 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
10 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
11 #include "base/string_split.h" | 13 #include "base/string_split.h" |
12 #include "base/string_util.h" | 14 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 18 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
40 // TODO(achuith): Use a cmd-line flag + use flags for this instead. | 42 // TODO(achuith): Use a cmd-line flag + use flags for this instead. |
41 bool IsLumpy() { | 43 bool IsLumpy() { |
42 std::string board; | 44 std::string board; |
43 system::StatisticsProvider::GetInstance()->GetMachineStatistic( | 45 system::StatisticsProvider::GetInstance()->GetMachineStatistic( |
44 "CHROMEOS_RELEASE_BOARD", &board); | 46 "CHROMEOS_RELEASE_BOARD", &board); |
45 return StartsWithASCII(board, "lumpy", false); | 47 return StartsWithASCII(board, "lumpy", false); |
46 } | 48 } |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
52 using ash::internal::DisplayController; | |
53 | |
50 static const char kFallbackInputMethodLocale[] = "en-US"; | 54 static const char kFallbackInputMethodLocale[] = "en-US"; |
51 | 55 |
52 Preferences::Preferences() | 56 Preferences::Preferences() |
53 : prefs_(NULL), | 57 : prefs_(NULL), |
54 input_method_manager_(input_method::InputMethodManager::GetInstance()) { | 58 input_method_manager_(input_method::InputMethodManager::GetInstance()) { |
55 } | 59 } |
56 | 60 |
57 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) | 61 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
58 : input_method_manager_(input_method_manager) { | 62 : input_method_manager_(input_method_manager) { |
59 } | 63 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 PrefService::UNSYNCABLE_PREF); | 239 PrefService::UNSYNCABLE_PREF); |
236 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, | 240 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, |
237 language_prefs::kXkbAutoRepeatIntervalInMs, | 241 language_prefs::kXkbAutoRepeatIntervalInMs, |
238 PrefService::UNSYNCABLE_PREF); | 242 PrefService::UNSYNCABLE_PREF); |
239 | 243 |
240 // Screen lock default to off. | 244 // Screen lock default to off. |
241 prefs->RegisterBooleanPref(prefs::kEnableScreenLock, | 245 prefs->RegisterBooleanPref(prefs::kEnableScreenLock, |
242 false, | 246 false, |
243 PrefService::SYNCABLE_PREF); | 247 PrefService::SYNCABLE_PREF); |
244 | 248 |
249 // Secondary display layout. | |
250 prefs->RegisterIntegerPref(prefs::kSecondaryDisplayLayout, | |
251 static_cast<int>(DisplayController::RIGHT), | |
252 PrefService::UNSYNCABLE_PREF); | |
253 | |
245 // Mobile plan notifications default to on. | 254 // Mobile plan notifications default to on. |
246 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, | 255 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, |
247 true, | 256 true, |
248 PrefService::SYNCABLE_PREF); | 257 PrefService::SYNCABLE_PREF); |
249 | 258 |
250 // 3G first-time usage promo will be shown at least once. | 259 // 3G first-time usage promo will be shown at least once. |
251 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, | 260 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, |
252 true, | 261 true, |
253 PrefService::UNSYNCABLE_PREF); | 262 PrefService::UNSYNCABLE_PREF); |
254 | 263 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 } | 351 } |
343 xkb_auto_repeat_enabled_.Init( | 352 xkb_auto_repeat_enabled_.Init( |
344 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); | 353 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); |
345 xkb_auto_repeat_delay_pref_.Init( | 354 xkb_auto_repeat_delay_pref_.Init( |
346 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); | 355 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); |
347 xkb_auto_repeat_interval_pref_.Init( | 356 xkb_auto_repeat_interval_pref_.Init( |
348 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); | 357 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); |
349 | 358 |
350 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); | 359 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); |
351 | 360 |
361 secondary_display_layout_.Init(prefs::kSecondaryDisplayLayout, prefs, this); | |
362 | |
352 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); | 363 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); |
353 } | 364 } |
354 | 365 |
355 void Preferences::Init(PrefService* prefs) { | 366 void Preferences::Init(PrefService* prefs) { |
356 InitUserPrefs(prefs); | 367 InitUserPrefs(prefs); |
357 | 368 |
358 // Initialize preferences to currently saved state. | 369 // Initialize preferences to currently saved state. |
359 NotifyPrefChanged(NULL); | 370 NotifyPrefChanged(NULL); |
360 | 371 |
361 // If a guest is logged in, initialize the prefs as if this is the first | 372 // If a guest is logged in, initialize the prefs as if this is the first |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 mozc_integer_prefs_[i].GetValue()); | 570 mozc_integer_prefs_[i].GetValue()); |
560 } | 571 } |
561 } | 572 } |
562 | 573 |
563 // Init or update power manager config. | 574 // Init or update power manager config. |
564 if (!pref_name || *pref_name == prefs::kEnableScreenLock) { | 575 if (!pref_name || *pref_name == prefs::kEnableScreenLock) { |
565 system::power_manager_settings::EnableScreenLock( | 576 system::power_manager_settings::EnableScreenLock( |
566 enable_screen_lock_.GetValue()); | 577 enable_screen_lock_.GetValue()); |
567 } | 578 } |
568 | 579 |
580 if (!pref_name || *pref_name == prefs::kSecondaryDisplayLayout) { | |
581 int layout = secondary_display_layout_.GetValue(); | |
582 DCHECK_LE(static_cast<int>(DisplayController::TOP), layout); | |
583 DCHECK_GE(static_cast<int>(DisplayController::LEFT), layout); | |
oshima
2012/07/26 15:05:19
it's probably better to ignore the value if it's o
Jun Mukai
2012/07/26 16:29:49
Done.
| |
584 ash::Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | |
585 static_cast<DisplayController::SecondaryDisplayLayout>(layout)); | |
586 } | |
587 | |
569 // Init or update protected content (DRM) support. | 588 // Init or update protected content (DRM) support. |
570 if (!pref_name || *pref_name == prefs::kEnableCrosDRM) { | 589 if (!pref_name || *pref_name == prefs::kEnableCrosDRM) { |
571 system::ToggleDrm(enable_drm_.GetValue()); | 590 system::ToggleDrm(enable_drm_.GetValue()); |
572 } | 591 } |
573 | 592 |
574 // Change the download directory to the default value if a GData directory is | 593 // Change the download directory to the default value if a GData directory is |
575 // selected and GData is disabled. | 594 // selected and GData is disabled. |
576 if (!pref_name || *pref_name == prefs::kDisableGData) { | 595 if (!pref_name || *pref_name == prefs::kDisableGData) { |
577 if (disable_gdata_.GetValue()) { | 596 if (disable_gdata_.GetValue()) { |
578 const FilePath download_path = | 597 const FilePath download_path = |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 | 695 |
677 input_method::AutoRepeatRate rate; | 696 input_method::AutoRepeatRate rate; |
678 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); | 697 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
679 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); | 698 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
680 DCHECK(rate.initial_delay_in_ms > 0); | 699 DCHECK(rate.initial_delay_in_ms > 0); |
681 DCHECK(rate.repeat_interval_in_ms > 0); | 700 DCHECK(rate.repeat_interval_in_ms > 0); |
682 input_method::XKeyboard::SetAutoRepeatRate(rate); | 701 input_method::XKeyboard::SetAutoRepeatRate(rate); |
683 } | 702 } |
684 | 703 |
685 } // namespace chromeos | 704 } // namespace chromeos |
OLD | NEW |