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

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: Copyright 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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/ash/tab_scrubber.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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* gesture_config = GestureConfiguration::GetInstance();
149 gesture_config->set_fling_max_cancel_to_down_time_in_ms(
149 prefs_->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs)); 150 prefs_->GetInteger(prefs::kFlingMaxCancelToDownTimeInMs));
150 GestureConfiguration::set_fling_max_tap_gap_time_in_ms( 151 gesture_config->set_fling_max_tap_gap_time_in_ms(
151 prefs_->GetInteger(prefs::kFlingMaxTapGapTimeInMs)); 152 prefs_->GetInteger(prefs::kFlingMaxTapGapTimeInMs));
152 GestureConfiguration::set_tab_scrub_activation_delay_in_ms( 153 gesture_config->set_tab_scrub_activation_delay_in_ms(
153 prefs_->GetInteger(prefs::kTabScrubActivationDelayInMs)); 154 prefs_->GetInteger(prefs::kTabScrubActivationDelayInMs));
154 GestureConfiguration::set_semi_long_press_time_in_ms( 155 gesture_config->set_semi_long_press_time_in_ms(
155 prefs_->GetInteger(prefs::kSemiLongPressTimeInMs)); 156 prefs_->GetInteger(prefs::kSemiLongPressTimeInMs));
156 GestureConfiguration::set_max_separation_for_gesture_touches_in_pixels( 157 gesture_config->set_max_separation_for_gesture_touches_in_pixels(
157 static_cast<float>( 158 static_cast<float>(
158 prefs_->GetDouble(prefs::kMaxSeparationForGestureTouchesInPixels))); 159 prefs_->GetDouble(prefs::kMaxSeparationForGestureTouchesInPixels)));
159 160
160 UpdateOverscrollPrefs(); 161 UpdateOverscrollPrefs();
161 } 162 }
162 163
163 void GesturePrefsObserver::UpdateOverscrollPrefs() { 164 void GesturePrefsObserver::UpdateOverscrollPrefs() {
164 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs(); 165 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs();
165 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { 166 for (size_t i = 0; i < overscroll_prefs.size(); ++i) {
166 content::SetOverscrollConfig(overscroll_prefs[i].config, 167 content::SetOverscrollConfig(overscroll_prefs[i].config,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 for (size_t i = 0; i < overscroll_prefs.size(); ++i) { 205 for (size_t i = 0; i < overscroll_prefs.size(); ++i) {
205 registry->RegisterDoublePref( 206 registry->RegisterDoublePref(
206 overscroll_prefs[i].pref_name, 207 overscroll_prefs[i].pref_name,
207 content::GetOverscrollConfig(overscroll_prefs[i].config), 208 content::GetOverscrollConfig(overscroll_prefs[i].config),
208 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 209 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
209 } 210 }
210 } 211 }
211 212
212 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs( 213 void GesturePrefsObserverFactoryAura::RegisterProfilePrefs(
213 user_prefs::PrefRegistrySyncable* registry) { 214 user_prefs::PrefRegistrySyncable* registry) {
215 GestureConfiguration* gesture_config = GestureConfiguration::GetInstance();
214 registry->RegisterIntegerPref( 216 registry->RegisterIntegerPref(
215 prefs::kFlingMaxCancelToDownTimeInMs, 217 prefs::kFlingMaxCancelToDownTimeInMs,
216 GestureConfiguration::fling_max_cancel_to_down_time_in_ms(), 218 gesture_config->fling_max_cancel_to_down_time_in_ms(),
217 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 219 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
218 registry->RegisterIntegerPref( 220 registry->RegisterIntegerPref(
219 prefs::kFlingMaxTapGapTimeInMs, 221 prefs::kFlingMaxTapGapTimeInMs,
220 GestureConfiguration::fling_max_tap_gap_time_in_ms(), 222 gesture_config->fling_max_tap_gap_time_in_ms(),
221 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 223 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
222 registry->RegisterIntegerPref( 224 registry->RegisterIntegerPref(
223 prefs::kTabScrubActivationDelayInMs, 225 prefs::kTabScrubActivationDelayInMs,
224 GestureConfiguration::tab_scrub_activation_delay_in_ms(), 226 gesture_config->tab_scrub_activation_delay_in_ms(),
225 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 227 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
226 registry->RegisterIntegerPref( 228 registry->RegisterIntegerPref(
227 prefs::kSemiLongPressTimeInMs, 229 prefs::kSemiLongPressTimeInMs,
228 GestureConfiguration::semi_long_press_time_in_ms(), 230 gesture_config->semi_long_press_time_in_ms(),
229 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 231 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
230 registry->RegisterDoublePref( 232 registry->RegisterDoublePref(
231 prefs::kMaxSeparationForGestureTouchesInPixels, 233 prefs::kMaxSeparationForGestureTouchesInPixels,
232 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(), 234 gesture_config->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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/ash/tab_scrubber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698