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

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: Applied reviews 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') | 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"
(...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.
Peter Kasting 2013/08/09 19:03:54 Nit: Say why, as well as when this will be removed
mohsen 2013/08/09 20:12:34 Done.
155 if (!prefs->GetBoolean(prefs::kGestureConfigIsTrustworthy)) {
156 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i)
157 prefs->ClearPref(kPrefsToObserve[i]);
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]);
165
166 for (size_t i = 0; i < arraysize(kFlingTouchscreenPrefs); ++i)
167 prefs->ClearPref(kFlingTouchscreenPrefs[i]);
168
169 #if defined(USE_ASH)
170 for (size_t i = 0; i < arraysize(kImmersiveModePrefs); ++i)
171 prefs->ClearPref(kImmersiveModePrefs[i]);
172 #endif // USE_ASH
173
174 prefs->SetBoolean(prefs::kGestureConfigIsTrustworthy, true);
175 }
176
154 registrar_.Init(prefs); 177 registrar_.Init(prefs);
155 registrar_.RemoveAll(); 178 registrar_.RemoveAll();
156 base::Closure callback = base::Bind(&GesturePrefsObserver::Update, 179 base::Closure callback = base::Bind(&GesturePrefsObserver::Update,
157 base::Unretained(this)); 180 base::Unretained(this));
158 181
159 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify, 182 base::Closure notify_callback = base::Bind(&GesturePrefsObserver::Notify,
160 base::Unretained(this)); 183 base::Unretained(this));
161 184
162 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i) 185 for (size_t i = 0; i < arraysize(kPrefsToObserve); ++i)
163 registrar_.Add(kPrefsToObserve[i], callback); 186 registrar_.Add(kPrefsToObserve[i], callback);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 497
475 // Register for migration. 498 // Register for migration.
476 registry->RegisterDoublePref( 499 registry->RegisterDoublePref(
477 kTouchScreenFlingAccelerationAdjustment, 500 kTouchScreenFlingAccelerationAdjustment,
478 0.0, 501 0.0,
479 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 502 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
480 503
481 RegisterOverscrollPrefs(registry); 504 RegisterOverscrollPrefs(registry);
482 RegisterFlingCurveParameters(registry); 505 RegisterFlingCurveParameters(registry);
483 RegisterImmersiveModePrefs(registry); 506 RegisterImmersiveModePrefs(registry);
507
508 // Register pref for a one-time wipe of all gesture preferences.
509 registry->RegisterBooleanPref(
510 prefs::kGestureConfigIsTrustworthy,
511 false,
512 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
484 } 513 }
485 514
486 bool 515 bool
487 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const { 516 GesturePrefsObserverFactoryAura::ServiceIsCreatedWithBrowserContext() const {
488 // Create the observer as soon as the profile is created. 517 // Create the observer as soon as the profile is created.
489 return true; 518 return true;
490 } 519 }
491 520
492 content::BrowserContext* 521 content::BrowserContext*
493 GesturePrefsObserverFactoryAura::GetBrowserContextToUse( 522 GesturePrefsObserverFactoryAura::GetBrowserContextToUse(
494 content::BrowserContext* context) const { 523 content::BrowserContext* context) const {
495 // Use same gesture preferences on incognito windows. 524 // Use same gesture preferences on incognito windows.
496 return chrome::GetBrowserContextRedirectedInIncognito(context); 525 return chrome::GetBrowserContextRedirectedInIncognito(context);
497 } 526 }
498 527
499 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const { 528 bool GesturePrefsObserverFactoryAura::ServiceIsNULLWhileTesting() const {
500 // Some tests replace the PrefService of the TestingProfile after the 529 // Some tests replace the PrefService of the TestingProfile after the
501 // GesturePrefsObserver has been created, which makes Shutdown() 530 // GesturePrefsObserver has been created, which makes Shutdown()
502 // remove the registrar from a non-existent PrefService. 531 // remove the registrar from a non-existent PrefService.
503 return true; 532 return true;
504 } 533 }
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