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" |
11 #include "chrome/browser/prefs/pref_registry_syncable.h" | |
11 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_dependency_manager.h" | 14 #include "chrome/browser/profiles/profile_dependency_manager.h" |
14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/overscroll_configuration.h" | 18 #include "content/public/browser/overscroll_configuration.h" |
18 #include "ui/base/gestures/gesture_configuration.h" | 19 #include "ui/base/gestures/gesture_configuration.h" |
19 | 20 |
20 using ui::GestureConfiguration; | 21 using ui::GestureConfiguration; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 ProfileDependencyManager::GetInstance()) {} | 222 ProfileDependencyManager::GetInstance()) {} |
222 | 223 |
223 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} | 224 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} |
224 | 225 |
225 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( | 226 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( |
226 Profile* profile) const { | 227 Profile* profile) const { |
227 return new GesturePrefsObserver(profile->GetPrefs()); | 228 return new GesturePrefsObserver(profile->GetPrefs()); |
228 } | 229 } |
229 | 230 |
230 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( | 231 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( |
231 PrefServiceSyncable* prefs) { | 232 PrefRegistrySyncable* registry) { |
232 const OverscrollPref* overscroll_prefs = | 233 const OverscrollPref* overscroll_prefs = |
233 GesturePrefsObserver::GetOverscrollPrefs(); | 234 GesturePrefsObserver::GetOverscrollPrefs(); |
234 | 235 |
235 for (int i = 0; overscroll_prefs[i].pref_name; ++i) { | 236 for (int i = 0; overscroll_prefs[i].pref_name; ++i) { |
236 prefs->RegisterDoublePref( | 237 registry->RegisterDoublePref( |
237 overscroll_prefs[i].pref_name, | 238 overscroll_prefs[i].pref_name, |
238 content::GetOverscrollConfig(overscroll_prefs[i].config), | 239 content::GetOverscrollConfig(overscroll_prefs[i].config), |
239 PrefServiceSyncable::UNSYNCABLE_PREF); | 240 PrefRegistrySyncable::UNSYNCABLE_PREF); |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 void GesturePrefsObserverFactoryAura::RegisterUserPrefs( | 244 void GesturePrefsObserverFactoryAura::DeprecatedRegisterUserPrefs( |
244 PrefServiceSyncable* prefs) { | 245 PrefService* prefs, |
245 prefs->RegisterDoublePref( | 246 PrefRegistrySyncable* registry) { |
247 registry->RegisterDoublePref( | |
246 prefs::kFlingAccelerationCurveCoefficient0, | 248 prefs::kFlingAccelerationCurveCoefficient0, |
247 GestureConfiguration::fling_acceleration_curve_coefficients(0), | 249 GestureConfiguration::fling_acceleration_curve_coefficients(0), |
248 PrefServiceSyncable::UNSYNCABLE_PREF); | 250 PrefRegistrySyncable::UNSYNCABLE_PREF); |
249 prefs->RegisterDoublePref( | 251 registry->RegisterDoublePref( |
250 prefs::kFlingAccelerationCurveCoefficient1, | 252 prefs::kFlingAccelerationCurveCoefficient1, |
251 GestureConfiguration::fling_acceleration_curve_coefficients(1), | 253 GestureConfiguration::fling_acceleration_curve_coefficients(1), |
252 PrefServiceSyncable::UNSYNCABLE_PREF); | 254 PrefRegistrySyncable::UNSYNCABLE_PREF); |
253 prefs->RegisterDoublePref( | 255 registry->RegisterDoublePref( |
254 prefs::kFlingAccelerationCurveCoefficient2, | 256 prefs::kFlingAccelerationCurveCoefficient2, |
255 GestureConfiguration::fling_acceleration_curve_coefficients(2), | 257 GestureConfiguration::fling_acceleration_curve_coefficients(2), |
256 PrefServiceSyncable::UNSYNCABLE_PREF); | 258 PrefRegistrySyncable::UNSYNCABLE_PREF); |
257 prefs->RegisterDoublePref( | 259 registry->RegisterDoublePref( |
258 prefs::kFlingAccelerationCurveCoefficient3, | 260 prefs::kFlingAccelerationCurveCoefficient3, |
259 GestureConfiguration::fling_acceleration_curve_coefficients(3), | 261 GestureConfiguration::fling_acceleration_curve_coefficients(3), |
260 PrefServiceSyncable::UNSYNCABLE_PREF); | 262 PrefRegistrySyncable::UNSYNCABLE_PREF); |
261 prefs->RegisterIntegerPref( | 263 registry->RegisterIntegerPref( |
262 prefs::kFlingMaxCancelToDownTimeInMs, | 264 prefs::kFlingMaxCancelToDownTimeInMs, |
263 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), | 265 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), |
264 PrefServiceSyncable::UNSYNCABLE_PREF); | 266 PrefRegistrySyncable::UNSYNCABLE_PREF); |
265 prefs->RegisterIntegerPref( | 267 registry->RegisterIntegerPref( |
266 prefs::kFlingMaxTapGapTimeInMs, | 268 prefs::kFlingMaxTapGapTimeInMs, |
267 GestureConfiguration::fling_max_tap_gap_time_in_ms(), | 269 GestureConfiguration::fling_max_tap_gap_time_in_ms(), |
268 PrefServiceSyncable::UNSYNCABLE_PREF); | 270 PrefRegistrySyncable::UNSYNCABLE_PREF); |
269 prefs->RegisterDoublePref( | 271 registry->RegisterDoublePref( |
270 prefs::kFlingVelocityCap, | 272 prefs::kFlingVelocityCap, |
271 GestureConfiguration::fling_velocity_cap(), | 273 GestureConfiguration::fling_velocity_cap(), |
272 PrefServiceSyncable::UNSYNCABLE_PREF); | 274 PrefRegistrySyncable::UNSYNCABLE_PREF); |
273 prefs->RegisterDoublePref( | 275 registry->RegisterDoublePref( |
274 prefs::kLongPressTimeInSeconds, | 276 prefs::kLongPressTimeInSeconds, |
275 GestureConfiguration::long_press_time_in_seconds(), | 277 GestureConfiguration::long_press_time_in_seconds(), |
276 PrefServiceSyncable::UNSYNCABLE_PREF); | 278 PrefRegistrySyncable::UNSYNCABLE_PREF); |
277 prefs->RegisterDoublePref( | 279 registry->RegisterDoublePref( |
278 prefs::kSemiLongPressTimeInSeconds, | 280 prefs::kSemiLongPressTimeInSeconds, |
279 GestureConfiguration::semi_long_press_time_in_seconds(), | 281 GestureConfiguration::semi_long_press_time_in_seconds(), |
280 PrefServiceSyncable::UNSYNCABLE_PREF); | 282 PrefRegistrySyncable::UNSYNCABLE_PREF); |
281 prefs->RegisterDoublePref( | 283 registry->RegisterDoublePref( |
282 prefs::kMaxDistanceForTwoFingerTapInPixels, | 284 prefs::kMaxDistanceForTwoFingerTapInPixels, |
283 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), | 285 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), |
284 PrefServiceSyncable::UNSYNCABLE_PREF); | 286 PrefRegistrySyncable::UNSYNCABLE_PREF); |
285 prefs->RegisterDoublePref( | 287 registry->RegisterDoublePref( |
286 prefs::kMaxSecondsBetweenDoubleClick, | 288 prefs::kMaxSecondsBetweenDoubleClick, |
287 GestureConfiguration::max_seconds_between_double_click(), | 289 GestureConfiguration::max_seconds_between_double_click(), |
288 PrefServiceSyncable::UNSYNCABLE_PREF); | 290 PrefRegistrySyncable::UNSYNCABLE_PREF); |
289 prefs->RegisterDoublePref( | 291 registry->RegisterDoublePref( |
290 prefs::kMaxSeparationForGestureTouchesInPixels, | 292 prefs::kMaxSeparationForGestureTouchesInPixels, |
291 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), | 293 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), |
292 PrefServiceSyncable::UNSYNCABLE_PREF); | 294 PrefRegistrySyncable::UNSYNCABLE_PREF); |
293 prefs->RegisterDoublePref( | 295 registry->RegisterDoublePref( |
294 prefs::kMaxSwipeDeviationRatio, | 296 prefs::kMaxSwipeDeviationRatio, |
295 GestureConfiguration::max_swipe_deviation_ratio(), | 297 GestureConfiguration::max_swipe_deviation_ratio(), |
296 PrefServiceSyncable::UNSYNCABLE_PREF); | 298 PrefRegistrySyncable::UNSYNCABLE_PREF); |
297 prefs->RegisterDoublePref( | 299 registry->RegisterDoublePref( |
298 prefs::kMaxTouchDownDurationInSecondsForClick, | 300 prefs::kMaxTouchDownDurationInSecondsForClick, |
299 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), | 301 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), |
300 PrefServiceSyncable::UNSYNCABLE_PREF); | 302 PrefRegistrySyncable::UNSYNCABLE_PREF); |
301 prefs->RegisterDoublePref( | 303 registry->RegisterDoublePref( |
302 prefs::kMaxTouchMoveInPixelsForClick, | 304 prefs::kMaxTouchMoveInPixelsForClick, |
303 GestureConfiguration::max_touch_move_in_pixels_for_click(), | 305 GestureConfiguration::max_touch_move_in_pixels_for_click(), |
304 PrefServiceSyncable::UNSYNCABLE_PREF); | 306 PrefRegistrySyncable::UNSYNCABLE_PREF); |
305 prefs->RegisterDoublePref( | 307 registry->RegisterDoublePref( |
306 prefs::kMaxDistanceBetweenTapsForDoubleTap, | 308 prefs::kMaxDistanceBetweenTapsForDoubleTap, |
307 GestureConfiguration::max_distance_between_taps_for_double_tap(), | 309 GestureConfiguration::max_distance_between_taps_for_double_tap(), |
308 PrefServiceSyncable::UNSYNCABLE_PREF); | 310 PrefRegistrySyncable::UNSYNCABLE_PREF); |
309 prefs->RegisterDoublePref( | 311 registry->RegisterDoublePref( |
310 prefs::kMinDistanceForPinchScrollInPixels, | 312 prefs::kMinDistanceForPinchScrollInPixels, |
311 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), | 313 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), |
312 PrefServiceSyncable::UNSYNCABLE_PREF); | 314 PrefRegistrySyncable::UNSYNCABLE_PREF); |
313 prefs->RegisterDoublePref( | 315 registry->RegisterDoublePref( |
314 prefs::kMinFlickSpeedSquared, | 316 prefs::kMinFlickSpeedSquared, |
315 GestureConfiguration::min_flick_speed_squared(), | 317 GestureConfiguration::min_flick_speed_squared(), |
316 PrefServiceSyncable::UNSYNCABLE_PREF); | 318 PrefRegistrySyncable::UNSYNCABLE_PREF); |
317 prefs->RegisterDoublePref( | 319 registry->RegisterDoublePref( |
318 prefs::kMinPinchUpdateDistanceInPixels, | 320 prefs::kMinPinchUpdateDistanceInPixels, |
319 GestureConfiguration::min_pinch_update_distance_in_pixels(), | 321 GestureConfiguration::min_pinch_update_distance_in_pixels(), |
320 PrefServiceSyncable::UNSYNCABLE_PREF); | 322 PrefRegistrySyncable::UNSYNCABLE_PREF); |
321 prefs->RegisterDoublePref( | 323 registry->RegisterDoublePref( |
322 prefs::kMinRailBreakVelocity, | 324 prefs::kMinRailBreakVelocity, |
323 GestureConfiguration::min_rail_break_velocity(), | 325 GestureConfiguration::min_rail_break_velocity(), |
324 PrefServiceSyncable::UNSYNCABLE_PREF); | 326 PrefRegistrySyncable::UNSYNCABLE_PREF); |
325 prefs->RegisterDoublePref( | 327 registry->RegisterDoublePref( |
326 prefs::kMinScrollDeltaSquared, | 328 prefs::kMinScrollDeltaSquared, |
327 GestureConfiguration::min_scroll_delta_squared(), | 329 GestureConfiguration::min_scroll_delta_squared(), |
328 PrefServiceSyncable::UNSYNCABLE_PREF); | 330 PrefRegistrySyncable::UNSYNCABLE_PREF); |
329 prefs->RegisterDoublePref( | 331 registry->RegisterDoublePref( |
330 prefs::kMinSwipeSpeed, | 332 prefs::kMinSwipeSpeed, |
331 GestureConfiguration::min_swipe_speed(), | 333 GestureConfiguration::min_swipe_speed(), |
332 PrefServiceSyncable::UNSYNCABLE_PREF); | 334 PrefRegistrySyncable::UNSYNCABLE_PREF); |
333 prefs->RegisterDoublePref( | 335 registry->RegisterDoublePref( |
334 prefs::kMinTouchDownDurationInSecondsForClick, | 336 prefs::kMinTouchDownDurationInSecondsForClick, |
335 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), | 337 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), |
336 PrefServiceSyncable::UNSYNCABLE_PREF); | 338 PrefRegistrySyncable::UNSYNCABLE_PREF); |
337 prefs->RegisterIntegerPref( | 339 registry->RegisterIntegerPref( |
338 prefs::kPointsBufferedForVelocity, | 340 prefs::kPointsBufferedForVelocity, |
339 GestureConfiguration::points_buffered_for_velocity(), | 341 GestureConfiguration::points_buffered_for_velocity(), |
340 PrefServiceSyncable::UNSYNCABLE_PREF); | 342 PrefRegistrySyncable::UNSYNCABLE_PREF); |
341 prefs->RegisterDoublePref( | 343 registry->RegisterDoublePref( |
342 prefs::kRailBreakProportion, | 344 prefs::kRailBreakProportion, |
343 GestureConfiguration::rail_break_proportion(), | 345 GestureConfiguration::rail_break_proportion(), |
344 PrefServiceSyncable::UNSYNCABLE_PREF); | 346 PrefRegistrySyncable::UNSYNCABLE_PREF); |
345 prefs->RegisterDoublePref( | 347 registry->RegisterDoublePref( |
346 prefs::kRailStartProportion, | 348 prefs::kRailStartProportion, |
347 GestureConfiguration::rail_start_proportion(), | 349 GestureConfiguration::rail_start_proportion(), |
348 PrefServiceSyncable::UNSYNCABLE_PREF); | 350 PrefRegistrySyncable::UNSYNCABLE_PREF); |
349 | 351 |
350 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243. | 352 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243. |
351 const char kTouchScreenFlingAccelerationAdjustment[] = | 353 const char kTouchScreenFlingAccelerationAdjustment[] = |
352 "gesture.touchscreen_fling_acceleration_adjustment"; | 354 "gesture.touchscreen_fling_acceleration_adjustment"; |
353 prefs->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, | 355 registry->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, |
354 0.0, | 356 0.0, |
355 PrefServiceSyncable::UNSYNCABLE_PREF); | 357 PrefRegistrySyncable::UNSYNCABLE_PREF); |
356 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); | 358 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); |
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
non-scoring comment: This should be part of migrat
Jói
2013/02/07 14:52:32
Agreed, I think many of the "special" cases we're
Mattias Nissler (ping if slow)
2013/02/08 11:26:56
+1 to adding that migration code path.
Regarding
| |
357 | 359 |
358 RegisterOverscrollPrefs(prefs); | 360 RegisterOverscrollPrefs(registry); |
359 } | 361 } |
360 | 362 |
361 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { | 363 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { |
362 // Create the observer as soon as the profile is created. | 364 // Create the observer as soon as the profile is created. |
363 return true; | 365 return true; |
364 } | 366 } |
365 | 367 |
366 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { | 368 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { |
367 // Use same gesture preferences on incognito windows. | 369 // Use same gesture preferences on incognito windows. |
368 return true; | 370 return true; |
369 } | 371 } |
370 | 372 |
371 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 373 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
372 // Some tests replace the PrefService of the TestingProfile after the | 374 // Some tests replace the PrefService of the TestingProfile after the |
373 // GesturePrefsObserver has been created, which makes Shutdown() | 375 // GesturePrefsObserver has been created, which makes Shutdown() |
374 // remove the registrar from a non-existent PrefService. | 376 // remove the registrar from a non-existent PrefService. |
375 return true; | 377 return true; |
376 } | 378 } |
OLD | NEW |