| OLD | NEW |
| 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/ui/gesture_prefs_observer_factory_aura.h" | 5 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 ProfileDependencyManager::GetInstance()) {} | 215 ProfileDependencyManager::GetInstance()) {} |
| 216 | 216 |
| 217 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} | 217 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} |
| 218 | 218 |
| 219 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( | 219 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( |
| 220 Profile* profile) const { | 220 Profile* profile) const { |
| 221 return new GesturePrefsObserver(profile->GetPrefs()); | 221 return new GesturePrefsObserver(profile->GetPrefs()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( | 224 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( |
| 225 PrefService* prefs) { | 225 PrefServiceSyncable* prefs) { |
| 226 const OverscrollPref* overscroll_prefs = | 226 const OverscrollPref* overscroll_prefs = |
| 227 GesturePrefsObserver::GetOverscrollPrefs(); | 227 GesturePrefsObserver::GetOverscrollPrefs(); |
| 228 | 228 |
| 229 for (int i = 0; overscroll_prefs[i].pref_name; ++i) { | 229 for (int i = 0; overscroll_prefs[i].pref_name; ++i) { |
| 230 prefs->RegisterDoublePref( | 230 prefs->RegisterDoublePref( |
| 231 overscroll_prefs[i].pref_name, | 231 overscroll_prefs[i].pref_name, |
| 232 content::GetOverscrollConfig(overscroll_prefs[i].config), | 232 content::GetOverscrollConfig(overscroll_prefs[i].config), |
| 233 PrefService::UNSYNCABLE_PREF); | 233 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 void GesturePrefsObserverFactoryAura::RegisterUserPrefs(PrefService* prefs) { | 237 void GesturePrefsObserverFactoryAura::RegisterUserPrefs( |
| 238 PrefServiceSyncable* prefs) { |
| 238 prefs->RegisterDoublePref( | 239 prefs->RegisterDoublePref( |
| 239 prefs::kFlingAccelerationCurveCoefficient0, | 240 prefs::kFlingAccelerationCurveCoefficient0, |
| 240 GestureConfiguration::fling_acceleration_curve_coefficients(0), | 241 GestureConfiguration::fling_acceleration_curve_coefficients(0), |
| 241 PrefService::UNSYNCABLE_PREF); | 242 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 242 prefs->RegisterDoublePref( | 243 prefs->RegisterDoublePref( |
| 243 prefs::kFlingAccelerationCurveCoefficient1, | 244 prefs::kFlingAccelerationCurveCoefficient1, |
| 244 GestureConfiguration::fling_acceleration_curve_coefficients(1), | 245 GestureConfiguration::fling_acceleration_curve_coefficients(1), |
| 245 PrefService::UNSYNCABLE_PREF); | 246 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 246 prefs->RegisterDoublePref( | 247 prefs->RegisterDoublePref( |
| 247 prefs::kFlingAccelerationCurveCoefficient2, | 248 prefs::kFlingAccelerationCurveCoefficient2, |
| 248 GestureConfiguration::fling_acceleration_curve_coefficients(2), | 249 GestureConfiguration::fling_acceleration_curve_coefficients(2), |
| 249 PrefService::UNSYNCABLE_PREF); | 250 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 250 prefs->RegisterDoublePref( | 251 prefs->RegisterDoublePref( |
| 251 prefs::kFlingAccelerationCurveCoefficient3, | 252 prefs::kFlingAccelerationCurveCoefficient3, |
| 252 GestureConfiguration::fling_acceleration_curve_coefficients(3), | 253 GestureConfiguration::fling_acceleration_curve_coefficients(3), |
| 253 PrefService::UNSYNCABLE_PREF); | 254 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 254 prefs->RegisterDoublePref( | 255 prefs->RegisterDoublePref( |
| 255 prefs::kFlingVelocityCap, | 256 prefs::kFlingVelocityCap, |
| 256 GestureConfiguration::fling_velocity_cap(), | 257 GestureConfiguration::fling_velocity_cap(), |
| 257 PrefService::UNSYNCABLE_PREF); | 258 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 258 prefs->RegisterDoublePref( | 259 prefs->RegisterDoublePref( |
| 259 prefs::kLongPressTimeInSeconds, | 260 prefs::kLongPressTimeInSeconds, |
| 260 GestureConfiguration::long_press_time_in_seconds(), | 261 GestureConfiguration::long_press_time_in_seconds(), |
| 261 PrefService::UNSYNCABLE_PREF); | 262 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 262 prefs->RegisterDoublePref( | 263 prefs->RegisterDoublePref( |
| 263 prefs::kSemiLongPressTimeInSeconds, | 264 prefs::kSemiLongPressTimeInSeconds, |
| 264 GestureConfiguration::semi_long_press_time_in_seconds(), | 265 GestureConfiguration::semi_long_press_time_in_seconds(), |
| 265 PrefService::UNSYNCABLE_PREF); | 266 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 266 prefs->RegisterDoublePref( | 267 prefs->RegisterDoublePref( |
| 267 prefs::kMaxDistanceForTwoFingerTapInPixels, | 268 prefs::kMaxDistanceForTwoFingerTapInPixels, |
| 268 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), | 269 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), |
| 269 PrefService::UNSYNCABLE_PREF); | 270 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 270 prefs->RegisterDoublePref( | 271 prefs->RegisterDoublePref( |
| 271 prefs::kMaxSecondsBetweenDoubleClick, | 272 prefs::kMaxSecondsBetweenDoubleClick, |
| 272 GestureConfiguration::max_seconds_between_double_click(), | 273 GestureConfiguration::max_seconds_between_double_click(), |
| 273 PrefService::UNSYNCABLE_PREF); | 274 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 274 prefs->RegisterDoublePref( | 275 prefs->RegisterDoublePref( |
| 275 prefs::kMaxSeparationForGestureTouchesInPixels, | 276 prefs::kMaxSeparationForGestureTouchesInPixels, |
| 276 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), | 277 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), |
| 277 PrefService::UNSYNCABLE_PREF); | 278 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 278 prefs->RegisterDoublePref( | 279 prefs->RegisterDoublePref( |
| 279 prefs::kMaxSwipeDeviationRatio, | 280 prefs::kMaxSwipeDeviationRatio, |
| 280 GestureConfiguration::max_swipe_deviation_ratio(), | 281 GestureConfiguration::max_swipe_deviation_ratio(), |
| 281 PrefService::UNSYNCABLE_PREF); | 282 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 282 prefs->RegisterDoublePref( | 283 prefs->RegisterDoublePref( |
| 283 prefs::kMaxTouchDownDurationInSecondsForClick, | 284 prefs::kMaxTouchDownDurationInSecondsForClick, |
| 284 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), | 285 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), |
| 285 PrefService::UNSYNCABLE_PREF); | 286 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 286 prefs->RegisterDoublePref( | 287 prefs->RegisterDoublePref( |
| 287 prefs::kMaxTouchMoveInPixelsForClick, | 288 prefs::kMaxTouchMoveInPixelsForClick, |
| 288 GestureConfiguration::max_touch_move_in_pixels_for_click(), | 289 GestureConfiguration::max_touch_move_in_pixels_for_click(), |
| 289 PrefService::UNSYNCABLE_PREF); | 290 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 290 prefs->RegisterDoublePref( | 291 prefs->RegisterDoublePref( |
| 291 prefs::kMaxDistanceBetweenTapsForDoubleTap, | 292 prefs::kMaxDistanceBetweenTapsForDoubleTap, |
| 292 GestureConfiguration::max_distance_between_taps_for_double_tap(), | 293 GestureConfiguration::max_distance_between_taps_for_double_tap(), |
| 293 PrefService::UNSYNCABLE_PREF); | 294 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 294 prefs->RegisterDoublePref( | 295 prefs->RegisterDoublePref( |
| 295 prefs::kMinDistanceForPinchScrollInPixels, | 296 prefs::kMinDistanceForPinchScrollInPixels, |
| 296 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), | 297 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), |
| 297 PrefService::UNSYNCABLE_PREF); | 298 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 298 prefs->RegisterDoublePref( | 299 prefs->RegisterDoublePref( |
| 299 prefs::kMinFlickSpeedSquared, | 300 prefs::kMinFlickSpeedSquared, |
| 300 GestureConfiguration::min_flick_speed_squared(), | 301 GestureConfiguration::min_flick_speed_squared(), |
| 301 PrefService::UNSYNCABLE_PREF); | 302 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 302 prefs->RegisterDoublePref( | 303 prefs->RegisterDoublePref( |
| 303 prefs::kMinPinchUpdateDistanceInPixels, | 304 prefs::kMinPinchUpdateDistanceInPixels, |
| 304 GestureConfiguration::min_pinch_update_distance_in_pixels(), | 305 GestureConfiguration::min_pinch_update_distance_in_pixels(), |
| 305 PrefService::UNSYNCABLE_PREF); | 306 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 306 prefs->RegisterDoublePref( | 307 prefs->RegisterDoublePref( |
| 307 prefs::kMinRailBreakVelocity, | 308 prefs::kMinRailBreakVelocity, |
| 308 GestureConfiguration::min_rail_break_velocity(), | 309 GestureConfiguration::min_rail_break_velocity(), |
| 309 PrefService::UNSYNCABLE_PREF); | 310 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 310 prefs->RegisterDoublePref( | 311 prefs->RegisterDoublePref( |
| 311 prefs::kMinScrollDeltaSquared, | 312 prefs::kMinScrollDeltaSquared, |
| 312 GestureConfiguration::min_scroll_delta_squared(), | 313 GestureConfiguration::min_scroll_delta_squared(), |
| 313 PrefService::UNSYNCABLE_PREF); | 314 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 314 prefs->RegisterDoublePref( | 315 prefs->RegisterDoublePref( |
| 315 prefs::kMinSwipeSpeed, | 316 prefs::kMinSwipeSpeed, |
| 316 GestureConfiguration::min_swipe_speed(), | 317 GestureConfiguration::min_swipe_speed(), |
| 317 PrefService::UNSYNCABLE_PREF); | 318 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 318 prefs->RegisterDoublePref( | 319 prefs->RegisterDoublePref( |
| 319 prefs::kMinTouchDownDurationInSecondsForClick, | 320 prefs::kMinTouchDownDurationInSecondsForClick, |
| 320 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), | 321 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), |
| 321 PrefService::UNSYNCABLE_PREF); | 322 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 322 prefs->RegisterIntegerPref( | 323 prefs->RegisterIntegerPref( |
| 323 prefs::kPointsBufferedForVelocity, | 324 prefs::kPointsBufferedForVelocity, |
| 324 GestureConfiguration::points_buffered_for_velocity(), | 325 GestureConfiguration::points_buffered_for_velocity(), |
| 325 PrefService::UNSYNCABLE_PREF); | 326 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 326 prefs->RegisterDoublePref( | 327 prefs->RegisterDoublePref( |
| 327 prefs::kRailBreakProportion, | 328 prefs::kRailBreakProportion, |
| 328 GestureConfiguration::rail_break_proportion(), | 329 GestureConfiguration::rail_break_proportion(), |
| 329 PrefService::UNSYNCABLE_PREF); | 330 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 330 prefs->RegisterDoublePref( | 331 prefs->RegisterDoublePref( |
| 331 prefs::kRailStartProportion, | 332 prefs::kRailStartProportion, |
| 332 GestureConfiguration::rail_start_proportion(), | 333 GestureConfiguration::rail_start_proportion(), |
| 333 PrefService::UNSYNCABLE_PREF); | 334 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 334 | 335 |
| 335 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243. | 336 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243. |
| 336 const char kTouchScreenFlingAccelerationAdjustment[] = | 337 const char kTouchScreenFlingAccelerationAdjustment[] = |
| 337 "gesture.touchscreen_fling_acceleration_adjustment"; | 338 "gesture.touchscreen_fling_acceleration_adjustment"; |
| 338 prefs->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, | 339 prefs->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, |
| 339 0.0, | 340 0.0, |
| 340 PrefService::UNSYNCABLE_PREF); | 341 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 341 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); | 342 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); |
| 342 | 343 |
| 343 RegisterOverscrollPrefs(prefs); | 344 RegisterOverscrollPrefs(prefs); |
| 344 } | 345 } |
| 345 | 346 |
| 346 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { | 347 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { |
| 347 // Create the observer as soon as the profile is created. | 348 // Create the observer as soon as the profile is created. |
| 348 return true; | 349 return true; |
| 349 } | 350 } |
| 350 | 351 |
| 351 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { | 352 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { |
| 352 // Use same gesture preferences on incognito windows. | 353 // Use same gesture preferences on incognito windows. |
| 353 return true; | 354 return true; |
| 354 } | 355 } |
| 355 | 356 |
| 356 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 357 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
| 357 // Some tests replace the PrefService of the TestingProfile after the | 358 // Some tests replace the PrefService of the TestingProfile after the |
| 358 // GesturePrefsObserver has been created, which makes Shutdown() | 359 // GesturePrefsObserver has been created, which makes Shutdown() |
| 359 // remove the registrar from a non-existent PrefService. | 360 // remove the registrar from a non-existent PrefService. |
| 360 return true; | 361 return true; |
| 361 } | 362 } |
| OLD | NEW |