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

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

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move all the methods to superclass Created 6 years, 1 month 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
OLDNEW
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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_change_registrar.h" 12 #include "base/prefs/pref_change_registrar.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/profiles/incognito_helpers.h" 15 #include "chrome/browser/profiles/incognito_helpers.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" 18 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/keyed_service/core/keyed_service.h" 19 #include "components/keyed_service/core/keyed_service.h"
20 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
21 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/overscroll_configuration.h" 23 #include "content/public/browser/overscroll_configuration.h"
24 #include "content/public/common/renderer_preferences.h" 24 #include "content/public/common/renderer_preferences.h"
25 #include "ui/events/gestures/gesture_configuration.h" 25 #include "ui/events/gesture_detection/gesture_configuration.h"
26 26
27 using ui::GestureConfiguration; 27 using ui::GestureConfiguration;
28 28
29 namespace { 29 namespace {
30 30
31 struct OverscrollPref { 31 struct OverscrollPref {
32 const char* pref_name; 32 const char* pref_name;
33 content::OverscrollConfig config; 33 content::OverscrollConfig config;
34 }; 34 };
35 35
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Update(); 138 Update();
139 } 139 }
140 140
141 GesturePrefsObserver::~GesturePrefsObserver() {} 141 GesturePrefsObserver::~GesturePrefsObserver() {}
142 142
143 void GesturePrefsObserver::Shutdown() { 143 void GesturePrefsObserver::Shutdown() {
144 registrar_.RemoveAll(); 144 registrar_.RemoveAll();
145 } 145 }
146 146
147 void GesturePrefsObserver::Update() { 147 void GesturePrefsObserver::Update() {
148 GestureConfiguration::set_fling_max_cancel_to_down_time_in_ms( 148 GestureConfiguration::GetInstance()->set_fling_max_cancel_to_down_time_in_ms(
149 prefs_->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs)); 149 prefs_->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs));
150 GestureConfiguration::set_fling_max_tap_gap_time_in_ms( 150 GestureConfiguration::GetInstance()->set_fling_max_tap_gap_time_in_ms(
151 prefs_->GetInteger(prefs::kFlingMaxTapGapTimeInMs)); 151 prefs_->GetInteger(prefs::kFlingMaxTapGapTimeInMs));
152 GestureConfiguration::set_tab_scrub_activation_delay_in_ms( 152 GestureConfiguration::GetInstance()->set_tab_scrub_activation_delay_in_ms(
153 prefs_->GetInteger(prefs::kTabScrubActivationDelayInMs)); 153 prefs_->GetInteger(prefs::kTabScrubActivationDelayInMs));
154 GestureConfiguration::set_semi_long_press_time_in_ms( 154 GestureConfiguration::GetInstance()->set_semi_long_press_time_in_ms(
155 prefs_->GetInteger(prefs::kSemiLongPressTimeInMs)); 155 prefs_->GetInteger(prefs::kSemiLongPressTimeInMs));
156 GestureConfiguration::set_max_separation_for_gesture_touches_in_pixels( 156 GestureConfiguration::GetInstance()
157 static_cast<float>( 157 ->set_max_separation_for_gesture_touches_in_pixels(static_cast<float>(
158 prefs_->GetDouble(prefs::kMaxSeparationForGestureTouchesInPixels))); 158 prefs_->GetDouble(prefs::kMaxSeparationForGestureTouchesInPixels)));
159 159
160 UpdateOverscrollPrefs(); 160 UpdateOverscrollPrefs();
161 } 161 }
162 162
163 void GesturePrefsObserver::UpdateOverscrollPrefs() { 163 void GesturePrefsObserver::UpdateOverscrollPrefs() {
164 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); 164 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs();
165 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { 165 for (size_t i = 0; i < overscroll_prefs.size(); ++i) {
166 content::SetOverscrollConfig(overscroll_prefs[i].config, 166 content::SetOverscrollConfig(overscroll_prefs[i].config,
167 static_cast<float>(prefs_->GetDouble(overscroll_prefs[i].pref_name))); 167 static_cast<float>(prefs_->GetDouble(overscroll_prefs[i].pref_name)));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 overscroll_prefs[i].pref_name, 206 overscroll_prefs[i].pref_name,
207 content::GetOverscrollConfig(overscroll_prefs[i].config), 207 content::GetOverscrollConfig(overscroll_prefs[i].config),
208 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 208 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
209 } 209 }
210 } 210 }
211 211
212 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs( 212 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs(
213 user_prefs::PrefRegistrySyncable* registry) { 213 user_prefs::PrefRegistrySyncable* registry) {
214 registry->RegisterIntegerPref( 214 registry->RegisterIntegerPref(
215 prefs::kFlingMaxCancelToDownTimeInMs, 215 prefs::kFlingMaxCancelToDownTimeInMs,
216 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), 216 GestureConfiguration::GetInstance()
217 ->fling_max_cancel_to_down_time_in_ms(),
217 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 218 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
218 registry->RegisterIntegerPref( 219 registry->RegisterIntegerPref(
219 prefs::kFlingMaxTapGapTimeInMs, 220 prefs::kFlingMaxTapGapTimeInMs,
220 GestureConfiguration::fling_max_tap_gap_time_in_ms(), 221 GestureConfiguration::GetInstance()->fling_max_tap_gap_time_in_ms(),
221 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 222 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
222 registry->RegisterIntegerPref( 223 registry->RegisterIntegerPref(
223 prefs::kTabScrubActivationDelayInMs, 224 prefs::kTabScrubActivationDelayInMs,
224 GestureConfiguration::tab_scrub_activation_delay_in_ms(), 225 GestureConfiguration::GetInstance()->tab_scrub_activation_delay_in_ms(),
225 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 226 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
226 registry->RegisterIntegerPref( 227 registry->RegisterIntegerPref(
227 prefs::kSemiLongPressTimeInMs, 228 prefs::kSemiLongPressTimeInMs,
228 GestureConfiguration::semi_long_press_time_in_ms(), 229 GestureConfiguration::GetInstance()->semi_long_press_time_in_ms(),
229 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 230 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
230 registry->RegisterDoublePref( 231 registry->RegisterDoublePref(
231 prefs::kMaxSeparationForGestureTouchesInPixels, 232 prefs::kMaxSeparationForGestureTouchesInPixels,
232 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), 233 GestureConfiguration::GetInstance()
234 ->max_separation_for_gesture_touches_in_pixels(),
233 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 235 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
234 RegisterOverscrollPrefs(registry); 236 RegisterOverscrollPrefs(registry);
235 } 237 }
236 238
237 bool 239 bool
238 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { 240 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const {
239 // Create the observer as soon as the profile is created. 241 // Create the observer as soon as the profile is created.
240 return true; 242 return true;
241 } 243 }
242 244
243 content::BrowserContext* 245 content::BrowserContext*
244 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( 246 GesturePrefsObserverFactoryAura::GetBrowserContextToUse(
245 content::BrowserContext* context) const { 247 content::BrowserContext* context) const {
246 // Use same gesture preferences on incognito windows. 248 // Use same gesture preferences on incognito windows.
247 return chrome::GetBrowserContextRedirectedInIncognito(context); 249 return chrome::GetBrowserContextRedirectedInIncognito(context);
248 } 250 }
249 251
250 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { 252 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const {
251 // Some tests replace the PrefService of the TestingProfile after the 253 // Some tests replace the PrefService of the TestingProfile after the
252 // GesturePrefsObserver has been created, which makes Shutdown() 254 // GesturePrefsObserver has been created, which makes Shutdown()
253 // remove the registrar from a non-existent PrefService. 255 // remove the registrar from a non-existent PrefService.
254 return true; 256 return true;
255 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698