gesture_prefs_observer_factory_aura.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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. 4 5#include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" 6 7#include <vector> 8 9#include "base/bind.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/profiles/profile.h" 15#include "chrome/browser/profiles/profile_dependency_manager.h" 16#include "chrome/common/chrome_notification_types.h" 17#include "chrome/common/pref_names.h" 18#include "components/user_prefs/pref_registry_syncable.h" 19#include "content/public/browser/notification_observer.h" 20#include "content/public/browser/notification_service.h" 21#include "content/public/browser/overscroll_configuration.h" 22#include "content/public/common/renderer_preferences.h" 23#include "ui/base/gestures/gesture_configuration.h" 24 25#if defined(USE_ASH) 26#include "ash/wm/workspace/workspace_cycler_configuration.h" 27#endif // USE_ASH 28 29#if defined(USE_ASH) 30using ash::WorkspaceCyclerConfiguration; 31#endif // USE_ASH 32 33using ui::GestureConfiguration; 34 35namespace { 36 37// TODO(rjkroege): Remove this deprecated pref in M29. http://crbug.com/160243. 38const char kTouchScreenFlingAccelerationAdjustment[] = 39 "gesture.touchscreen_fling_acceleration_adjustment"; 40 41struct OverscrollPref { 42 const char* pref_name; 43 content::OverscrollConfig config; 44}; 45 46const std::vector<OverscrollPref>& GetOverscrollPrefs() { 47 CR_DEFINE_STATIC_LOCAL(std::vector<OverscrollPref>, overscroll_prefs, ()); 48 if (overscroll_prefs.empty()) { 49 using namespace content; 50 const OverscrollPref kOverscrollPrefs[] = { 51 { prefs::kOverscrollHorizontalThresholdComplete, 52 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE }, 53 { prefs::kOverscrollVerticalThresholdComplete, 54 OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE }, 55 { prefs::kOverscrollMinimumThresholdStart, 56 OVERSCROLL_CONFIG_MIN_THRESHOLD_START }, 57 { prefs::kOverscrollHorizontalResistThreshold, 58 OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER }, 59 { prefs::kOverscrollVerticalResistThreshold, 60 OVERSCROLL_CONFIG_VERT_RESIST_AFTER }, 61 }; 62 overscroll_prefs.assign(kOverscrollPrefs, 63 kOverscrollPrefs + arraysize(kOverscrollPrefs)); 64 } 65 return overscroll_prefs; 66} 67 68#if defined(USE_ASH) 69struct WorkspaceCyclerPref { 70 const char* pref_name; 71 WorkspaceCyclerConfiguration::Property property; 72}; 73 74const std::vector<WorkspaceCyclerPref>& GetWorkspaceCyclerPrefs() { 75 CR_DEFINE_STATIC_LOCAL(std::vector<WorkspaceCyclerPref>, cycler_prefs, ()); 76 if (cycler_prefs.empty()) { 77 const WorkspaceCyclerPref kCyclerPrefs[] = { 78 { prefs::kWorkspaceCyclerShallowerThanSelectedYOffsets, 79 WorkspaceCyclerConfiguration::SHALLOWER_THAN_SELECTED_Y_OFFSETS }, 80 { prefs::kWorkspaceCyclerDeeperThanSelectedYOffsets, 81 WorkspaceCyclerConfiguration::DEEPER_THAN_SELECTED_Y_OFFSETS }, 82 { prefs::kWorkspaceCyclerSelectedYOffset, 83 WorkspaceCyclerConfiguration::SELECTED_Y_OFFSET }, 84 { prefs::kWorkspaceCyclerSelectedScale, 85 WorkspaceCyclerConfiguration::SELECTED_SCALE }, 86 { prefs::kWorkspaceCyclerMinScale, 87 WorkspaceCyclerConfiguration::MIN_SCALE }, 88 { prefs::kWorkspaceCyclerMaxScale, 89 WorkspaceCyclerConfiguration::MAX_SCALE }, 90 { prefs::kWorkspaceCyclerMinBrightness, 91 WorkspaceCyclerConfiguration::MIN_BRIGHTNESS }, 92 { prefs::kWorkspaceCyclerBackgroundOpacity, 93 WorkspaceCyclerConfiguration::BACKGROUND_OPACITY }, 94 { prefs::kWorkspaceCyclerDesktopWorkspaceBrightness, 95 WorkspaceCyclerConfiguration::DESKTOP_WORKSPACE_BRIGHTNESS }, 96 { prefs::kWorkspaceCyclerDistanceToInitiateCycling, 97 WorkspaceCyclerConfiguration::DISTANCE_TO_INITIATE_CYCLING }, 98 { prefs::kWorkspaceCyclerScrollDistanceToCycleToNextWorkspace, 99 WorkspaceCyclerConfiguration:: 100 SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE }, 101 { prefs::kWorkspaceCyclerCyclerStepAnimationDurationRatio, 102 WorkspaceCyclerConfiguration::CYCLER_STEP_ANIMATION_DURATION_RATIO }, 103 { prefs::kWorkspaceCyclerStartCyclerAnimationDuration, 104 WorkspaceCyclerConfiguration::START_CYCLER_ANIMATION_DURATION }, 105 { prefs::kWorkspaceCyclerStopCyclerAnimationDuration, 106 WorkspaceCyclerConfiguration::STOP_CYCLER_ANIMATION_DURATION }, 107 }; 108 cycler_prefs.assign(kCyclerPrefs, kCyclerPrefs + arraysize(kCyclerPrefs)); 109 } 110 return cycler_prefs; 111} 112#endif // USE_ASH 113 114// This class manages gesture configuration preferences. 115class GesturePrefsObserver : public ProfileKeyedService { 116 public: 117 explicit GesturePrefsObserver(PrefService* prefs); 118 virtual ~GesturePrefsObserver(); 119 120 // ProfileKeyedService implementation. 121 virtual void Shutdown() OVERRIDE; 122 123 private: 124 // Notification callback invoked when browser-side preferences 125 // are updated and need to be pushed into ui::GesturePreferences. 126 void Update(); 127 128 // Notification callback invoked when the fling deacceleration 129 // gesture preferences are changed from chrome://gesture. 130 // Broadcasts the changes all renderers where they are used. 131 void Notify(); 132 133 // Notification helper to push overscroll preferences into 134 // content. 135 void UpdateOverscrollPrefs(); 136 void UpdateWorkspaceCyclerPrefs(); 137 138 PrefChangeRegistrar registrar_; 139 PrefService* prefs_; 140 141 DISALLOW_COPY_AND_ASSIGN(GesturePrefsObserver); 142}; 143 144// The list of prefs we want to observe. 145// Note that this collection of settings should correspond to the settings used 146// in ui/base/gestures/gesture_configuration.h 147const char* kPrefsToObserve[] = { 148 prefs::kFlingAccelerationCurveCoefficient0, 149 prefs::kFlingAccelerationCurveCoefficient1, 150 prefs::kFlingAccelerationCurveCoefficient2, 151 prefs::kFlingAccelerationCurveCoefficient3, 152 prefs::kFlingMaxCancelToDownTimeInMs, 153 prefs::kFlingMaxTapGapTimeInMs, 154 prefs::kTabScrubActivationDelayInMS, 155 prefs::kFlingVelocityCap, 156 prefs::kLongPressTimeInSeconds, 157 prefs::kMaxDistanceForTwoFingerTapInPixels, 158 prefs::kMaxSecondsBetweenDoubleClick, 159 prefs::kMaxSeparationForGestureTouchesInPixels, 160 prefs::kMaxSwipeDeviationRatio, 161 prefs::kMaxTouchDownDurationInSecondsForClick, 162 prefs::kMaxTouchMoveInPixelsForClick, 163 prefs::kMinDistanceForPinchScrollInPixels, 164 prefs::kMinFlickSpeedSquared, 165 prefs::kMinPinchUpdateDistanceInPixels, 166 prefs::kMinRailBreakVelocity, 167 prefs::kMinScrollDeltaSquared, 168 prefs::kMinSwipeSpeed, 169 prefs::kMinTouchDownDurationInSecondsForClick, 170 prefs::kPointsBufferedForVelocity, 171 prefs::kRailBreakProportion, 172 prefs::kRailStartProportion, 173 prefs::kSemiLongPressTimeInSeconds, 174}; 175 176const char* kFlingTouchpadPrefs[] = { 177 prefs::kFlingCurveTouchpadAlpha, 178 prefs::kFlingCurveTouchpadBeta, 179 prefs::kFlingCurveTouchpadGamma 180}; 181 182const char* kFlingTouchscreenPrefs[] = { 183 prefs::kFlingCurveTouchscreenAlpha, 184 prefs::kFlingCurveTouchscreenBeta, 185 prefs::kFlingCurveTouchscreenGamma, 186}; 187 188GesturePrefsObserver::GesturePrefsObserver(PrefService* prefs) 189 : prefs_(prefs) { 190 // Clear for migration. 191 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); 192 193 registrar_.Init(prefs); 194 registrar_.RemoveAll(); 195 base::Closure callback = base::Bind(&GesturePrefsObserver::Update, 196 base::Unretained(this)); 197 198 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify, 199 base::Unretained(this)); 200 201 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i) 202 registrar_.Add(kPrefsToObserve[i], callback); 203 204 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); 205 for (size_t i = 0; i < overscroll_prefs.size(); ++i) 206 registrar_.Add(overscroll_prefs[i].pref_name, callback); 207 208 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); ++i) 209 registrar_.Add(kFlingTouchpadPrefs[i], notify_callback); 210 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); ++i) 211 registrar_.Add(kFlingTouchscreenPrefs[i], notify_callback); 212 213#if defined(USE_ASH) 214 const std::vector<WorkspaceCyclerPref>& cycler_prefs = 215 GetWorkspaceCyclerPrefs(); 216 for (size_t i = 0; i < cycler_prefs.size(); ++i) 217 registrar_.Add(cycler_prefs[i].pref_name, callback); 218#endif // USE_ASH 219 Update(); 220} 221 222GesturePrefsObserver::~GesturePrefsObserver() {} 223 224void GesturePrefsObserver::Shutdown() { 225 registrar_.RemoveAll(); 226} 227 228void GesturePrefsObserver::Update() { 229 GestureConfiguration::set_fling_acceleration_curve_coefficients(0, 230 prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient0)); 231 GestureConfiguration::set_fling_acceleration_curve_coefficients(1, 232 prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient1)); 233 GestureConfiguration::set_fling_acceleration_curve_coefficients(2, 234 prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient2)); 235 GestureConfiguration::set_fling_acceleration_curve_coefficients(3, 236 prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient3)); 237 GestureConfiguration::set_fling_max_cancel_to_down_time_in_ms( 238 prefs_->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs)); 239 GestureConfiguration::set_fling_max_tap_gap_time_in_ms( 240 prefs_->GetInteger(prefs::kFlingMaxTapGapTimeInMs)); 241 GestureConfiguration::set_tab_scrub_activation_delay_in_ms( 242 prefs_->GetInteger(prefs::kTabScrubActivationDelayInMS)); 243 GestureConfiguration::set_fling_velocity_cap( 244 prefs_->GetDouble(prefs::kFlingVelocityCap)); 245 GestureConfiguration::set_long_press_time_in_seconds( 246 prefs_->GetDouble( 247 prefs::kLongPressTimeInSeconds)); 248 GestureConfiguration::set_semi_long_press_time_in_seconds( 249 prefs_->GetDouble( 250 prefs::kSemiLongPressTimeInSeconds)); 251 GestureConfiguration::set_max_distance_for_two_finger_tap_in_pixels( 252 prefs_->GetDouble( 253 prefs::kMaxDistanceForTwoFingerTapInPixels)); 254 GestureConfiguration::set_max_seconds_between_double_click( 255 prefs_->GetDouble( 256 prefs::kMaxSecondsBetweenDoubleClick)); 257 GestureConfiguration::set_max_separation_for_gesture_touches_in_pixels( 258 prefs_->GetDouble( 259 prefs::kMaxSeparationForGestureTouchesInPixels)); 260 GestureConfiguration::set_max_swipe_deviation_ratio( 261 prefs_->GetDouble( 262 prefs::kMaxSwipeDeviationRatio)); 263 GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click( 264 prefs_->GetDouble( 265 prefs::kMaxTouchDownDurationInSecondsForClick)); 266 GestureConfiguration::set_max_touch_move_in_pixels_for_click( 267 prefs_->GetDouble( 268 prefs::kMaxTouchMoveInPixelsForClick)); 269 GestureConfiguration::set_max_distance_between_taps_for_double_tap( 270 prefs_->GetDouble( 271 prefs::kMaxDistanceBetweenTapsForDoubleTap)); 272 GestureConfiguration::set_min_distance_for_pinch_scroll_in_pixels( 273 prefs_->GetDouble( 274 prefs::kMinDistanceForPinchScrollInPixels)); 275 GestureConfiguration::set_min_flick_speed_squared( 276 prefs_->GetDouble( 277 prefs::kMinFlickSpeedSquared)); 278 GestureConfiguration::set_min_pinch_update_distance_in_pixels( 279 prefs_->GetDouble( 280 prefs::kMinPinchUpdateDistanceInPixels)); 281 GestureConfiguration::set_min_rail_break_velocity( 282 prefs_->GetDouble( 283 prefs::kMinRailBreakVelocity)); 284 GestureConfiguration::set_min_scroll_delta_squared( 285 prefs_->GetDouble( 286 prefs::kMinScrollDeltaSquared)); 287 GestureConfiguration::set_min_swipe_speed( 288 prefs_->GetDouble( 289 prefs::kMinSwipeSpeed)); 290 GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click( 291 prefs_->GetDouble( 292 prefs::kMinTouchDownDurationInSecondsForClick)); 293 GestureConfiguration::set_points_buffered_for_velocity( 294 prefs_->GetInteger( 295 prefs::kPointsBufferedForVelocity)); 296 GestureConfiguration::set_rail_break_proportion( 297 prefs_->GetDouble( 298 prefs::kRailBreakProportion)); 299 GestureConfiguration::set_rail_start_proportion( 300 prefs_->GetDouble( 301 prefs::kRailStartProportion)); 302 303 UpdateOverscrollPrefs(); 304 UpdateWorkspaceCyclerPrefs(); 305} 306 307void GesturePrefsObserver::UpdateOverscrollPrefs() { 308 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); 309 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { 310 content::SetOverscrollConfig(overscroll_prefs[i].config, 311 static_cast<float>(prefs_->GetDouble(overscroll_prefs[i].pref_name))); 312 } 313} 314 315void GesturePrefsObserver::UpdateWorkspaceCyclerPrefs() { 316#if defined(USE_ASH) 317 const std::vector<WorkspaceCyclerPref>& cycler_prefs = 318 GetWorkspaceCyclerPrefs(); 319 for (size_t i = 0; i < cycler_prefs.size(); ++i) { 320 WorkspaceCyclerConfiguration::Property property = 321 cycler_prefs[i].property; 322 if (WorkspaceCyclerConfiguration::IsListProperty(property)) { 323 WorkspaceCyclerConfiguration::SetListValue(property, 324 *prefs_->GetList(cycler_prefs[i].pref_name)); 325 } else { 326 WorkspaceCyclerConfiguration::SetDouble(property, 327 prefs_->GetDouble(cycler_prefs[i].pref_name)); 328 } 329 } 330#endif // USE_ASH 331} 332 333void GesturePrefsObserver::Notify() { 334 // Must do a notify to distribute the changes to all renderers. 335 content::NotificationService* service = 336 content::NotificationService::current(); 337 service->Notify(chrome::NOTIFICATION_BROWSER_FLING_CURVE_PARAMETERS_CHANGED, 338 content::Source<GesturePrefsObserver>(this), 339 content::NotificationService::NoDetails()); 340} 341 342} // namespace 343 344// static 345GesturePrefsObserverFactoryAura* 346GesturePrefsObserverFactoryAura::GetInstance() { 347 return Singleton<GesturePrefsObserverFactoryAura>::get(); 348} 349 350GesturePrefsObserverFactoryAura::GesturePrefsObserverFactoryAura() 351 : ProfileKeyedServiceFactory("GesturePrefsObserverAura", 352 ProfileDependencyManager::GetInstance()) {} 353 354GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} 355 356ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( 357 Profile* profile) const { 358 return new GesturePrefsObserver(profile->GetPrefs()); 359} 360 361void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( 362 PrefRegistrySyncable* registry) { 363 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); 364 365 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { 366 registry->RegisterDoublePref( 367 overscroll_prefs[i].pref_name, 368 content::GetOverscrollConfig(overscroll_prefs[i].config), 369 PrefRegistrySyncable::UNSYNCABLE_PREF); 370 } 371} 372 373void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters( 374 PrefRegistrySyncable* registry) { 375 content::RendererPreferences def_prefs; 376 377 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); i++) 378 registry->RegisterDoublePref(kFlingTouchpadPrefs[i], 379 def_prefs.touchpad_fling_profile[i], 380 PrefRegistrySyncable::UNSYNCABLE_PREF); 381 382 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); i++) 383 registry->RegisterDoublePref(kFlingTouchscreenPrefs[i], 384 def_prefs.touchscreen_fling_profile[i], 385 PrefRegistrySyncable::UNSYNCABLE_PREF); 386} 387 388void GesturePrefsObserverFactoryAura::RegisterWorkspaceCyclerPrefs( 389 PrefRegistrySyncable* registry) { 390#if defined(USE_ASH) 391 const std::vector<WorkspaceCyclerPref>& cycler_prefs = 392 GetWorkspaceCyclerPrefs(); 393 for (size_t i = 0; i < cycler_prefs.size(); ++i) { 394 WorkspaceCyclerConfiguration::Property property = 395 cycler_prefs[i].property; 396 if (WorkspaceCyclerConfiguration::IsListProperty(property)) { 397 registry->RegisterListPref( 398 cycler_prefs[i].pref_name, 399 WorkspaceCyclerConfiguration::GetListValue(property).DeepCopy(), 400 PrefRegistrySyncable::UNSYNCABLE_PREF); 401 } else { 402 registry->RegisterDoublePref( 403 cycler_prefs[i].pref_name, 404 WorkspaceCyclerConfiguration::GetDouble(property), 405 PrefRegistrySyncable::UNSYNCABLE_PREF); 406 } 407 } 408#endif // USE_ASH 409} 410 411void GesturePrefsObserverFactoryAura::RegisterUserPrefs( 412 PrefRegistrySyncable* registry) { 413 registry->RegisterDoublePref( 414 prefs::kFlingAccelerationCurveCoefficient0, 415 GestureConfiguration::fling_acceleration_curve_coefficients(0), 416 PrefRegistrySyncable::UNSYNCABLE_PREF); 417 registry->RegisterDoublePref( 418 prefs::kFlingAccelerationCurveCoefficient1, 419 GestureConfiguration::fling_acceleration_curve_coefficients(1), 420 PrefRegistrySyncable::UNSYNCABLE_PREF); 421 registry->RegisterDoublePref( 422 prefs::kFlingAccelerationCurveCoefficient2, 423 GestureConfiguration::fling_acceleration_curve_coefficients(2), 424 PrefRegistrySyncable::UNSYNCABLE_PREF); 425 registry->RegisterDoublePref( 426 prefs::kFlingAccelerationCurveCoefficient3, 427 GestureConfiguration::fling_acceleration_curve_coefficients(3), 428 PrefRegistrySyncable::UNSYNCABLE_PREF); 429 registry->RegisterIntegerPref( 430 prefs::kFlingMaxCancelToDownTimeInMs, 431 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), 432 PrefRegistrySyncable::UNSYNCABLE_PREF); 433 registry->RegisterIntegerPref( 434 prefs::kFlingMaxTapGapTimeInMs, 435 GestureConfiguration::fling_max_tap_gap_time_in_ms(), 436 PrefRegistrySyncable::UNSYNCABLE_PREF); 437 registry->RegisterIntegerPref( 438 prefs::kTabScrubActivationDelayInMS, 439 GestureConfiguration::tab_scrub_activation_delay_in_ms(), 440 PrefRegistrySyncable::UNSYNCABLE_PREF); 441 registry->RegisterDoublePref( 442 prefs::kFlingVelocityCap, 443 GestureConfiguration::fling_velocity_cap(), 444 PrefRegistrySyncable::UNSYNCABLE_PREF); 445 registry->RegisterDoublePref( 446 prefs::kLongPressTimeInSeconds, 447 GestureConfiguration::long_press_time_in_seconds(), 448 PrefRegistrySyncable::UNSYNCABLE_PREF); 449 registry->RegisterDoublePref( 450 prefs::kSemiLongPressTimeInSeconds, 451 GestureConfiguration::semi_long_press_time_in_seconds(), 452 PrefRegistrySyncable::UNSYNCABLE_PREF); 453 registry->RegisterDoublePref( 454 prefs::kMaxDistanceForTwoFingerTapInPixels, 455 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), 456 PrefRegistrySyncable::UNSYNCABLE_PREF); 457 registry->RegisterDoublePref( 458 prefs::kMaxSecondsBetweenDoubleClick, 459 GestureConfiguration::max_seconds_between_double_click(), 460 PrefRegistrySyncable::UNSYNCABLE_PREF); 461 registry->RegisterDoublePref( 462 prefs::kMaxSeparationForGestureTouchesInPixels, 463 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), 464 PrefRegistrySyncable::UNSYNCABLE_PREF); 465 registry->RegisterDoublePref( 466 prefs::kMaxSwipeDeviationRatio, 467 GestureConfiguration::max_swipe_deviation_ratio(), 468 PrefRegistrySyncable::UNSYNCABLE_PREF); 469 registry->RegisterDoublePref( 470 prefs::kMaxTouchDownDurationInSecondsForClick, 471 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), 472 PrefRegistrySyncable::UNSYNCABLE_PREF); 473 registry->RegisterDoublePref( 474 prefs::kMaxTouchMoveInPixelsForClick, 475 GestureConfiguration::max_touch_move_in_pixels_for_click(), 476 PrefRegistrySyncable::UNSYNCABLE_PREF); 477 registry->RegisterDoublePref( 478 prefs::kMaxDistanceBetweenTapsForDoubleTap, 479 GestureConfiguration::max_distance_between_taps_for_double_tap(), 480 PrefRegistrySyncable::UNSYNCABLE_PREF); 481 registry->RegisterDoublePref( 482 prefs::kMinDistanceForPinchScrollInPixels, 483 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), 484 PrefRegistrySyncable::UNSYNCABLE_PREF); 485 registry->RegisterDoublePref( 486 prefs::kMinFlickSpeedSquared, 487 GestureConfiguration::min_flick_speed_squared(), 488 PrefRegistrySyncable::UNSYNCABLE_PREF); 489 registry->RegisterDoublePref( 490 prefs::kMinPinchUpdateDistanceInPixels, 491 GestureConfiguration::min_pinch_update_distance_in_pixels(), 492 PrefRegistrySyncable::UNSYNCABLE_PREF); 493 registry->RegisterDoublePref( 494 prefs::kMinRailBreakVelocity, 495 GestureConfiguration::min_rail_break_velocity(), 496 PrefRegistrySyncable::UNSYNCABLE_PREF); 497 registry->RegisterDoublePref( 498 prefs::kMinScrollDeltaSquared, 499 GestureConfiguration::min_scroll_delta_squared(), 500 PrefRegistrySyncable::UNSYNCABLE_PREF); 501 registry->RegisterDoublePref( 502 prefs::kMinSwipeSpeed, 503 GestureConfiguration::min_swipe_speed(), 504 PrefRegistrySyncable::UNSYNCABLE_PREF); 505 registry->RegisterDoublePref( 506 prefs::kMinTouchDownDurationInSecondsForClick, 507 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), 508 PrefRegistrySyncable::UNSYNCABLE_PREF); 509 registry->RegisterIntegerPref( 510 prefs::kPointsBufferedForVelocity, 511 GestureConfiguration::points_buffered_for_velocity(), 512 PrefRegistrySyncable::UNSYNCABLE_PREF); 513 registry->RegisterDoublePref( 514 prefs::kRailBreakProportion, 515 GestureConfiguration::rail_break_proportion(), 516 PrefRegistrySyncable::UNSYNCABLE_PREF); 517 registry->RegisterDoublePref( 518 prefs::kRailStartProportion, 519 GestureConfiguration::rail_start_proportion(), 520 PrefRegistrySyncable::UNSYNCABLE_PREF); 521 522 // Register for migration. 523 registry->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, 524 0.0, 525 PrefRegistrySyncable::UNSYNCABLE_PREF); 526 527 RegisterOverscrollPrefs(registry); 528 RegisterFlingCurveParameters(registry); 529 RegisterWorkspaceCyclerPrefs(registry); 530} 531 532bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { 533 // Create the observer as soon as the profile is created. 534 return true; 535} 536 537bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { 538 // Use same gesture preferences on incognito windows. 539 return true; 540} 541 542bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { 543 // Some tests replace the PrefService of the TestingProfile after the 544 // GesturePrefsObserver has been created, which makes Shutdown() 545 // remove the registrar from a non-existent PrefService. 546 return true; 547} 548