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

Side by Side Diff: chrome/browser/prefs/chrome_pref_model_associator_client.cc

Issue 1302303002: Remove year+ old migration support of "session.urls_to_restore_on_startup". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pref_service_syncable_unittest
Patch Set: Address comments Created 5 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/prefs/chrome_pref_model_associator_client.h" 5 #include "chrome/browser/prefs/chrome_pref_model_associator_client.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "components/content_settings/core/browser/website_settings_info.h" 9 #include "components/content_settings/core/browser/website_settings_info.h"
10 #include "components/content_settings/core/browser/website_settings_registry.h" 10 #include "components/content_settings/core/browser/website_settings_registry.h"
11 11
12 namespace {
13 // List of migrated preference name pairs. If a preference is migrated
14 // (meaning renamed) adding the old and new preference names here will ensure
15 // that the sync engine knows how to deal with the synced values coming in
16 // with the old name. Preference migration itself doesn't happen here. It may
17 // happen in session_startup_pref.cc.
18 const struct MigratedPreferences {
19 const char* const old_name;
20 const char* const new_name;
21 } kMigratedPreferences[] = {
22 {prefs::kURLsToRestoreOnStartupOld, prefs::kURLsToRestoreOnStartup},
23 };
24 } // namespace
25
26 // static 12 // static
27 ChromePrefModelAssociatorClient* 13 ChromePrefModelAssociatorClient*
28 ChromePrefModelAssociatorClient::GetInstance() { 14 ChromePrefModelAssociatorClient::GetInstance() {
29 return base::Singleton<ChromePrefModelAssociatorClient>::get(); 15 return base::Singleton<ChromePrefModelAssociatorClient>::get();
30 } 16 }
31 17
32 ChromePrefModelAssociatorClient::ChromePrefModelAssociatorClient() {} 18 ChromePrefModelAssociatorClient::ChromePrefModelAssociatorClient() {}
33 19
34 ChromePrefModelAssociatorClient::~ChromePrefModelAssociatorClient() {} 20 ChromePrefModelAssociatorClient::~ChromePrefModelAssociatorClient() {}
35 21
36 bool ChromePrefModelAssociatorClient::IsMergeableListPreference( 22 bool ChromePrefModelAssociatorClient::IsMergeableListPreference(
37 const std::string& pref_name) const { 23 const std::string& pref_name) const {
38 return pref_name == prefs::kURLsToRestoreOnStartup; 24 return pref_name == prefs::kURLsToRestoreOnStartup;
39 } 25 }
40 26
41 bool ChromePrefModelAssociatorClient::IsMergeableDictionaryPreference( 27 bool ChromePrefModelAssociatorClient::IsMergeableDictionaryPreference(
42 const std::string& pref_name) const { 28 const std::string& pref_name) const {
43 const content_settings::WebsiteSettingsRegistry& registry = 29 const content_settings::WebsiteSettingsRegistry& registry =
44 *content_settings::WebsiteSettingsRegistry::GetInstance(); 30 *content_settings::WebsiteSettingsRegistry::GetInstance();
45 for (const content_settings::WebsiteSettingsInfo* info : registry) { 31 for (const content_settings::WebsiteSettingsInfo* info : registry) {
46 if (info->pref_name() == pref_name) 32 if (info->pref_name() == pref_name)
47 return true; 33 return true;
48 } 34 }
49 return false; 35 return false;
50 } 36 }
51
52 bool ChromePrefModelAssociatorClient::IsMigratedPreference(
53 const std::string& new_pref_name,
54 std::string* old_pref_name) const {
55 for (size_t i = 0; i < arraysize(kMigratedPreferences); ++i) {
56 if (new_pref_name == kMigratedPreferences[i].new_name) {
57 old_pref_name->assign(kMigratedPreferences[i].old_name);
58 return true;
59 }
60 }
61 return false;
62 }
63
64 bool ChromePrefModelAssociatorClient::IsOldMigratedPreference(
65 const std::string& old_pref_name,
66 std::string* new_pref_name) const {
67 for (size_t i = 0; i < arraysize(kMigratedPreferences); ++i) {
68 if (old_pref_name == kMigratedPreferences[i].old_name) {
69 new_pref_name->assign(kMigratedPreferences[i].new_name);
70 return true;
71 }
72 }
73 return false;
74 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/chrome_pref_model_associator_client.h ('k') | chrome/browser/prefs/session_startup_pref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698