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

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

Issue 9562013: Revert 124433 - Adding persistance for gesture recognition parms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gesture_prefs.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/singleton.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/ui/gesture_prefs.h"
8 #include "chrome/browser/prefs/pref_change_registrar.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/pref_names.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "ui/aura/gestures/gesture_configuration.h"
14
15 namespace {
16
17 // This class manages gesture configuration preferences.
18 class GesturePrefsObserverAura : public content::NotificationObserver {
19 public:
20 static GesturePrefsObserverAura *GetInstance();
21 void RegisterPrefs(PrefService* prefs);
22
23 private:
24 GesturePrefsObserverAura();
25 friend struct DefaultSingletonTraits<GesturePrefsObserverAura>;
26 virtual ~GesturePrefsObserverAura();
27
28 // content::NotificationObserver implementation.
29 virtual void Observe(int type,
30 const content::NotificationSource& source,
31 const content::NotificationDetails& details) OVERRIDE;
32
33 private:
34 void Update();
35
36 PrefChangeRegistrar registrar_;
37
38 DISALLOW_COPY_AND_ASSIGN(GesturePrefsObserverAura);
39 };
40
41 GesturePrefsObserverAura::GesturePrefsObserverAura() {
42 }
43
44 GesturePrefsObserverAura::~GesturePrefsObserverAura() {
45 }
46
47 GesturePrefsObserverAura* GesturePrefsObserverAura::GetInstance() {
48 return Singleton<GesturePrefsObserverAura>::get();
49 }
50
51 // The list of prefs we want to observe.
52 // Note that this collection of settings should correspond to the settings used
53 // in ui/aura/gestures/gesture_configuration.h
54 const char* kPrefsToObserve[] = {
55 prefs::kMaximumSecondsBetweenDoubleClick,
56 prefs::kMaximumTouchDownDurationInSecondsForClick,
57 prefs::kMaximumTouchMoveInPixelsForClick,
58 prefs::kMinFlickSpeedSquared,
59 prefs::kMinimumTouchDownDurationInSecondsForClick,
60 };
61
62 const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
63
64 void GesturePrefsObserverAura::RegisterPrefs(PrefService* ) {
65 PrefService* local_state = g_browser_process->local_state();
66
67 local_state->RegisterDoublePref(
68 prefs::kMaximumSecondsBetweenDoubleClick, 0.7);
69 local_state->RegisterDoublePref(
70 prefs::kMaximumTouchDownDurationInSecondsForClick, 0.8);
71 local_state->RegisterDoublePref(
72 prefs::kMaximumTouchMoveInPixelsForClick, 20);
73 local_state->RegisterDoublePref(
74 prefs::kMinFlickSpeedSquared, 550.f*550.f);
75 local_state->RegisterDoublePref(
76 prefs::kMinimumTouchDownDurationInSecondsForClick, 0.01);
77
78 registrar_.Init(local_state);
79 if (local_state) {
80 for (int i = 0; i < kPrefsToObserveLength; ++i)
81 registrar_.Add(kPrefsToObserve[i], this);
82 }
83 }
84
85 void GesturePrefsObserverAura::Update() {
86 PrefService* local_state = g_browser_process->local_state();
87
88 aura::GestureConfiguration::set_max_seconds_between_double_click(
89 local_state->GetDouble(prefs::kMaximumSecondsBetweenDoubleClick));
90 aura::GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click(
91 local_state->GetDouble(prefs::kMaximumTouchDownDurationInSecondsForClick));
92 aura::GestureConfiguration::set_max_touch_move_in_pixels_for_click(
93 local_state->GetDouble(prefs::kMaximumTouchMoveInPixelsForClick));
94 aura::GestureConfiguration::set_min_flick_speed_squared(
95 local_state->GetDouble(prefs::kMinFlickSpeedSquared));
96 aura::GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click(
97 local_state->GetDouble(prefs::kMinimumTouchDownDurationInSecondsForClick));
98 }
99
100 void GesturePrefsObserverAura::Observe(int type,
101 const content::NotificationSource& source,
102 const content::NotificationDetails& details) {
103 Update();
104 }
105
106 } // namespace
107
108 void GesturePrefsRegisterPrefs(PrefService* prefs) {
109 GesturePrefsObserverAura::GetInstance()->RegisterPrefs(prefs);
110 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gesture_prefs.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698