| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 { prefs::kWorkspaceCyclerStopCyclerAnimationDuration, | 111 { prefs::kWorkspaceCyclerStopCyclerAnimationDuration, |
| 112 WorkspaceCyclerConfiguration::STOP_CYCLER_ANIMATION_DURATION }, | 112 WorkspaceCyclerConfiguration::STOP_CYCLER_ANIMATION_DURATION }, |
| 113 }; | 113 }; |
| 114 cycler_prefs.assign(kCyclerPrefs, kCyclerPrefs + arraysize(kCyclerPrefs)); | 114 cycler_prefs.assign(kCyclerPrefs, kCyclerPrefs + arraysize(kCyclerPrefs)); |
| 115 } | 115 } |
| 116 return cycler_prefs; | 116 return cycler_prefs; |
| 117 } | 117 } |
| 118 #endif // USE_ASH | 118 #endif // USE_ASH |
| 119 | 119 |
| 120 // This class manages gesture configuration preferences. | 120 // This class manages gesture configuration preferences. |
| 121 class GesturePrefsObserver : public ProfileKeyedService { | 121 class GesturePrefsObserver : public BrowserContextKeyedService { |
| 122 public: | 122 public: |
| 123 explicit GesturePrefsObserver(PrefService* prefs); | 123 explicit GesturePrefsObserver(PrefService* prefs); |
| 124 virtual ~GesturePrefsObserver(); | 124 virtual ~GesturePrefsObserver(); |
| 125 | 125 |
| 126 // ProfileKeyedService implementation. | 126 // BrowserContextKeyedService implementation. |
| 127 virtual void Shutdown() OVERRIDE; | 127 virtual void Shutdown() OVERRIDE; |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 // Notification callback invoked when browser-side preferences | 130 // Notification callback invoked when browser-side preferences |
| 131 // are updated and need to be pushed into ui::GesturePreferences. | 131 // are updated and need to be pushed into ui::GesturePreferences. |
| 132 void Update(); | 132 void Update(); |
| 133 | 133 |
| 134 // Notification callback invoked when the fling deacceleration | 134 // Notification callback invoked when the fling deacceleration |
| 135 // gesture preferences are changed from chrome://gesture. | 135 // gesture preferences are changed from chrome://gesture. |
| 136 // Broadcasts the changes all renderers where they are used. | 136 // Broadcasts the changes all renderers where they are used. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 } // namespace | 363 } // namespace |
| 364 | 364 |
| 365 // static | 365 // static |
| 366 GesturePrefsObserverFactoryAura* | 366 GesturePrefsObserverFactoryAura* |
| 367 GesturePrefsObserverFactoryAura::GetInstance() { | 367 GesturePrefsObserverFactoryAura::GetInstance() { |
| 368 return Singleton<GesturePrefsObserverFactoryAura>::get(); | 368 return Singleton<GesturePrefsObserverFactoryAura>::get(); |
| 369 } | 369 } |
| 370 | 370 |
| 371 GesturePrefsObserverFactoryAura::GesturePrefsObserverFactoryAura() | 371 GesturePrefsObserverFactoryAura::GesturePrefsObserverFactoryAura() |
| 372 : ProfileKeyedServiceFactory("GesturePrefsObserverAura", | 372 : BrowserContextKeyedServiceFactory("GesturePrefsObserverAura", |
| 373 ProfileDependencyManager::GetInstance()) {} | 373 BrowserContextDependencyManager::GetInstance())
{} |
| 374 | 374 |
| 375 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} | 375 GesturePrefsObserverFactoryAura::~GesturePrefsObserverFactoryAura() {} |
| 376 | 376 |
| 377 ProfileKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanceFor( | 377 BrowserContextKeyedService* GesturePrefsObserverFactoryAura::BuildServiceInstanc
eFor( |
| 378 content::BrowserContext* profile) const { | 378 content::BrowserContext* profile) const { |
| 379 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); | 379 return new GesturePrefsObserver(static_cast<Profile*>(profile)->GetPrefs()); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( | 382 void GesturePrefsObserverFactoryAura::RegisterOverscrollPrefs( |
| 383 user_prefs::PrefRegistrySyncable* registry) { | 383 user_prefs::PrefRegistrySyncable* registry) { |
| 384 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); | 384 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); |
| 385 | 385 |
| 386 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { | 386 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { |
| 387 registry->RegisterDoublePref( | 387 registry->RegisterDoublePref( |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 kTouchScreenFlingAccelerationAdjustment, | 561 kTouchScreenFlingAccelerationAdjustment, |
| 562 0.0, | 562 0.0, |
| 563 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 563 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 564 | 564 |
| 565 RegisterOverscrollPrefs(registry); | 565 RegisterOverscrollPrefs(registry); |
| 566 RegisterFlingCurveParameters(registry); | 566 RegisterFlingCurveParameters(registry); |
| 567 RegisterImmersiveModePrefs(registry); | 567 RegisterImmersiveModePrefs(registry); |
| 568 RegisterWorkspaceCyclerPrefs(registry); | 568 RegisterWorkspaceCyclerPrefs(registry); |
| 569 } | 569 } |
| 570 | 570 |
| 571 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithProfile() const { | 571 bool GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const
{ |
| 572 // Create the observer as soon as the profile is created. | 572 // Create the observer as soon as the profile is created. |
| 573 return true; | 573 return true; |
| 574 } | 574 } |
| 575 | 575 |
| 576 content::BrowserContext* | 576 content::BrowserContext* |
| 577 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( | 577 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( |
| 578 content::BrowserContext* context) const { | 578 content::BrowserContext* context) const { |
| 579 // Use same gesture preferences on incognito windows. | 579 // Use same gesture preferences on incognito windows. |
| 580 return chrome::GetBrowserContextRedirectedInIncognito(context); | 580 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { | 583 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { |
| 584 // Some tests replace the PrefService of the TestingProfile after the | 584 // Some tests replace the PrefService of the TestingProfile after the |
| 585 // GesturePrefsObserver has been created, which makes Shutdown() | 585 // GesturePrefsObserver has been created, which makes Shutdown() |
| 586 // remove the registrar from a non-existent PrefService. | 586 // remove the registrar from a non-existent PrefService. |
| 587 return true; | 587 return true; |
| 588 } | 588 } |
| OLD | NEW |