| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/gesture_prefs_observer_factory_aura.h" | 5 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 prefs::kFlingCurveTouchscreenAlpha, | 133 prefs::kFlingCurveTouchscreenAlpha, |
| 134 prefs::kFlingCurveTouchscreenBeta, | 134 prefs::kFlingCurveTouchscreenBeta, |
| 135 prefs::kFlingCurveTouchscreenGamma, | 135 prefs::kFlingCurveTouchscreenGamma, |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 GesturePrefsObserver::GesturePrefsObserver(PrefService* prefs) | 138 GesturePrefsObserver::GesturePrefsObserver(PrefService* prefs) |
| 139 : prefs_(prefs) { | 139 : prefs_(prefs) { |
| 140 // Clear for migration. | 140 // Clear for migration. |
| 141 prefs->ClearPref(kMinScrollSuccessiveVelocityEvents); | 141 prefs->ClearPref(kMinScrollSuccessiveVelocityEvents); |
| 142 | 142 |
| 143 // Clear temporary pref gesture.config_is_trustworthy, so that in M33, we can | |
| 144 // remove it completely: crbug.com/269292. | |
| 145 prefs->ClearPref(prefs::kGestureConfigIsTrustworthy); | |
| 146 | |
| 147 registrar_.Init(prefs); | 143 registrar_.Init(prefs); |
| 148 registrar_.RemoveAll(); | 144 registrar_.RemoveAll(); |
| 149 base::Closure callback = base::Bind(&GesturePrefsObserver::Update, | 145 base::Closure callback = base::Bind(&GesturePrefsObserver::Update, |
| 150 base::Unretained(this)); | 146 base::Unretained(this)); |
| 151 | 147 |
| 152 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify, | 148 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify, |
| 153 base::Unretained(this)); | 149 base::Unretained(this)); |
| 154 | 150 |
| 155 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i) | 151 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i) |
| 156 registrar_.Add(kPrefsToObserve[i], callback); | 152 registrar_.Add(kPrefsToObserve[i], callback); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 438 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 443 | 439 |
| 444 // Register for migration. | 440 // Register for migration. |
| 445 registry->RegisterIntegerPref( | 441 registry->RegisterIntegerPref( |
| 446 kMinScrollSuccessiveVelocityEvents, | 442 kMinScrollSuccessiveVelocityEvents, |
| 447 0, | 443 0, |
| 448 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 444 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 449 | 445 |
| 450 RegisterOverscrollPrefs(registry); | 446 RegisterOverscrollPrefs(registry); |
| 451 RegisterFlingCurveParameters(registry); | 447 RegisterFlingCurveParameters(registry); |
| 452 | |
| 453 // Register pref for a one-time wipe of all gesture preferences. | |
| 454 registry->RegisterBooleanPref( | |
| 455 prefs::kGestureConfigIsTrustworthy, | |
| 456 false, | |
| 457 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 458 } | 448 } |
| 459 | 449 |
| 460 bool | 450 bool |
| 461 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { | 451 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { |
| 462 // Create the observer as soon as the profile is created. | 452 // Create the observer as soon as the profile is created. |
| 463 return true; | 453 return true; |
| 464 } | 454 } |
| 465 | 455 |
| 466 content::BrowserContext* | 456 content::BrowserContext* |
| 467 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( | 457 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( |
| 468 content::BrowserContext* context) const { | 458 content::BrowserContext* context) const { |
| 469 // Use same gesture preferences on incognito windows. | 459 // Use same gesture preferences on incognito windows. |
| 470 return chrome::GetBrowserContextRedirectedInIncognito(context); | 460 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 471 } | 461 } |
| 472 | 462 |
| 473 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 463 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
| 474 // Some tests replace the PrefService of the TestingProfile after the | 464 // Some tests replace the PrefService of the TestingProfile after the |
| 475 // GesturePrefsObserver has been created, which makes Shutdown() | 465 // GesturePrefsObserver has been created, which makes Shutdown() |
| 476 // remove the registrar from a non-existent PrefService. | 466 // remove the registrar from a non-existent PrefService. |
| 477 return true; | 467 return true; |
| 478 } | 468 } |
| OLD | NEW |