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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ProfileDependencyManager::GetInstance()) {} | 353 ProfileDependencyManager::GetInstance()) {} |
354 | 354 |
355 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} | 355 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} |
356 | 356 |
357 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( | 357 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( |
358 content::BrowserContext* profile) const { | 358 content::BrowserContext* profile) const { |
359 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); | 359 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); |
360 } | 360 } |
361 | 361 |
362 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( | 362 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( |
363 PrefRegistrySyncable* registry) { | 363 user_prefs::PrefRegistrySyncable* registry) { |
364 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); | 364 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); |
365 | 365 |
366 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { | 366 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { |
367 registry->RegisterDoublePref( | 367 registry->RegisterDoublePref( |
368 overscroll_prefs[i].pref_name, | 368 overscroll_prefs[i].pref_name, |
369 content::GetOverscrollConfig(overscroll_prefs[i].config), | 369 content::GetOverscrollConfig(overscroll_prefs[i].config), |
370 PrefRegistrySyncable::UNSYNCABLE_PREF); | 370 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters( | 374 void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters( |
375 PrefRegistrySyncable* registry) { | 375 user_prefs::PrefRegistrySyncable* registry) { |
376 content::RendererPreferences def_prefs; | 376 content::RendererPreferences def_prefs; |
377 | 377 |
378 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); i++) | 378 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); i++) |
379 registry->RegisterDoublePref(kFlingTouchpadPrefs[i], | 379 registry->RegisterDoublePref( |
380 def_prefs.touchpad_fling_profile[i], | 380 kFlingTouchpadPrefs[i], |
381 PrefRegistrySyncable::UNSYNCABLE_PREF); | 381 def_prefs.touchpad_fling_profile[i], |
| 382 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
382 | 383 |
383 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); i++) | 384 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); i++) |
384 registry->RegisterDoublePref(kFlingTouchscreenPrefs[i], | 385 registry->RegisterDoublePref( |
385 def_prefs.touchscreen_fling_profile[i], | 386 kFlingTouchscreenPrefs[i], |
386 PrefRegistrySyncable::UNSYNCABLE_PREF); | 387 def_prefs.touchscreen_fling_profile[i], |
| 388 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
387 } | 389 } |
388 | 390 |
389 void GesturePrefsObserverFactoryAura::RegisterWorkspaceCyclerPrefs( | 391 void GesturePrefsObserverFactoryAura::RegisterWorkspaceCyclerPrefs( |
390 PrefRegistrySyncable* registry) { | 392 user_prefs::PrefRegistrySyncable* registry) { |
391 #if defined(USE_ASH) | 393 #if defined(USE_ASH) |
392 const std::vector<WorkspaceCyclerPref>& cycler_prefs = | 394 const std::vector<WorkspaceCyclerPref>& cycler_prefs = |
393 GetWorkspaceCyclerPrefs(); | 395 GetWorkspaceCyclerPrefs(); |
394 for (size_t i = 0; i < cycler_prefs.size(); ++i) { | 396 for (size_t i = 0; i < cycler_prefs.size(); ++i) { |
395 WorkspaceCyclerConfiguration::Property property = | 397 WorkspaceCyclerConfiguration::Property property = |
396 cycler_prefs[i].property; | 398 cycler_prefs[i].property; |
397 if (WorkspaceCyclerConfiguration::IsListProperty(property)) { | 399 if (WorkspaceCyclerConfiguration::IsListProperty(property)) { |
398 registry->RegisterListPref( | 400 registry->RegisterListPref( |
399 cycler_prefs[i].pref_name, | 401 cycler_prefs[i].pref_name, |
400 WorkspaceCyclerConfiguration::GetListValue(property).DeepCopy(), | 402 WorkspaceCyclerConfiguration::GetListValue(property).DeepCopy(), |
401 PrefRegistrySyncable::UNSYNCABLE_PREF); | 403 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
402 } else { | 404 } else { |
403 registry->RegisterDoublePref( | 405 registry->RegisterDoublePref( |
404 cycler_prefs[i].pref_name, | 406 cycler_prefs[i].pref_name, |
405 WorkspaceCyclerConfiguration::GetDouble(property), | 407 WorkspaceCyclerConfiguration::GetDouble(property), |
406 PrefRegistrySyncable::UNSYNCABLE_PREF); | 408 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
407 } | 409 } |
408 } | 410 } |
409 #endif // USE_ASH | 411 #endif // USE_ASH |
410 } | 412 } |
411 | 413 |
412 void GesturePrefsObserverFactoryAura::RegisterUserPrefs( | 414 void GesturePrefsObserverFactoryAura::RegisterUserPrefs( |
413 PrefRegistrySyncable* registry) { | 415 user_prefs::PrefRegistrySyncable* registry) { |
414 registry->RegisterDoublePref( | 416 registry->RegisterDoublePref( |
415 prefs::kFlingAccelerationCurveCoefficient0, | 417 prefs::kFlingAccelerationCurveCoefficient0, |
416 GestureConfiguration::fling_acceleration_curve_coefficients(0), | 418 GestureConfiguration::fling_acceleration_curve_coefficients(0), |
417 PrefRegistrySyncable::UNSYNCABLE_PREF); | 419 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
418 registry->RegisterDoublePref( | 420 registry->RegisterDoublePref( |
419 prefs::kFlingAccelerationCurveCoefficient1, | 421 prefs::kFlingAccelerationCurveCoefficient1, |
420 GestureConfiguration::fling_acceleration_curve_coefficients(1), | 422 GestureConfiguration::fling_acceleration_curve_coefficients(1), |
421 PrefRegistrySyncable::UNSYNCABLE_PREF); | 423 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
422 registry->RegisterDoublePref( | 424 registry->RegisterDoublePref( |
423 prefs::kFlingAccelerationCurveCoefficient2, | 425 prefs::kFlingAccelerationCurveCoefficient2, |
424 GestureConfiguration::fling_acceleration_curve_coefficients(2), | 426 GestureConfiguration::fling_acceleration_curve_coefficients(2), |
425 PrefRegistrySyncable::UNSYNCABLE_PREF); | 427 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
426 registry->RegisterDoublePref( | 428 registry->RegisterDoublePref( |
427 prefs::kFlingAccelerationCurveCoefficient3, | 429 prefs::kFlingAccelerationCurveCoefficient3, |
428 GestureConfiguration::fling_acceleration_curve_coefficients(3), | 430 GestureConfiguration::fling_acceleration_curve_coefficients(3), |
429 PrefRegistrySyncable::UNSYNCABLE_PREF); | 431 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
430 registry->RegisterIntegerPref( | 432 registry->RegisterIntegerPref( |
431 prefs::kFlingMaxCancelToDownTimeInMs, | 433 prefs::kFlingMaxCancelToDownTimeInMs, |
432 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), | 434 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), |
433 PrefRegistrySyncable::UNSYNCABLE_PREF); | 435 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
434 registry->RegisterIntegerPref( | 436 registry->RegisterIntegerPref( |
435 prefs::kFlingMaxTapGapTimeInMs, | 437 prefs::kFlingMaxTapGapTimeInMs, |
436 GestureConfiguration::fling_max_tap_gap_time_in_ms(), | 438 GestureConfiguration::fling_max_tap_gap_time_in_ms(), |
437 PrefRegistrySyncable::UNSYNCABLE_PREF); | 439 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
438 registry->RegisterIntegerPref( | 440 registry->RegisterIntegerPref( |
439 prefs::kTabScrubActivationDelayInMS, | 441 prefs::kTabScrubActivationDelayInMS, |
440 GestureConfiguration::tab_scrub_activation_delay_in_ms(), | 442 GestureConfiguration::tab_scrub_activation_delay_in_ms(), |
441 PrefRegistrySyncable::UNSYNCABLE_PREF); | 443 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
442 registry->RegisterDoublePref( | 444 registry->RegisterDoublePref( |
443 prefs::kFlingVelocityCap, | 445 prefs::kFlingVelocityCap, |
444 GestureConfiguration::fling_velocity_cap(), | 446 GestureConfiguration::fling_velocity_cap(), |
445 PrefRegistrySyncable::UNSYNCABLE_PREF); | 447 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
446 registry->RegisterDoublePref( | 448 registry->RegisterDoublePref( |
447 prefs::kLongPressTimeInSeconds, | 449 prefs::kLongPressTimeInSeconds, |
448 GestureConfiguration::long_press_time_in_seconds(), | 450 GestureConfiguration::long_press_time_in_seconds(), |
449 PrefRegistrySyncable::UNSYNCABLE_PREF); | 451 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
450 registry->RegisterDoublePref( | 452 registry->RegisterDoublePref( |
451 prefs::kSemiLongPressTimeInSeconds, | 453 prefs::kSemiLongPressTimeInSeconds, |
452 GestureConfiguration::semi_long_press_time_in_seconds(), | 454 GestureConfiguration::semi_long_press_time_in_seconds(), |
453 PrefRegistrySyncable::UNSYNCABLE_PREF); | 455 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
454 registry->RegisterDoublePref( | 456 registry->RegisterDoublePref( |
455 prefs::kMaxDistanceForTwoFingerTapInPixels, | 457 prefs::kMaxDistanceForTwoFingerTapInPixels, |
456 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), | 458 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), |
457 PrefRegistrySyncable::UNSYNCABLE_PREF); | 459 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
458 registry->RegisterDoublePref( | 460 registry->RegisterDoublePref( |
459 prefs::kMaxSecondsBetweenDoubleClick, | 461 prefs::kMaxSecondsBetweenDoubleClick, |
460 GestureConfiguration::max_seconds_between_double_click(), | 462 GestureConfiguration::max_seconds_between_double_click(), |
461 PrefRegistrySyncable::UNSYNCABLE_PREF); | 463 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
462 registry->RegisterDoublePref( | 464 registry->RegisterDoublePref( |
463 prefs::kMaxSeparationForGestureTouchesInPixels, | 465 prefs::kMaxSeparationForGestureTouchesInPixels, |
464 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), | 466 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), |
465 PrefRegistrySyncable::UNSYNCABLE_PREF); | 467 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
466 registry->RegisterDoublePref( | 468 registry->RegisterDoublePref( |
467 prefs::kMaxSwipeDeviationRatio, | 469 prefs::kMaxSwipeDeviationRatio, |
468 GestureConfiguration::max_swipe_deviation_ratio(), | 470 GestureConfiguration::max_swipe_deviation_ratio(), |
469 PrefRegistrySyncable::UNSYNCABLE_PREF); | 471 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
470 registry->RegisterDoublePref( | 472 registry->RegisterDoublePref( |
471 prefs::kMaxTouchDownDurationInSecondsForClick, | 473 prefs::kMaxTouchDownDurationInSecondsForClick, |
472 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), | 474 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), |
473 PrefRegistrySyncable::UNSYNCABLE_PREF); | 475 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
474 registry->RegisterDoublePref( | 476 registry->RegisterDoublePref( |
475 prefs::kMaxTouchMoveInPixelsForClick, | 477 prefs::kMaxTouchMoveInPixelsForClick, |
476 GestureConfiguration::max_touch_move_in_pixels_for_click(), | 478 GestureConfiguration::max_touch_move_in_pixels_for_click(), |
477 PrefRegistrySyncable::UNSYNCABLE_PREF); | 479 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
478 registry->RegisterDoublePref( | 480 registry->RegisterDoublePref( |
479 prefs::kMaxDistanceBetweenTapsForDoubleTap, | 481 prefs::kMaxDistanceBetweenTapsForDoubleTap, |
480 GestureConfiguration::max_distance_between_taps_for_double_tap(), | 482 GestureConfiguration::max_distance_between_taps_for_double_tap(), |
481 PrefRegistrySyncable::UNSYNCABLE_PREF); | 483 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
482 registry->RegisterDoublePref( | 484 registry->RegisterDoublePref( |
483 prefs::kMinDistanceForPinchScrollInPixels, | 485 prefs::kMinDistanceForPinchScrollInPixels, |
484 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), | 486 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), |
485 PrefRegistrySyncable::UNSYNCABLE_PREF); | 487 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
486 registry->RegisterDoublePref( | 488 registry->RegisterDoublePref( |
487 prefs::kMinFlickSpeedSquared, | 489 prefs::kMinFlickSpeedSquared, |
488 GestureConfiguration::min_flick_speed_squared(), | 490 GestureConfiguration::min_flick_speed_squared(), |
489 PrefRegistrySyncable::UNSYNCABLE_PREF); | 491 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
490 registry->RegisterDoublePref( | 492 registry->RegisterDoublePref( |
491 prefs::kMinPinchUpdateDistanceInPixels, | 493 prefs::kMinPinchUpdateDistanceInPixels, |
492 GestureConfiguration::min_pinch_update_distance_in_pixels(), | 494 GestureConfiguration::min_pinch_update_distance_in_pixels(), |
493 PrefRegistrySyncable::UNSYNCABLE_PREF); | 495 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
494 registry->RegisterDoublePref( | 496 registry->RegisterDoublePref( |
495 prefs::kMinRailBreakVelocity, | 497 prefs::kMinRailBreakVelocity, |
496 GestureConfiguration::min_rail_break_velocity(), | 498 GestureConfiguration::min_rail_break_velocity(), |
497 PrefRegistrySyncable::UNSYNCABLE_PREF); | 499 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
498 registry->RegisterDoublePref( | 500 registry->RegisterDoublePref( |
499 prefs::kMinScrollDeltaSquared, | 501 prefs::kMinScrollDeltaSquared, |
500 GestureConfiguration::min_scroll_delta_squared(), | 502 GestureConfiguration::min_scroll_delta_squared(), |
501 PrefRegistrySyncable::UNSYNCABLE_PREF); | 503 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
502 registry->RegisterDoublePref( | 504 registry->RegisterDoublePref( |
503 prefs::kMinSwipeSpeed, | 505 prefs::kMinSwipeSpeed, |
504 GestureConfiguration::min_swipe_speed(), | 506 GestureConfiguration::min_swipe_speed(), |
505 PrefRegistrySyncable::UNSYNCABLE_PREF); | 507 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
506 registry->RegisterDoublePref( | 508 registry->RegisterDoublePref( |
507 prefs::kMinTouchDownDurationInSecondsForClick, | 509 prefs::kMinTouchDownDurationInSecondsForClick, |
508 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), | 510 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), |
509 PrefRegistrySyncable::UNSYNCABLE_PREF); | 511 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
510 registry->RegisterIntegerPref( | 512 registry->RegisterIntegerPref( |
511 prefs::kPointsBufferedForVelocity, | 513 prefs::kPointsBufferedForVelocity, |
512 GestureConfiguration::points_buffered_for_velocity(), | 514 GestureConfiguration::points_buffered_for_velocity(), |
513 PrefRegistrySyncable::UNSYNCABLE_PREF); | 515 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
514 registry->RegisterDoublePref( | 516 registry->RegisterDoublePref( |
515 prefs::kRailBreakProportion, | 517 prefs::kRailBreakProportion, |
516 GestureConfiguration::rail_break_proportion(), | 518 GestureConfiguration::rail_break_proportion(), |
517 PrefRegistrySyncable::UNSYNCABLE_PREF); | 519 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
518 registry->RegisterDoublePref( | 520 registry->RegisterDoublePref( |
519 prefs::kRailStartProportion, | 521 prefs::kRailStartProportion, |
520 GestureConfiguration::rail_start_proportion(), | 522 GestureConfiguration::rail_start_proportion(), |
521 PrefRegistrySyncable::UNSYNCABLE_PREF); | 523 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
522 | 524 |
523 // Register for migration. | 525 // Register for migration. |
524 registry->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, | 526 registry->RegisterDoublePref( |
525 0.0, | 527 kTouchScreenFlingAccelerationAdjustment, |
526 PrefRegistrySyncable::UNSYNCABLE_PREF); | 528 0.0, |
| 529 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
527 | 530 |
528 RegisterOverscrollPrefs(registry); | 531 RegisterOverscrollPrefs(registry); |
529 RegisterFlingCurveParameters(registry); | 532 RegisterFlingCurveParameters(registry); |
530 RegisterWorkspaceCyclerPrefs(registry); | 533 RegisterWorkspaceCyclerPrefs(registry); |
531 } | 534 } |
532 | 535 |
533 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { | 536 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { |
534 // Create the observer as soon as the profile is created. | 537 // Create the observer as soon as the profile is created. |
535 return true; | 538 return true; |
536 } | 539 } |
537 | 540 |
538 content::BrowserContext* | 541 content::BrowserContext* |
539 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( | 542 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( |
540 content::BrowserContext* context) const { | 543 content::BrowserContext* context) const { |
541 // Use same gesture preferences on incognito windows. | 544 // Use same gesture preferences on incognito windows. |
542 return chrome::GetBrowserContextRedirectedInIncognito(context); | 545 return chrome::GetBrowserContextRedirectedInIncognito(context); |
543 } | 546 } |
544 | 547 |
545 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 548 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
546 // Some tests replace the PrefService of the TestingProfile after the | 549 // Some tests replace the PrefService of the TestingProfile after the |
547 // GesturePrefsObserver has been created, which makes Shutdown() | 550 // GesturePrefsObserver has been created, which makes Shutdown() |
548 // remove the registrar from a non-existent PrefService. | 551 // remove the registrar from a non-existent PrefService. |
549 return true; | 552 return true; |
550 } | 553 } |
OLD | NEW |