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

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

Issue 21983002: Add a pref for a one-time wipe of gesture prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | « no previous file | chrome/common/pref_names.h » ('j') | chrome/common/pref_names.cc » ('J')
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"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 prefs::kFlingCurveTouchscreenAlpha, 144 prefs::kFlingCurveTouchscreenAlpha,
145 prefs::kFlingCurveTouchscreenBeta, 145 prefs::kFlingCurveTouchscreenBeta,
146 prefs::kFlingCurveTouchscreenGamma, 146 prefs::kFlingCurveTouchscreenGamma,
147 }; 147 };
148 148
149 GesturePrefsObserver::GesturePrefsObserver(PrefService* prefs) 149 GesturePrefsObserver::GesturePrefsObserver(PrefService* prefs)
150 : prefs_(prefs) { 150 : prefs_(prefs) {
151 // Clear for migration. 151 // Clear for migration.
152 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment); 152 prefs->ClearPref(kTouchScreenFlingAccelerationAdjustment);
153 153
154 // Do a one-time wipe of all gesture preferences.
155 if (!prefs->GetBoolean(prefs::kGestureConfigIsTrustworthy)) {
156 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i)
157 prefs->ClearPref(kPrefsToObserve[i]);
Bernhard Bauer 2013/08/02 22:18:40 Could you do this only if the pref has the default
mohsen 2013/08/07 05:58:04 I thought all prefs have default values. Isn't it
Bernhard Bauer 2013/08/07 06:01:43 Sorry, I meant if the current user-defined value o
mohsen 2013/08/07 16:28:11 Oh, I see. This makes sense. But, the problem is t
Bernhard Bauer 2013/08/07 16:43:52 Hm, ok.
158
159 const std::vector<OverscrollPref>& overscroll_prefs = GetOverscrollPrefs();
160 for (size_t i = 0; i < overscroll_prefs.size(); ++i)
161 prefs->ClearPref(overscroll_prefs[i].pref_name);
162
163 for (size_t i = 0; i < arraysize(kFlingTouchpadPrefs); ++i)
164 prefs->ClearPref(kFlingTouchpadPrefs[i]);
Bernhard Bauer 2013/08/02 22:18:40 Nit: newline.
mohsen 2013/08/07 05:58:04 Done.
165 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); ++i)
166 prefs->ClearPref(kFlingTouchscreenPrefs[i]);
167
168 #if defined(USE_ASH)
169 for (size_t i = 0; i < arraysize(kImmersiveModePrefs); ++i)
170 prefs->ClearPref(kImmersiveModePrefs[i]);
171 #endif // USE_ASH
172
173 prefs->SetBoolean(prefs::kGestureConfigIsTrustworthy, true);
174 }
175
154 registrar_.Init(prefs); 176 registrar_.Init(prefs);
155 registrar_.RemoveAll(); 177 registrar_.RemoveAll();
156 base::Closure callback = base::Bind(&GesturePrefsObserver::Update, 178 base::Closure callback = base::Bind(&GesturePrefsObserver::Update,
157 base::Unretained(this)); 179 base::Unretained(this));
158 180
159 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify, 181 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify,
160 base::Unretained(this)); 182 base::Unretained(this));
161 183
162 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i) 184 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i)
163 registrar_.Add(kPrefsToObserve[i], callback); 185 registrar_.Add(kPrefsToObserve[i], callback);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 496
475 // Register for migration. 497 // Register for migration.
476 registry->RegisterDoublePref( 498 registry->RegisterDoublePref(
477 kTouchScreenFlingAccelerationAdjustment, 499 kTouchScreenFlingAccelerationAdjustment,
478 0.0, 500 0.0,
479 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 501 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
480 502
481 RegisterOverscrollPrefs(registry); 503 RegisterOverscrollPrefs(registry);
482 RegisterFlingCurveParameters(registry); 504 RegisterFlingCurveParameters(registry);
483 RegisterImmersiveModePrefs(registry); 505 RegisterImmersiveModePrefs(registry);
506
507 // Register pref for a one-time wipe of all gesture preferences.
508 registry->RegisterBooleanPref(
509 prefs::kGestureConfigIsTrustworthy,
510 false,
511 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
484 } 512 }
485 513
486 bool 514 bool
487 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { 515 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const {
488 // Create the observer as soon as the profile is created. 516 // Create the observer as soon as the profile is created.
489 return true; 517 return true;
490 } 518 }
491 519
492 content::BrowserContext* 520 content::BrowserContext*
493 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( 521 GesturePrefsObserverFactoryAura::GetBrowserContextToUse(
494 content::BrowserContext* context) const { 522 content::BrowserContext* context) const {
495 // Use same gesture preferences on incognito windows. 523 // Use same gesture preferences on incognito windows.
496 return chrome::GetBrowserContextRedirectedInIncognito(context); 524 return chrome::GetBrowserContextRedirectedInIncognito(context);
497 } 525 }
498 526
499 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { 527 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const {
500 // Some tests replace the PrefService of the TestingProfile after the 528 // Some tests replace the PrefService of the TestingProfile after the
501 // GesturePrefsObserver has been created, which makes Shutdown() 529 // GesturePrefsObserver has been created, which makes Shutdown()
502 // remove the registrar from a non-existent PrefService. 530 // remove the registrar from a non-existent PrefService.
503 return true; 531 return true;
504 } 532 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/pref_names.h » ('j') | chrome/common/pref_names.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698