| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); | 198 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( | 201 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( |
| 202 user_prefs::PrefRegistrySyncable* registry) { | 202 user_prefs::PrefRegistrySyncable* registry) { |
| 203 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); | 203 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); |
| 204 | 204 |
| 205 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { | 205 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { |
| 206 registry->RegisterDoublePref( | 206 registry->RegisterDoublePref( |
| 207 overscroll_prefs[i].pref_name, | 207 overscroll_prefs[i].pref_name, |
| 208 content::GetOverscrollConfig(overscroll_prefs[i].config), | 208 content::GetOverscrollConfig(overscroll_prefs[i].config)); |
| 209 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs( | 212 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs( |
| 214 user_prefs::PrefRegistrySyncable* registry) { | 213 user_prefs::PrefRegistrySyncable* registry) { |
| 215 GestureConfiguration* gesture_config = GestureConfiguration::GetInstance(); | 214 GestureConfiguration* gesture_config = GestureConfiguration::GetInstance(); |
| 216 registry->RegisterIntegerPref( | 215 registry->RegisterIntegerPref( |
| 217 prefs::kFlingMaxCancelToDownTimeInMs, | 216 prefs::kFlingMaxCancelToDownTimeInMs, |
| 218 gesture_config->fling_max_cancel_to_down_time_in_ms(), | 217 gesture_config->fling_max_cancel_to_down_time_in_ms()); |
| 219 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 218 registry->RegisterIntegerPref(prefs::kFlingMaxTapGapTimeInMs, |
| 220 registry->RegisterIntegerPref( | 219 gesture_config->fling_max_tap_gap_time_in_ms()); |
| 221 prefs::kFlingMaxTapGapTimeInMs, | |
| 222 gesture_config->fling_max_tap_gap_time_in_ms(), | |
| 223 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 224 registry->RegisterIntegerPref( | 220 registry->RegisterIntegerPref( |
| 225 prefs::kTabScrubActivationDelayInMs, | 221 prefs::kTabScrubActivationDelayInMs, |
| 226 gesture_config->tab_scrub_activation_delay_in_ms(), | 222 gesture_config->tab_scrub_activation_delay_in_ms()); |
| 227 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 223 registry->RegisterIntegerPref(prefs::kSemiLongPressTimeInMs, |
| 228 registry->RegisterIntegerPref( | 224 gesture_config->semi_long_press_time_in_ms()); |
| 229 prefs::kSemiLongPressTimeInMs, | |
| 230 gesture_config->semi_long_press_time_in_ms(), | |
| 231 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 232 registry->RegisterDoublePref( | 225 registry->RegisterDoublePref( |
| 233 prefs::kMaxSeparationForGestureTouchesInPixels, | 226 prefs::kMaxSeparationForGestureTouchesInPixels, |
| 234 gesture_config->max_separation_for_gesture_touches_in_pixels(), | 227 gesture_config->max_separation_for_gesture_touches_in_pixels()); |
| 235 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 236 RegisterOverscrollPrefs(registry); | 228 RegisterOverscrollPrefs(registry); |
| 237 } | 229 } |
| 238 | 230 |
| 239 bool | 231 bool |
| 240 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { | 232 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { |
| 241 // Create the observer as soon as the profile is created. | 233 // Create the observer as soon as the profile is created. |
| 242 return true; | 234 return true; |
| 243 } | 235 } |
| 244 | 236 |
| 245 content::BrowserContext* | 237 content::BrowserContext* |
| 246 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( | 238 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( |
| 247 content::BrowserContext* context) const { | 239 content::BrowserContext* context) const { |
| 248 // Use same gesture preferences on incognito windows. | 240 // Use same gesture preferences on incognito windows. |
| 249 return chrome::GetBrowserContextRedirectedInIncognito(context); | 241 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 250 } | 242 } |
| 251 | 243 |
| 252 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 244 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
| 253 // Some tests replace the PrefService of the TestingProfile after the | 245 // Some tests replace the PrefService of the TestingProfile after the |
| 254 // GesturePrefsObserver has been created, which makes Shutdown() | 246 // GesturePrefsObserver has been created, which makes Shutdown() |
| 255 // remove the registrar from a non-existent PrefService. | 247 // remove the registrar from a non-existent PrefService. |
| 256 return true; | 248 return true; |
| 257 } | 249 } |
| OLD | NEW |