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

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

Powered by Google App Engine
This is Rietveld 408576698