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

Side by Side Diff: chrome/browser/ui/views/ash/gesture_prefs_aura.cc

Issue 9751011: Gesture recognition constants should all be stored in the GestureConfiguration object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Freshen Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/common/pref_names.h » ('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) 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 "base/memory/singleton.h" 5 #include "base/memory/singleton.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/ui/gesture_prefs.h" 7 #include "chrome/browser/ui/gesture_prefs.h"
8 #include "chrome/browser/prefs/pref_change_registrar.h" 8 #include "chrome/browser/prefs/pref_change_registrar.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 26 matching lines...) Expand all
37 37
38 PrefChangeRegistrar registrar_; 38 PrefChangeRegistrar registrar_;
39 PrefService* local_state_; 39 PrefService* local_state_;
40 DISALLOW_COPY_AND_ASSIGN(GesturePrefsObserverAura); 40 DISALLOW_COPY_AND_ASSIGN(GesturePrefsObserverAura);
41 }; 41 };
42 42
43 // The list of prefs we want to observe. 43 // The list of prefs we want to observe.
44 // Note that this collection of settings should correspond to the settings used 44 // Note that this collection of settings should correspond to the settings used
45 // in ui/aura/gestures/gesture_configuration.h 45 // in ui/aura/gestures/gesture_configuration.h
46 const char* kPrefsToObserve[] = { 46 const char* kPrefsToObserve[] = {
47 prefs::kMaximumSecondsBetweenDoubleClick, 47 prefs::kLongPressTimeInSeconds,
48 prefs::kMaximumTouchDownDurationInSecondsForClick, 48 prefs::kMaxSecondsBetweenDoubleClick,
49 prefs::kMaximumTouchMoveInPixelsForClick, 49 prefs::kMaxSeparationForGestureTouchesInPixels,
50 prefs::kMaxTouchDownDurationInSecondsForClick,
51 prefs::kMaxTouchMoveInPixelsForClick,
52 prefs::kMinDistanceForPinchScrollInPixels,
50 prefs::kMinFlickSpeedSquared, 53 prefs::kMinFlickSpeedSquared,
51 prefs::kMinimumTouchDownDurationInSecondsForClick, 54 prefs::kMinPinchUpdateDistanceInPixels,
55 prefs::kMinRailBreakVelocity,
56 prefs::kMinScrollDeltaSquared,
57 prefs::kMinTouchDownDurationInSecondsForClick,
58 prefs::kPointsBufferedForVelocity,
59 prefs::kRailBreakProportion,
60 prefs::kRailStartProportion,
52 }; 61 };
53 62
54 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); 63 const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
55 64
56 GesturePrefsObserverAura::GesturePrefsObserverAura() 65 GesturePrefsObserverAura::GesturePrefsObserverAura()
57 : local_state_(0) { 66 : local_state_(0) {
58 } 67 }
59 68
60 GesturePrefsObserverAura::~GesturePrefsObserverAura() { 69 GesturePrefsObserverAura::~GesturePrefsObserverAura() {
61 } 70 }
62 71
63 GesturePrefsObserverAura* GesturePrefsObserverAura::GetInstance() { 72 GesturePrefsObserverAura* GesturePrefsObserverAura::GetInstance() {
64 return Singleton<GesturePrefsObserverAura, 73 return Singleton<GesturePrefsObserverAura,
65 LeakySingletonTraits<GesturePrefsObserverAura> >::get(); 74 LeakySingletonTraits<GesturePrefsObserverAura> >::get();
66 } 75 }
67 76
68 void GesturePrefsObserverAura::RegisterPrefs(PrefService* local_state) { 77 void GesturePrefsObserverAura::RegisterPrefs(PrefService* local_state) {
69 if (local_state_ == 0) { 78 if (local_state_ == 0) {
70 local_state_ = local_state; 79 local_state_ = local_state;
71 80
72 if (local_state_) { 81 if (local_state_) {
82 local_state->RegisterDoublePref(
83 prefs::kLongPressTimeInSeconds,
84 GestureConfiguration::long_press_time_in_seconds());
73 local_state_->RegisterDoublePref( 85 local_state_->RegisterDoublePref(
74 prefs::kMaximumSecondsBetweenDoubleClick, 0.7); 86 prefs::kMaxSecondsBetweenDoubleClick,
87 GestureConfiguration::max_seconds_between_double_click());
75 local_state_->RegisterDoublePref( 88 local_state_->RegisterDoublePref(
76 prefs::kMaximumTouchDownDurationInSecondsForClick, 0.8); 89 prefs::kMaxSeparationForGestureTouchesInPixels,
90 GestureConfiguration::max_separation_for_gesture_touches_in_pixels());
77 local_state_->RegisterDoublePref( 91 local_state_->RegisterDoublePref(
78 prefs::kMaximumTouchMoveInPixelsForClick, 20); 92 prefs::kMaxTouchDownDurationInSecondsForClick,
93 GestureConfiguration::max_touch_down_duration_in_seconds_for_click());
79 local_state_->RegisterDoublePref( 94 local_state_->RegisterDoublePref(
80 prefs::kMinFlickSpeedSquared, 550.f*550.f); 95 prefs::kMaxTouchMoveInPixelsForClick,
96 GestureConfiguration::max_touch_move_in_pixels_for_click());
97 local_state->RegisterDoublePref(
98 prefs::kMinDistanceForPinchScrollInPixels,
99 GestureConfiguration::min_distance_for_pinch_scroll_in_pixels());
81 local_state_->RegisterDoublePref( 100 local_state_->RegisterDoublePref(
82 prefs::kMinimumTouchDownDurationInSecondsForClick, 0.01); 101 prefs::kMinFlickSpeedSquared,
102 GestureConfiguration::min_flick_speed_squared());
103 local_state->RegisterDoublePref(
104 prefs::kMinPinchUpdateDistanceInPixels,
105 GestureConfiguration::min_pinch_update_distance_in_pixels());
106 local_state_->RegisterDoublePref(
107 prefs::kMinRailBreakVelocity,
108 GestureConfiguration::min_rail_break_velocity());
109 local_state_->RegisterDoublePref(
110 prefs::kMinScrollDeltaSquared,
111 GestureConfiguration::min_scroll_delta_squared());
112 local_state_->RegisterDoublePref(
113 prefs::kMinTouchDownDurationInSecondsForClick,
114 GestureConfiguration::min_touch_down_duration_in_seconds_for_click());
115 local_state->RegisterIntegerPref(
116 prefs::kPointsBufferedForVelocity,
117 GestureConfiguration::points_buffered_for_velocity());
118 local_state->RegisterDoublePref(
119 prefs::kRailBreakProportion,
120 GestureConfiguration::rail_break_proportion());
121 local_state->RegisterDoublePref(
122 prefs::kRailStartProportion,
123 GestureConfiguration::rail_start_proportion());
83 124
84 registrar_.Init(local_state_); 125 registrar_.Init(local_state_);
85 registrar_.RemoveAll(); 126 registrar_.RemoveAll();
86 for (int i = 0; i < kPrefsToObserveLength; ++i) 127 for (int i = 0; i < kPrefsToObserveLength; ++i)
87 registrar_.Add(kPrefsToObserve[i], this); 128 registrar_.Add(kPrefsToObserve[i], this);
88 } 129 }
89 } 130 }
90 } 131 }
91 132
92 void GesturePrefsObserverAura::Update() { 133 void GesturePrefsObserverAura::Update() {
93 if (local_state_) { 134 if (local_state_) {
135 GestureConfiguration::set_long_press_time_in_seconds(
136 local_state_->GetDouble(
137 prefs::kLongPressTimeInSeconds));
94 GestureConfiguration::set_max_seconds_between_double_click( 138 GestureConfiguration::set_max_seconds_between_double_click(
95 local_state_->GetDouble(prefs::kMaximumSecondsBetweenDoubleClick)); 139 local_state_->GetDouble(
140 prefs::kMaxSecondsBetweenDoubleClick));
141 GestureConfiguration::set_max_separation_for_gesture_touches_in_pixels(
142 local_state_->GetDouble(
143 prefs::kMaxSeparationForGestureTouchesInPixels));
96 GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click( 144 GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click(
97 local_state_->GetDouble( 145 local_state_->GetDouble(
98 prefs::kMaximumTouchDownDurationInSecondsForClick)); 146 prefs::kMaxTouchDownDurationInSecondsForClick));
99 GestureConfiguration::set_max_touch_move_in_pixels_for_click( 147 GestureConfiguration::set_max_touch_move_in_pixels_for_click(
100 local_state_->GetDouble(prefs::kMaximumTouchMoveInPixelsForClick)); 148 local_state_->GetDouble(
149 prefs::kMaxTouchMoveInPixelsForClick));
150 GestureConfiguration::set_min_distance_for_pinch_scroll_in_pixels(
151 local_state_->GetDouble(
152 prefs::kMinDistanceForPinchScrollInPixels));
101 GestureConfiguration::set_min_flick_speed_squared( 153 GestureConfiguration::set_min_flick_speed_squared(
102 local_state_->GetDouble(prefs::kMinFlickSpeedSquared)); 154 local_state_->GetDouble(
155 prefs::kMinFlickSpeedSquared));
156 GestureConfiguration::set_min_pinch_update_distance_in_pixels(
157 local_state_->GetDouble(
158 prefs::kMinPinchUpdateDistanceInPixels));
159 GestureConfiguration::set_min_rail_break_velocity(
160 local_state_->GetDouble(
161 prefs::kMinRailBreakVelocity));
162 GestureConfiguration::set_min_scroll_delta_squared(
163 local_state_->GetDouble(
164 prefs::kMinScrollDeltaSquared));
103 GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click( 165 GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click(
104 local_state_->GetDouble( 166 local_state_->GetDouble(
105 prefs::kMinimumTouchDownDurationInSecondsForClick)); 167 prefs::kMinTouchDownDurationInSecondsForClick));
168 GestureConfiguration::set_points_buffered_for_velocity(
169 local_state_->GetInteger(
170 prefs::kPointsBufferedForVelocity));
171 GestureConfiguration::set_rail_break_proportion(
172 local_state_->GetDouble(
173 prefs::kRailBreakProportion));
174 GestureConfiguration::set_rail_start_proportion(
175 local_state_->GetDouble(
176 prefs::kRailStartProportion));
106 } 177 }
107 } 178 }
108 179
109 void GesturePrefsObserverAura::Observe(int type, 180 void GesturePrefsObserverAura::Observe(int type,
110 const content::NotificationSource& source, 181 const content::NotificationSource& source,
111 const content::NotificationDetails& details) { 182 const content::NotificationDetails& details) {
112 Update(); 183 Update();
113 } 184 }
114 185
115 } // namespace 186 } // namespace
116 187
117 void GesturePrefsRegisterPrefs(PrefService* prefs) { 188 void GesturePrefsRegisterPrefs(PrefService* prefs) {
118 GesturePrefsObserverAura::GetInstance()->RegisterPrefs(prefs); 189 GesturePrefsObserverAura::GetInstance()->RegisterPrefs(prefs);
119 } 190 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698