Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: chrome/browser/ui/gesture_prefs_observer_factory_aura.cc

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again; base::File changes conflicted. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/overscroll_configuration.h" 19 #include "content/public/browser/overscroll_configuration.h"
19 #include "content/public/common/renderer_preferences.h" 20 #include "content/public/common/renderer_preferences.h"
20 #include "ui/base/gestures/gesture_configuration.h" 21 #include "ui/base/gestures/gesture_configuration.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ProfileDependencyManager::GetInstance()) {} 263 ProfileDependencyManager::GetInstance()) {}
263 264
264 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} 265 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {}
265 266
266 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( 267 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor(
267 Profile* profile) const { 268 Profile* profile) const {
268 return new GesturePrefsObserver(profile->GetPrefs()); 269 return new GesturePrefsObserver(profile->GetPrefs());
269 } 270 }
270 271
271 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( 272 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs(
272 PrefServiceSyncable* prefs) { 273 PrefRegistrySyncable* registry) {
273 const OverscrollPref* overscroll_prefs = 274 const OverscrollPref* overscroll_prefs =
274 GesturePrefsObserver::GetOverscrollPrefs(); 275 GesturePrefsObserver::GetOverscrollPrefs();
275 276
276 for (int i = 0; overscroll_prefs[i].pref_name; ++i) { 277 for (int i = 0; overscroll_prefs[i].pref_name; ++i) {
277 prefs->RegisterDoublePref( 278 registry->RegisterDoublePref(
278 overscroll_prefs[i].pref_name, 279 overscroll_prefs[i].pref_name,
279 content::GetOverscrollConfig(overscroll_prefs[i].config), 280 content::GetOverscrollConfig(overscroll_prefs[i].config),
280 PrefServiceSyncable::UNSYNCABLE_PREF); 281 PrefRegistrySyncable::UNSYNCABLE_PREF);
281 } 282 }
282 } 283 }
283 284
284 void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters( 285 void GesturePrefsObserverFactoryAura::RegisterFlingCurveParameters(
285 PrefServiceSyncable* prefs) { 286 PrefRegistrySyncable* registry) {
286 content::RendererPreferences def_prefs; 287 content::RendererPreferences def_prefs;
287 288
288 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); i++) 289 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); i++)
289 prefs->RegisterDoublePref(kFlingTouchpadPrefs[i], 290 registry->RegisterDoublePref(kFlingTouchpadPrefs[i],
290 def_prefs.touchpad_fling_profile[i], 291 def_prefs.touchpad_fling_profile[i],
291 PrefServiceSyncable::UNSYNCABLE_PREF); 292 PrefRegistrySyncable::UNSYNCABLE_PREF);
292 293
293 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); i++) 294 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); i++)
294 prefs->RegisterDoublePref(kFlingTouchscreenPrefs[i], 295 registry->RegisterDoublePref(kFlingTouchscreenPrefs[i],
295 def_prefs.touchscreen_fling_profile[i], 296 def_prefs.touchscreen_fling_profile[i],
296 PrefServiceSyncable::UNSYNCABLE_PREF); 297 PrefRegistrySyncable::UNSYNCABLE_PREF);
297 } 298 }
298 299
299 void GesturePrefsObserverFactoryAura::RegisterUserPrefs( 300 void GesturePrefsObserverFactoryAura::DeprecatedRegisterUserPrefs(
300 PrefServiceSyncable* prefs) { 301 PrefService* prefs,
301 prefs->RegisterDoublePref( 302 PrefRegistrySyncable* registry) {
303 registry->RegisterDoublePref(
302 prefs::kFlingAccelerationCurveCoefficient0, 304 prefs::kFlingAccelerationCurveCoefficient0,
303 GestureConfiguration::fling_acceleration_curve_coefficients(0), 305 GestureConfiguration::fling_acceleration_curve_coefficients(0),
304 PrefServiceSyncable::UNSYNCABLE_PREF); 306 PrefRegistrySyncable::UNSYNCABLE_PREF);
305 prefs->RegisterDoublePref( 307 registry->RegisterDoublePref(
306 prefs::kFlingAccelerationCurveCoefficient1, 308 prefs::kFlingAccelerationCurveCoefficient1,
307 GestureConfiguration::fling_acceleration_curve_coefficients(1), 309 GestureConfiguration::fling_acceleration_curve_coefficients(1),
308 PrefServiceSyncable::UNSYNCABLE_PREF); 310 PrefRegistrySyncable::UNSYNCABLE_PREF);
309 prefs->RegisterDoublePref( 311 registry->RegisterDoublePref(
310 prefs::kFlingAccelerationCurveCoefficient2, 312 prefs::kFlingAccelerationCurveCoefficient2,
311 GestureConfiguration::fling_acceleration_curve_coefficients(2), 313 GestureConfiguration::fling_acceleration_curve_coefficients(2),
312 PrefServiceSyncable::UNSYNCABLE_PREF); 314 PrefRegistrySyncable::UNSYNCABLE_PREF);
313 prefs->RegisterDoublePref( 315 registry->RegisterDoublePref(
314 prefs::kFlingAccelerationCurveCoefficient3, 316 prefs::kFlingAccelerationCurveCoefficient3,
315 GestureConfiguration::fling_acceleration_curve_coefficients(3), 317 GestureConfiguration::fling_acceleration_curve_coefficients(3),
316 PrefServiceSyncable::UNSYNCABLE_PREF); 318 PrefRegistrySyncable::UNSYNCABLE_PREF);
317 prefs->RegisterIntegerPref( 319 registry->RegisterIntegerPref(
318 prefs::kFlingMaxCancelToDownTimeInMs, 320 prefs::kFlingMaxCancelToDownTimeInMs,
319 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), 321 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(),
320 PrefServiceSyncable::UNSYNCABLE_PREF); 322 PrefRegistrySyncable::UNSYNCABLE_PREF);
321 prefs->RegisterIntegerPref( 323 registry->RegisterIntegerPref(
322 prefs::kFlingMaxTapGapTimeInMs, 324 prefs::kFlingMaxTapGapTimeInMs,
323 GestureConfiguration::fling_max_tap_gap_time_in_ms(), 325 GestureConfiguration::fling_max_tap_gap_time_in_ms(),
324 PrefServiceSyncable::UNSYNCABLE_PREF); 326 PrefRegistrySyncable::UNSYNCABLE_PREF);
325 prefs->RegisterDoublePref( 327 registry->RegisterDoublePref(
326 prefs::kFlingVelocityCap, 328 prefs::kFlingVelocityCap,
327 GestureConfiguration::fling_velocity_cap(), 329 GestureConfiguration::fling_velocity_cap(),
328 PrefServiceSyncable::UNSYNCABLE_PREF); 330 PrefRegistrySyncable::UNSYNCABLE_PREF);
329 prefs->RegisterDoublePref( 331 registry->RegisterDoublePref(
330 prefs::kLongPressTimeInSeconds, 332 prefs::kLongPressTimeInSeconds,
331 GestureConfiguration::long_press_time_in_seconds(), 333 GestureConfiguration::long_press_time_in_seconds(),
332 PrefServiceSyncable::UNSYNCABLE_PREF); 334 PrefRegistrySyncable::UNSYNCABLE_PREF);
333 prefs->RegisterDoublePref( 335 registry->RegisterDoublePref(
334 prefs::kSemiLongPressTimeInSeconds, 336 prefs::kSemiLongPressTimeInSeconds,
335 GestureConfiguration::semi_long_press_time_in_seconds(), 337 GestureConfiguration::semi_long_press_time_in_seconds(),
336 PrefServiceSyncable::UNSYNCABLE_PREF); 338 PrefRegistrySyncable::UNSYNCABLE_PREF);
337 prefs->RegisterDoublePref( 339 registry->RegisterDoublePref(
338 prefs::kMaxDistanceForTwoFingerTapInPixels, 340 prefs::kMaxDistanceForTwoFingerTapInPixels,
339 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(), 341 GestureConfiguration::max_distance_for_two_finger_tap_in_pixels(),
340 PrefServiceSyncable::UNSYNCABLE_PREF); 342 PrefRegistrySyncable::UNSYNCABLE_PREF);
341 prefs->RegisterDoublePref( 343 registry->RegisterDoublePref(
342 prefs::kMaxSecondsBetweenDoubleClick, 344 prefs::kMaxSecondsBetweenDoubleClick,
343 GestureConfiguration::max_seconds_between_double_click(), 345 GestureConfiguration::max_seconds_between_double_click(),
344 PrefServiceSyncable::UNSYNCABLE_PREF); 346 PrefRegistrySyncable::UNSYNCABLE_PREF);
345 prefs->RegisterDoublePref( 347 registry->RegisterDoublePref(
346 prefs::kMaxSeparationForGestureTouchesInPixels, 348 prefs::kMaxSeparationForGestureTouchesInPixels,
347 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), 349 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(),
348 PrefServiceSyncable::UNSYNCABLE_PREF); 350 PrefRegistrySyncable::UNSYNCABLE_PREF);
349 prefs->RegisterDoublePref( 351 registry->RegisterDoublePref(
350 prefs::kMaxSwipeDeviationRatio, 352 prefs::kMaxSwipeDeviationRatio,
351 GestureConfiguration::max_swipe_deviation_ratio(), 353 GestureConfiguration::max_swipe_deviation_ratio(),
352 PrefServiceSyncable::UNSYNCABLE_PREF); 354 PrefRegistrySyncable::UNSYNCABLE_PREF);
353 prefs->RegisterDoublePref( 355 registry->RegisterDoublePref(
354 prefs::kMaxTouchDownDurationInSecondsForClick, 356 prefs::kMaxTouchDownDurationInSecondsForClick,
355 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(), 357 GestureConfiguration::max_touch_down_duration_in_seconds_for_click(),
356 PrefServiceSyncable::UNSYNCABLE_PREF); 358 PrefRegistrySyncable::UNSYNCABLE_PREF);
357 prefs->RegisterDoublePref( 359 registry->RegisterDoublePref(
358 prefs::kMaxTouchMoveInPixelsForClick, 360 prefs::kMaxTouchMoveInPixelsForClick,
359 GestureConfiguration::max_touch_move_in_pixels_for_click(), 361 GestureConfiguration::max_touch_move_in_pixels_for_click(),
360 PrefServiceSyncable::UNSYNCABLE_PREF); 362 PrefRegistrySyncable::UNSYNCABLE_PREF);
361 prefs->RegisterDoublePref( 363 registry->RegisterDoublePref(
362 prefs::kMaxDistanceBetweenTapsForDoubleTap, 364 prefs::kMaxDistanceBetweenTapsForDoubleTap,
363 GestureConfiguration::max_distance_between_taps_for_double_tap(), 365 GestureConfiguration::max_distance_between_taps_for_double_tap(),
364 PrefServiceSyncable::UNSYNCABLE_PREF); 366 PrefRegistrySyncable::UNSYNCABLE_PREF);
365 prefs->RegisterDoublePref( 367 registry->RegisterDoublePref(
366 prefs::kMinDistanceForPinchScrollInPixels, 368 prefs::kMinDistanceForPinchScrollInPixels,
367 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(), 369 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels(),
368 PrefServiceSyncable::UNSYNCABLE_PREF); 370 PrefRegistrySyncable::UNSYNCABLE_PREF);
369 prefs->RegisterDoublePref( 371 registry->RegisterDoublePref(
370 prefs::kMinFlickSpeedSquared, 372 prefs::kMinFlickSpeedSquared,
371 GestureConfiguration::min_flick_speed_squared(), 373 GestureConfiguration::min_flick_speed_squared(),
372 PrefServiceSyncable::UNSYNCABLE_PREF); 374 PrefRegistrySyncable::UNSYNCABLE_PREF);
373 prefs->RegisterDoublePref( 375 registry->RegisterDoublePref(
374 prefs::kMinPinchUpdateDistanceInPixels, 376 prefs::kMinPinchUpdateDistanceInPixels,
375 GestureConfiguration::min_pinch_update_distance_in_pixels(), 377 GestureConfiguration::min_pinch_update_distance_in_pixels(),
376 PrefServiceSyncable::UNSYNCABLE_PREF); 378 PrefRegistrySyncable::UNSYNCABLE_PREF);
377 prefs->RegisterDoublePref( 379 registry->RegisterDoublePref(
378 prefs::kMinRailBreakVelocity, 380 prefs::kMinRailBreakVelocity,
379 GestureConfiguration::min_rail_break_velocity(), 381 GestureConfiguration::min_rail_break_velocity(),
380 PrefServiceSyncable::UNSYNCABLE_PREF); 382 PrefRegistrySyncable::UNSYNCABLE_PREF);
381 prefs->RegisterDoublePref( 383 registry->RegisterDoublePref(
382 prefs::kMinScrollDeltaSquared, 384 prefs::kMinScrollDeltaSquared,
383 GestureConfiguration::min_scroll_delta_squared(), 385 GestureConfiguration::min_scroll_delta_squared(),
384 PrefServiceSyncable::UNSYNCABLE_PREF); 386 PrefRegistrySyncable::UNSYNCABLE_PREF);
385 prefs->RegisterDoublePref( 387 registry->RegisterDoublePref(
386 prefs::kMinSwipeSpeed, 388 prefs::kMinSwipeSpeed,
387 GestureConfiguration::min_swipe_speed(), 389 GestureConfiguration::min_swipe_speed(),
388 PrefServiceSyncable::UNSYNCABLE_PREF); 390 PrefRegistrySyncable::UNSYNCABLE_PREF);
389 prefs->RegisterDoublePref( 391 registry->RegisterDoublePref(
390 prefs::kMinTouchDownDurationInSecondsForClick, 392 prefs::kMinTouchDownDurationInSecondsForClick,
391 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(), 393 GestureConfiguration::min_touch_down_duration_in_seconds_for_click(),
392 PrefServiceSyncable::UNSYNCABLE_PREF); 394 PrefRegistrySyncable::UNSYNCABLE_PREF);
393 prefs->RegisterIntegerPref( 395 registry->RegisterIntegerPref(
394 prefs::kPointsBufferedForVelocity, 396 prefs::kPointsBufferedForVelocity,
395 GestureConfiguration::points_buffered_for_velocity(), 397 GestureConfiguration::points_buffered_for_velocity(),
396 PrefServiceSyncable::UNSYNCABLE_PREF); 398 PrefRegistrySyncable::UNSYNCABLE_PREF);
397 prefs->RegisterDoublePref( 399 registry->RegisterDoublePref(
398 prefs::kRailBreakProportion, 400 prefs::kRailBreakProportion,
399 GestureConfiguration::rail_break_proportion(), 401 GestureConfiguration::rail_break_proportion(),
400 PrefServiceSyncable::UNSYNCABLE_PREF); 402 PrefRegistrySyncable::UNSYNCABLE_PREF);
401 prefs->RegisterDoublePref( 403 registry->RegisterDoublePref(
402 prefs::kRailStartProportion, 404 prefs::kRailStartProportion,
403 GestureConfiguration::rail_start_proportion(), 405 GestureConfiguration::rail_start_proportion(),
404 PrefServiceSyncable::UNSYNCABLE_PREF); 406 PrefRegistrySyncable::UNSYNCABLE_PREF);
405 407
406 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243. 408 // TODO(rjkroege): Remove this in M29. http://crbug.com/160243.
407 const char kTouchScreenFlingAccelerationAdjustment[] = 409 const char kTouchScreenFlingAccelerationAdjustment[] =
408 "gesture.touchscreen_fling_acceleration_adjustment"; 410 "gesture.touchscreen_fling_acceleration_adjustment";
409 prefs->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment, 411 registry->RegisterDoublePref(kTouchScreenFlingAccelerationAdjustment,
410 0.0, 412 0.0,
411 PrefServiceSyncable::UNSYNCABLE_PREF); 413 PrefRegistrySyncable::UNSYNCABLE_PREF);
412 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); 414 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment);
413 415
414 RegisterOverscrollPrefs(prefs); 416 RegisterOverscrollPrefs(registry);
415 RegisterFlingCurveParameters(prefs); 417 RegisterFlingCurveParameters(registry);
416 } 418 }
417 419
418 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { 420 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const {
419 // Create the observer as soon as the profile is created. 421 // Create the observer as soon as the profile is created.
420 return true; 422 return true;
421 } 423 }
422 424
423 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const { 425 bool GesturePrefsObserverFactoryAura::ServiceRedirectedInIncognito() const {
424 // Use same gesture preferences on incognito windows. 426 // Use same gesture preferences on incognito windows.
425 return true; 427 return true;
426 } 428 }
427 429
428 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { 430 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const {
429 // Some tests replace the PrefService of the TestingProfile after the 431 // Some tests replace the PrefService of the TestingProfile after the
430 // GesturePrefsObserver has been created, which makes Shutdown() 432 // GesturePrefsObserver has been created, which makes Shutdown()
431 // remove the registrar from a non-existent PrefService. 433 // remove the registrar from a non-existent PrefService.
432 return true; 434 return true;
433 } 435 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gesture_prefs_observer_factory_aura.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698