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

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

Issue 756363003: Revert of Sync starting language and input method preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years 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
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "ash/autoclick/autoclick_controller.h" 9 #include "ash/autoclick/autoclick_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/i18n/time_formatting.h" 12 #include "base/i18n/time_formatting.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_member.h" 14 #include "base/prefs/pref_member.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/scoped_user_pref_update.h" 16 #include "base/prefs/scoped_user_pref_update.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/sys_info.h" 20 #include "base/sys_info.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
24 #include "chrome/browser/chromeos/drive/file_system_util.h" 24 #include "chrome/browser/chromeos/drive/file_system_util.h"
25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" 25 #include "chrome/browser/chromeos/input_method/input_method_util.h"
26 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 26 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" 27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
28 #include "chrome/browser/chromeos/profiles/profile_helper.h"
28 #include "chrome/browser/chromeos/system/input_device_settings.h" 29 #include "chrome/browser/chromeos/system/input_device_settings.h"
29 #include "chrome/browser/download/download_prefs.h" 30 #include "chrome/browser/download/download_prefs.h"
30 #include "chrome/browser/prefs/pref_service_syncable.h" 31 #include "chrome/browser/prefs/pref_service_syncable.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
33 #include "chromeos/chromeos_switches.h" 34 #include "chromeos/chromeos_switches.h"
34 #include "chromeos/system/statistics_provider.h" 35 #include "chromeos/system/statistics_provider.h"
35 #include "components/feedback/tracing_manager.h" 36 #include "components/feedback/tracing_manager.h"
36 #include "components/pref_registry/pref_registry_syncable.h" 37 #include "components/pref_registry/pref_registry_syncable.h"
37 #include "components/user_manager/user.h" 38 #include "components/user_manager/user.h"
38 #include "content/public/browser/browser_thread.h"
39 #include "third_party/icu/source/i18n/unicode/timezone.h" 39 #include "third_party/icu/source/i18n/unicode/timezone.h"
40 #include "ui/base/ime/chromeos/extension_ime_util.h" 40 #include "ui/base/ime/chromeos/extension_ime_util.h"
41 #include "ui/base/ime/chromeos/ime_keyboard.h" 41 #include "ui/base/ime/chromeos/ime_keyboard.h"
42 #include "ui/base/ime/chromeos/input_method_manager.h" 42 #include "ui/base/ime/chromeos/input_method_manager.h"
43 #include "ui/chromeos/accessibility_types.h" 43 #include "ui/chromeos/accessibility_types.h"
44 #include "ui/events/event_constants.h" 44 #include "ui/events/event_constants.h"
45 #include "ui/events/event_utils.h" 45 #include "ui/events/event_utils.h"
46 #include "url/gurl.h" 46 #include "url/gurl.h"
47 47
48 namespace chromeos { 48 namespace chromeos {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod 209 // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod
210 // because they're just used to track the logout state of the device. 210 // because they're just used to track the logout state of the device.
211 registry->RegisterStringPref( 211 registry->RegisterStringPref(
212 prefs::kLanguageCurrentInputMethod, 212 prefs::kLanguageCurrentInputMethod,
213 "", 213 "",
214 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 214 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
215 registry->RegisterStringPref( 215 registry->RegisterStringPref(
216 prefs::kLanguagePreviousInputMethod, 216 prefs::kLanguagePreviousInputMethod,
217 "", 217 "",
218 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 218 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
219 // We don't sync the list of input methods and preferred languages since a
220 // user might use two or more devices with different hardware keyboards.
221 // crosbug.com/15181
219 registry->RegisterStringPref( 222 registry->RegisterStringPref(
220 prefs::kLanguagePreferredLanguages, 223 prefs::kLanguagePreferredLanguages,
221 kFallbackInputMethodLocale, 224 kFallbackInputMethodLocale,
222 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 225 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
223 registry->RegisterStringPref( 226 registry->RegisterStringPref(
224 prefs::kLanguagePreloadEngines, 227 prefs::kLanguagePreloadEngines,
225 hardware_keyboard_id, 228 hardware_keyboard_id,
226 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 229 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
227 registry->RegisterStringPref( 230 registry->RegisterStringPref(
228 prefs::kLanguageEnabledExtensionImes, 231 prefs::kLanguageEnabledExtensionImes,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 315
313 registry->RegisterBooleanPref( 316 registry->RegisterBooleanPref(
314 prefs::kTouchHudProjectionEnabled, 317 prefs::kTouchHudProjectionEnabled,
315 false, 318 false,
316 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 319 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
317 320
318 registry->RegisterBooleanPref( 321 registry->RegisterBooleanPref(
319 prefs::kTouchVirtualKeyboardEnabled, 322 prefs::kTouchVirtualKeyboardEnabled,
320 false, 323 false,
321 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 324 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
322
323 input_method::InputMethodSyncer::RegisterProfilePrefs(registry);
324 } 325 }
325 326
326 void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { 327 void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) {
327 prefs_ = prefs; 328 prefs_ = prefs;
328 329
329 BooleanPrefMember::NamedChangeCallback callback = 330 BooleanPrefMember::NamedChangeCallback callback =
330 base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); 331 base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this));
331 332
332 performance_tracing_enabled_.Init(prefs::kPerformanceTracingEnabled, 333 performance_tracing_enabled_.Init(prefs::kPerformanceTracingEnabled,
333 prefs, callback); 334 prefs, callback);
(...skipping 25 matching lines...) Expand all
359 xkb_auto_repeat_interval_pref_.Init( 360 xkb_auto_repeat_interval_pref_.Init(
360 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); 361 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback);
361 362
362 wake_on_wifi_enabled_.Init(prefs::kWakeOnWiFiEnabled, prefs, callback); 363 wake_on_wifi_enabled_.Init(prefs::kWakeOnWiFiEnabled, prefs, callback);
363 } 364 }
364 365
365 void Preferences::Init(Profile* profile, const user_manager::User* user) { 366 void Preferences::Init(Profile* profile, const user_manager::User* user) {
366 DCHECK(profile); 367 DCHECK(profile);
367 DCHECK(user); 368 DCHECK(user);
368 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); 369 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile);
369 // This causes OnIsSyncingChanged to be called when the value of
370 // PrefService::IsSyncing() changes.
371 prefs->AddObserver(this);
372 user_ = user; 370 user_ = user;
373 user_is_primary_ = 371 user_is_primary_ =
374 user_manager::UserManager::Get()->GetPrimaryUser() == user_; 372 user_manager::UserManager::Get()->GetPrimaryUser() == user_;
375 InitUserPrefs(prefs); 373 InitUserPrefs(prefs);
376 374
377 user_manager::UserManager::Get()->AddSessionStateObserver(this); 375 user_manager::UserManager::Get()->AddSessionStateObserver(this);
378 376
377 // This causes OnIsSyncingChanged to be called when the value of
378 // PrefService::IsSyncing() changes.
379 prefs->AddObserver(this);
380
379 UserSessionManager* session_manager = UserSessionManager::GetInstance(); 381 UserSessionManager* session_manager = UserSessionManager::GetInstance();
380 DCHECK(session_manager); 382 DCHECK(session_manager);
381 ime_state_ = session_manager->GetDefaultIMEState(profile); 383 ime_state_ = session_manager->GetDefaultIMEState(profile);
382 input_method_manager_->SetState(ime_state_); 384 input_method_manager_->SetState(ime_state_);
383 385
384 // Initialize preferences to currently saved state. 386 // Initialize preferences to currently saved state.
385 ApplyPreferences(REASON_INITIALIZATION, ""); 387 ApplyPreferences(REASON_INITIALIZATION, "");
386 input_method_syncer_.reset(
387 new input_method::InputMethodSyncer(prefs, ime_state_));
388 input_method_syncer_->Initialize();
389 388
390 // If a guest is logged in, initialize the prefs as if this is the first 389 // If a guest is logged in, initialize the prefs as if this is the first
391 // login. For a regular user this is done in 390 // login. For a regular user this is done in
392 // UserSessionManager::InitProfilePreferences(). 391 // UserSessionManager::InitProfilePreferences().
393 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) 392 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
394 session_manager->SetFirstLoginPrefs(profile, std::string(), std::string()); 393 session_manager->SetFirstLoginPrefs(profile, std::string(), std::string());
395 } 394 }
396 395
397 void Preferences::InitUserPrefsForTesting( 396 void Preferences::InitUserPrefsForTesting(
398 PrefServiceSyncable* prefs, 397 PrefServiceSyncable* prefs,
399 const user_manager::User* user, 398 const user_manager::User* user,
400 scoped_refptr<input_method::InputMethodManager::State> ime_state) { 399 scoped_refptr<input_method::InputMethodManager::State> ime_state) {
401 user_ = user; 400 user_ = user;
402 ime_state_ = ime_state; 401 ime_state_ = ime_state;
403 402
404 if (ime_state.get()) 403 if (ime_state.get())
405 input_method_manager_->SetState(ime_state); 404 input_method_manager_->SetState(ime_state);
406 405
407 InitUserPrefs(prefs); 406 InitUserPrefs(prefs);
408
409 input_method_syncer_.reset(
410 new input_method::InputMethodSyncer(prefs, ime_state_));
411 input_method_syncer_->Initialize();
412 } 407 }
413 408
414 void Preferences::SetInputMethodListForTesting() { 409 void Preferences::SetInputMethodListForTesting() {
415 SetInputMethodList(); 410 SetInputMethodList();
416 } 411 }
417 412
418 void Preferences::OnPreferenceChanged(const std::string& pref_name) { 413 void Preferences::OnPreferenceChanged(const std::string& pref_name) {
419 ApplyPreferences(REASON_PREF_CHANGED, pref_name); 414 ApplyPreferences(REASON_PREF_CHANGED, pref_name);
420 } 415 }
421 416
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 else if (reason == REASON_INITIALIZATION) 538 else if (reason == REASON_INITIALIZATION)
544 UMA_HISTOGRAM_BOOLEAN( 539 UMA_HISTOGRAM_BOOLEAN(
545 "FileBrowser.DownloadDestination.IsGoogleDrive.Started", 540 "FileBrowser.DownloadDestination.IsGoogleDrive.Started",
546 default_download_to_drive); 541 default_download_to_drive);
547 } 542 }
548 if (reason != REASON_PREF_CHANGED || 543 if (reason != REASON_PREF_CHANGED ||
549 pref_name == prefs::kTouchHudProjectionEnabled) { 544 pref_name == prefs::kTouchHudProjectionEnabled) {
550 #if !defined(USE_ATHENA) 545 #if !defined(USE_ATHENA)
551 if (user_is_active) { 546 if (user_is_active) {
552 const bool enabled = touch_hud_projection_enabled_.GetValue(); 547 const bool enabled = touch_hud_projection_enabled_.GetValue();
553 // There may not be a shell, e.g., in some unit tests. 548 ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled);
554 if (ash::Shell::HasInstance())
555 ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled);
556 } 549 }
557 #endif 550 #endif
558 } 551 }
559 552
560 if (reason != REASON_PREF_CHANGED || 553 if (reason != REASON_PREF_CHANGED ||
561 pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { 554 pref_name == prefs::kLanguageXkbAutoRepeatEnabled) {
562 if (user_is_active) { 555 if (user_is_active) {
563 const bool enabled = xkb_auto_repeat_enabled_.GetValue(); 556 const bool enabled = xkb_auto_repeat_enabled_.GetValue();
564 input_method::InputMethodManager::Get() 557 input_method::InputMethodManager::Get()
565 ->GetImeKeyboard() 558 ->GetImeKeyboard()
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 touch_hud_projection_enabled_.SetValue(enabled); 685 touch_hud_projection_enabled_.SetValue(enabled);
693 } 686 }
694 687
695 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 688 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
696 if (active_user != user_) 689 if (active_user != user_)
697 return; 690 return;
698 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 691 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
699 } 692 }
700 693
701 } // namespace chromeos 694 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698