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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
10 #include "base/bind_helpers.h"
11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_change_registrar.h"
13 #include "base/prefs/pref_service.h"
14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/profiles/incognito_helpers.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/pref_names.h"
18 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
19 #include "components/user_prefs/pref_registry_syncable.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/overscroll_configuration.h"
23 #include "content/public/common/renderer_preferences.h"
24 #include "ui/base/gestures/gesture_configuration.h"
27 #include "chrome/browser/ui/immersive_fullscreen_configuration.h"
30 using ui::GestureConfiguration
;
34 // TODO(rjkroege): Remove this deprecated pref in M29. http://crbug.com/160243.
35 const char kTouchScreenFlingAccelerationAdjustment
[] =
36 "gesture.touchscreen_fling_acceleration_adjustment";
38 struct OverscrollPref
{
39 const char* pref_name
;
40 content::OverscrollConfig config
;
43 const std::vector
<OverscrollPref
>& GetOverscrollPrefs() {
44 CR_DEFINE_STATIC_LOCAL(std::vector
<OverscrollPref
>, overscroll_prefs
, ());
45 if (overscroll_prefs
.empty()) {
46 using namespace content
;
47 const OverscrollPref kOverscrollPrefs
[] = {
48 { prefs::kOverscrollHorizontalThresholdComplete
,
49 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE
},
50 { prefs::kOverscrollVerticalThresholdComplete
,
51 OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE
},
52 { prefs::kOverscrollMinimumThresholdStart
,
53 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN
},
54 { prefs::kOverscrollMinimumThresholdStartTouchpad
,
55 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD
},
56 { prefs::kOverscrollVerticalThresholdStart
,
57 OVERSCROLL_CONFIG_VERT_THRESHOLD_START
},
58 { prefs::kOverscrollHorizontalResistThreshold
,
59 OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER
},
60 { prefs::kOverscrollVerticalResistThreshold
,
61 OVERSCROLL_CONFIG_VERT_RESIST_AFTER
},
63 overscroll_prefs
.assign(kOverscrollPrefs
,
64 kOverscrollPrefs
+ arraysize(kOverscrollPrefs
));
66 return overscroll_prefs
;
70 const char* kImmersiveModePrefs
[] = {
71 prefs::kImmersiveModeRevealDelayMs
,
72 prefs::kImmersiveModeRevealXThresholdPixels
,
76 // This class manages gesture configuration preferences.
77 class GesturePrefsObserver
: public BrowserContextKeyedService
{
79 explicit GesturePrefsObserver(PrefService
* prefs
);
80 virtual ~GesturePrefsObserver();
82 // BrowserContextKeyedService implementation.
83 virtual void Shutdown() OVERRIDE
;
86 // Notification callback invoked when browser-side preferences
87 // are updated and need to be pushed into ui::GesturePreferences.
90 // Notification callback invoked when the fling deacceleration
91 // gesture preferences are changed from chrome://gesture.
92 // Broadcasts the changes all renderers where they are used.
95 // Notification helper to push overscroll preferences into
97 void UpdateOverscrollPrefs();
99 void UpdateImmersiveModePrefs();
101 PrefChangeRegistrar registrar_
;
104 DISALLOW_COPY_AND_ASSIGN(GesturePrefsObserver
);
107 // The list of prefs we want to observe.
108 // Note that this collection of settings should correspond to the settings used
109 // in ui/base/gestures/gesture_configuration.h
110 const char* kPrefsToObserve
[] = {
111 prefs::kFlingAccelerationCurveCoefficient0
,
112 prefs::kFlingAccelerationCurveCoefficient1
,
113 prefs::kFlingAccelerationCurveCoefficient2
,
114 prefs::kFlingAccelerationCurveCoefficient3
,
115 prefs::kFlingMaxCancelToDownTimeInMs
,
116 prefs::kFlingMaxTapGapTimeInMs
,
117 prefs::kTabScrubActivationDelayInMS
,
118 prefs::kFlingVelocityCap
,
119 prefs::kLongPressTimeInSeconds
,
120 prefs::kMaxDistanceForTwoFingerTapInPixels
,
121 prefs::kMaxSecondsBetweenDoubleClick
,
122 prefs::kMaxSeparationForGestureTouchesInPixels
,
123 prefs::kMaxSwipeDeviationRatio
,
124 prefs::kMaxTouchDownDurationInSecondsForClick
,
125 prefs::kMaxTouchMoveInPixelsForClick
,
126 prefs::kMinDistanceForPinchScrollInPixels
,
127 prefs::kMinFlickSpeedSquared
,
128 prefs::kMinPinchUpdateDistanceInPixels
,
129 prefs::kMinRailBreakVelocity
,
130 prefs::kMinScrollDeltaSquared
,
131 prefs::kMinSwipeSpeed
,
132 prefs::kMinTouchDownDurationInSecondsForClick
,
133 prefs::kPointsBufferedForVelocity
,
134 prefs::kRailBreakProportion
,
135 prefs::kRailStartProportion
,
136 prefs::kSemiLongPressTimeInSeconds
,
139 const char* kFlingTouchpadPrefs
[] = {
140 prefs::kFlingCurveTouchpadAlpha
,
141 prefs::kFlingCurveTouchpadBeta
,
142 prefs::kFlingCurveTouchpadGamma
145 const char* kFlingTouchscreenPrefs
[] = {
146 prefs::kFlingCurveTouchscreenAlpha
,
147 prefs::kFlingCurveTouchscreenBeta
,
148 prefs::kFlingCurveTouchscreenGamma
,
151 GesturePrefsObserver::GesturePrefsObserver(PrefService
* prefs
)
153 // Clear for migration.
154 prefs
->ClearPref(kTouchScreenFlingAccelerationAdjustment
);
156 // TODO(mohsen): Remove following code in M32. By then, gesture prefs will
157 // have been cleared for majority of the users: crbug.com/269292.
158 // Do a one-time wipe of all gesture preferences.
159 if (!prefs
->GetBoolean(prefs::kGestureConfigIsTrustworthy
)) {
160 for (size_t i
= 0; i
< arraysize(kPrefsToObserve
); ++i
)
161 prefs
->ClearPref(kPrefsToObserve
[i
]);
163 const std::vector
<OverscrollPref
>& overscroll_prefs
= GetOverscrollPrefs();
164 for (size_t i
= 0; i
< overscroll_prefs
.size(); ++i
)
165 prefs
->ClearPref(overscroll_prefs
[i
].pref_name
);
167 for (size_t i
= 0; i
< arraysize(kFlingTouchpadPrefs
); ++i
)
168 prefs
->ClearPref(kFlingTouchpadPrefs
[i
]);
170 for (size_t i
= 0; i
< arraysize(kFlingTouchscreenPrefs
); ++i
)
171 prefs
->ClearPref(kFlingTouchscreenPrefs
[i
]);
174 for (size_t i
= 0; i
< arraysize(kImmersiveModePrefs
); ++i
)
175 prefs
->ClearPref(kImmersiveModePrefs
[i
]);
178 prefs
->SetBoolean(prefs::kGestureConfigIsTrustworthy
, true);
181 registrar_
.Init(prefs
);
182 registrar_
.RemoveAll();
183 base::Closure callback
= base::Bind(&GesturePrefsObserver::Update
,
184 base::Unretained(this));
186 base::Closure notify_callback
= base::Bind(&GesturePrefsObserver::Notify
,
187 base::Unretained(this));
189 for (size_t i
= 0; i
< arraysize(kPrefsToObserve
); ++i
)
190 registrar_
.Add(kPrefsToObserve
[i
], callback
);
192 const std::vector
<OverscrollPref
>& overscroll_prefs
= GetOverscrollPrefs();
193 for (size_t i
= 0; i
< overscroll_prefs
.size(); ++i
)
194 registrar_
.Add(overscroll_prefs
[i
].pref_name
, callback
);
196 for (size_t i
= 0; i
< arraysize(kFlingTouchpadPrefs
); ++i
)
197 registrar_
.Add(kFlingTouchpadPrefs
[i
], notify_callback
);
198 for (size_t i
= 0; i
< arraysize(kFlingTouchscreenPrefs
); ++i
)
199 registrar_
.Add(kFlingTouchscreenPrefs
[i
], notify_callback
);
202 for (size_t i
= 0; i
< arraysize(kImmersiveModePrefs
); ++i
)
203 registrar_
.Add(kImmersiveModePrefs
[i
], callback
);
208 GesturePrefsObserver::~GesturePrefsObserver() {}
210 void GesturePrefsObserver::Shutdown() {
211 registrar_
.RemoveAll();
214 void GesturePrefsObserver::Update() {
215 GestureConfiguration::set_fling_acceleration_curve_coefficients(0,
216 prefs_
->GetDouble(prefs::kFlingAccelerationCurveCoefficient0
));
217 GestureConfiguration::set_fling_acceleration_curve_coefficients(1,
218 prefs_
->GetDouble(prefs::kFlingAccelerationCurveCoefficient1
));
219 GestureConfiguration::set_fling_acceleration_curve_coefficients(2,
220 prefs_
->GetDouble(prefs::kFlingAccelerationCurveCoefficient2
));
221 GestureConfiguration::set_fling_acceleration_curve_coefficients(3,
222 prefs_
->GetDouble(prefs::kFlingAccelerationCurveCoefficient3
));
223 GestureConfiguration::set_fling_max_cancel_to_down_time_in_ms(
224 prefs_
->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs
));
225 GestureConfiguration::set_fling_max_tap_gap_time_in_ms(
226 prefs_
->GetInteger(prefs::kFlingMaxTapGapTimeInMs
));
227 GestureConfiguration::set_tab_scrub_activation_delay_in_ms(
228 prefs_
->GetInteger(prefs::kTabScrubActivationDelayInMS
));
229 GestureConfiguration::set_fling_velocity_cap(
230 prefs_
->GetDouble(prefs::kFlingVelocityCap
));
231 GestureConfiguration::set_long_press_time_in_seconds(
233 prefs::kLongPressTimeInSeconds
));
234 GestureConfiguration::set_semi_long_press_time_in_seconds(
236 prefs::kSemiLongPressTimeInSeconds
));
237 GestureConfiguration::set_max_distance_for_two_finger_tap_in_pixels(
239 prefs::kMaxDistanceForTwoFingerTapInPixels
));
240 GestureConfiguration::set_max_seconds_between_double_click(
242 prefs::kMaxSecondsBetweenDoubleClick
));
243 GestureConfiguration::set_max_separation_for_gesture_touches_in_pixels(
245 prefs::kMaxSeparationForGestureTouchesInPixels
));
246 GestureConfiguration::set_max_swipe_deviation_ratio(
248 prefs::kMaxSwipeDeviationRatio
));
249 GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click(
251 prefs::kMaxTouchDownDurationInSecondsForClick
));
252 GestureConfiguration::set_max_touch_move_in_pixels_for_click(
254 prefs::kMaxTouchMoveInPixelsForClick
));
255 GestureConfiguration::set_max_distance_between_taps_for_double_tap(
257 prefs::kMaxDistanceBetweenTapsForDoubleTap
));
258 GestureConfiguration::set_min_distance_for_pinch_scroll_in_pixels(
260 prefs::kMinDistanceForPinchScrollInPixels
));
261 GestureConfiguration::set_min_flick_speed_squared(
263 prefs::kMinFlickSpeedSquared
));
264 GestureConfiguration::set_min_pinch_update_distance_in_pixels(
266 prefs::kMinPinchUpdateDistanceInPixels
));
267 GestureConfiguration::set_min_rail_break_velocity(
269 prefs::kMinRailBreakVelocity
));
270 GestureConfiguration::set_min_scroll_delta_squared(
272 prefs::kMinScrollDeltaSquared
));
273 GestureConfiguration::set_min_swipe_speed(
275 prefs::kMinSwipeSpeed
));
276 GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click(
278 prefs::kMinTouchDownDurationInSecondsForClick
));
279 GestureConfiguration::set_points_buffered_for_velocity(
281 prefs::kPointsBufferedForVelocity
));
282 GestureConfiguration::set_rail_break_proportion(
284 prefs::kRailBreakProportion
));
285 GestureConfiguration::set_rail_start_proportion(
287 prefs::kRailStartProportion
));
288 GestureConfiguration::set_scroll_prediction_seconds(
289 prefs_
->GetDouble(prefs::kScrollPredictionSeconds
));
291 UpdateOverscrollPrefs();
292 UpdateImmersiveModePrefs();
295 void GesturePrefsObserver::UpdateOverscrollPrefs() {
296 const std::vector
<OverscrollPref
>& overscroll_prefs
= GetOverscrollPrefs();
297 for (size_t i
= 0; i
< overscroll_prefs
.size(); ++i
) {
298 content::SetOverscrollConfig(overscroll_prefs
[i
].config
,
299 static_cast<float>(prefs_
->GetDouble(overscroll_prefs
[i
].pref_name
)));
303 void GesturePrefsObserver::UpdateImmersiveModePrefs() {
305 ImmersiveFullscreenConfiguration::set_immersive_mode_reveal_delay_ms(
306 prefs_
->GetInteger(prefs::kImmersiveModeRevealDelayMs
));
307 ImmersiveFullscreenConfiguration::
308 set_immersive_mode_reveal_x_threshold_pixels(
309 prefs_
->GetInteger(prefs::kImmersiveModeRevealXThresholdPixels
));
313 void GesturePrefsObserver::Notify() {
314 // Must do a notify to distribute the changes to all renderers.
315 content::NotificationService
* service
=
316 content::NotificationService::current();
317 service
->Notify(chrome::NOTIFICATION_BROWSER_FLING_CURVE_PARAMETERS_CHANGED
,
318 content::Source
<GesturePrefsObserver
>(this),
319 content::NotificationService::NoDetails());
325 GesturePrefsObserverFactoryAura
*
326 GesturePrefsObserverFactoryAura::GetInstance() {
327 return Singleton
<GesturePrefsObserverFactoryAura
>::get();
330 GesturePrefsObserverFactoryAura::GesturePrefsObserverFactoryAura()
331 : BrowserContextKeyedServiceFactory(
332 "GesturePrefsObserverAura",
333 BrowserContextDependencyManager::GetInstance()) {}
335 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {}
337 BrowserContextKeyedService
*
338 GesturePrefsObserverFactoryAura::BuildServiceInstanceFor(
339 content::BrowserContext
* profile
) const {
340 return new GesturePrefsObserver(static_cast<Profile
*>(profile
)->GetPrefs());
343 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs(
344 user_prefs::PrefRegistrySyncable
* registry
) {
345 const std::vector
<OverscrollPref
>& overscroll_prefs
= GetOverscrollPrefs();
347 for (size_t i
= 0; i
< overscroll_prefs
.size(); ++i
) {
348 registry
->RegisterDoublePref(
349 overscroll_prefs
[i
].pref_name
,
350 content::GetOverscrollConfig(overscroll_prefs
[i
].config
),
351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
355 void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters(
356 user_prefs::PrefRegistrySyncable
* registry
) {
357 content::RendererPreferences def_prefs
;
359 for (size_t i
= 0; i
< arraysize(kFlingTouchpadPrefs
); i
++)
360 registry
->RegisterDoublePref(
361 kFlingTouchpadPrefs
[i
],
362 def_prefs
.touchpad_fling_profile
[i
],
363 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
365 for (size_t i
= 0; i
< arraysize(kFlingTouchscreenPrefs
); i
++)
366 registry
->RegisterDoublePref(
367 kFlingTouchscreenPrefs
[i
],
368 def_prefs
.touchscreen_fling_profile
[i
],
369 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
372 void GesturePrefsObserverFactoryAura::RegisterImmersiveModePrefs(
373 user_prefs::PrefRegistrySyncable
* registry
) {
375 registry
->RegisterIntegerPref(
376 prefs::kImmersiveModeRevealDelayMs
,
377 ImmersiveFullscreenConfiguration::immersive_mode_reveal_delay_ms(),
378 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
379 registry
->RegisterIntegerPref(
380 prefs::kImmersiveModeRevealXThresholdPixels
,
381 ImmersiveFullscreenConfiguration::
382 immersive_mode_reveal_x_threshold_pixels(),
383 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
387 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs(
388 user_prefs::PrefRegistrySyncable
* registry
) {
389 registry
->RegisterDoublePref(
390 prefs::kFlingAccelerationCurveCoefficient0
,
391 GestureConfiguration::fling_acceleration_curve_coefficients(0),
392 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
393 registry
->RegisterDoublePref(
394 prefs::kFlingAccelerationCurveCoefficient1
,
395 GestureConfiguration::fling_acceleration_curve_coefficients(1),
396 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
397 registry
->RegisterDoublePref(
398 prefs::kFlingAccelerationCurveCoefficient2
,
399 GestureConfiguration::fling_acceleration_curve_coefficients(2),
400 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
401 registry
->RegisterDoublePref(
402 prefs::kFlingAccelerationCurveCoefficient3
,
403 GestureConfiguration::fling_acceleration_curve_coefficients(3),
404 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
405 registry
->RegisterIntegerPref(
406 prefs::kFlingMaxCancelToDownTimeInMs
,
407 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(),
408 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
409 registry
->RegisterIntegerPref(
410 prefs::kFlingMaxTapGapTimeInMs
,
411 GestureConfiguration::fling_max_tap_gap_time_in_ms(),
412 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
413 registry
->RegisterIntegerPref(
414 prefs::kTabScrubActivationDelayInMS
,
415 GestureConfiguration::tab_scrub_activation_delay_in_ms(),
416 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
417 registry
->RegisterDoublePref(
418 prefs::kFlingVelocityCap
,
419 GestureConfiguration::fling_velocity_cap(),
420 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
421 registry
->RegisterDoublePref(
422 prefs::kLongPressTimeInSeconds
,
423 GestureConfiguration::long_press_time_in_seconds(),
424 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
425 registry
->RegisterDoublePref(
426 prefs::kSemiLongPressTimeInSeconds
,
427 GestureConfiguration::semi_long_press_time_in_seconds(),
428 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
429 registry
->RegisterDoublePref(
430 prefs::kMaxDistanceForTwoFingerTapInPixels
,
431 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(),
432 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
433 registry
->RegisterDoublePref(
434 prefs::kMaxSecondsBetweenDoubleClick
,
435 GestureConfiguration::max_seconds_between_double_click(),
436 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
437 registry
->RegisterDoublePref(
438 prefs::kMaxSeparationForGestureTouchesInPixels
,
439 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(),
440 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
441 registry
->RegisterDoublePref(
442 prefs::kMaxSwipeDeviationRatio
,
443 GestureConfiguration::max_swipe_deviation_ratio(),
444 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
445 registry
->RegisterDoublePref(
446 prefs::kMaxTouchDownDurationInSecondsForClick
,
447 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(),
448 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
449 registry
->RegisterDoublePref(
450 prefs::kMaxTouchMoveInPixelsForClick
,
451 GestureConfiguration::max_touch_move_in_pixels_for_click(),
452 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
453 registry
->RegisterDoublePref(
454 prefs::kMaxDistanceBetweenTapsForDoubleTap
,
455 GestureConfiguration::max_distance_between_taps_for_double_tap(),
456 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
457 registry
->RegisterDoublePref(
458 prefs::kMinDistanceForPinchScrollInPixels
,
459 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(),
460 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
461 registry
->RegisterDoublePref(
462 prefs::kMinFlickSpeedSquared
,
463 GestureConfiguration::min_flick_speed_squared(),
464 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
465 registry
->RegisterDoublePref(
466 prefs::kMinPinchUpdateDistanceInPixels
,
467 GestureConfiguration::min_pinch_update_distance_in_pixels(),
468 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
469 registry
->RegisterDoublePref(
470 prefs::kMinRailBreakVelocity
,
471 GestureConfiguration::min_rail_break_velocity(),
472 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
473 registry
->RegisterDoublePref(
474 prefs::kMinScrollDeltaSquared
,
475 GestureConfiguration::min_scroll_delta_squared(),
476 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
477 registry
->RegisterDoublePref(
478 prefs::kMinSwipeSpeed
,
479 GestureConfiguration::min_swipe_speed(),
480 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
481 registry
->RegisterDoublePref(
482 prefs::kMinTouchDownDurationInSecondsForClick
,
483 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(),
484 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
485 registry
->RegisterIntegerPref(
486 prefs::kPointsBufferedForVelocity
,
487 GestureConfiguration::points_buffered_for_velocity(),
488 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
489 registry
->RegisterDoublePref(
490 prefs::kRailBreakProportion
,
491 GestureConfiguration::rail_break_proportion(),
492 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
493 registry
->RegisterDoublePref(
494 prefs::kRailStartProportion
,
495 GestureConfiguration::rail_start_proportion(),
496 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
497 registry
->RegisterDoublePref(
498 prefs::kScrollPredictionSeconds
,
499 GestureConfiguration::scroll_prediction_seconds(),
500 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
502 // Register for migration.
503 registry
->RegisterDoublePref(
504 kTouchScreenFlingAccelerationAdjustment
,
506 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
508 RegisterOverscrollPrefs(registry
);
509 RegisterFlingCurveParameters(registry
);
510 RegisterImmersiveModePrefs(registry
);
512 // Register pref for a one-time wipe of all gesture preferences.
513 registry
->RegisterBooleanPref(
514 prefs::kGestureConfigIsTrustworthy
,
516 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
520 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const {
521 // Create the observer as soon as the profile is created.
525 content::BrowserContext
*
526 GesturePrefsObserverFactoryAura::GetBrowserContextToUse(
527 content::BrowserContext
* context
) const {
528 // Use same gesture preferences on incognito windows.
529 return chrome::GetBrowserContextRedirectedInIncognito(context
);
532 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const {
533 // Some tests replace the PrefService of the TestingProfile after the
534 // GesturePrefsObserver has been created, which makes Shutdown()
535 // remove the registrar from a non-existent PrefService.