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

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