OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_engines/default_search_pref_migration.h" | 5 #include "components/search_engines/default_search_pref_migration.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 12 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
12 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
13 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
15 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
16 #include "components/search_engines/default_search_manager.h" | 19 #include "components/search_engines/default_search_manager.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const base::ListValue* alternate_urls = | 78 const base::ListValue* alternate_urls = |
76 prefs->GetList(prefs::kDefaultSearchProviderAlternateURLs); | 79 prefs->GetList(prefs::kDefaultSearchProviderAlternateURLs); |
77 for (size_t i = 0; i < alternate_urls->GetSize(); ++i) { | 80 for (size_t i = 0; i < alternate_urls->GetSize(); ++i) { |
78 std::string alternate_url; | 81 std::string alternate_url; |
79 if (alternate_urls->GetString(i, &alternate_url)) | 82 if (alternate_urls->GetString(i, &alternate_url)) |
80 default_provider_data->alternate_urls.push_back(alternate_url); | 83 default_provider_data->alternate_urls.push_back(alternate_url); |
81 } | 84 } |
82 | 85 |
83 std::string id_string = prefs->GetString(prefs::kDefaultSearchProviderID); | 86 std::string id_string = prefs->GetString(prefs::kDefaultSearchProviderID); |
84 if (!id_string.empty()) { | 87 if (!id_string.empty()) { |
85 int64 value; | 88 int64_t value; |
86 base::StringToInt64(id_string, &value); | 89 base::StringToInt64(id_string, &value); |
87 default_provider_data->id = value; | 90 default_provider_data->id = value; |
88 } | 91 } |
89 | 92 |
90 std::string prepopulate_id = | 93 std::string prepopulate_id = |
91 prefs->GetString(prefs::kDefaultSearchProviderPrepopulateID); | 94 prefs->GetString(prefs::kDefaultSearchProviderPrepopulateID); |
92 if (!prepopulate_id.empty()) { | 95 if (!prepopulate_id.empty()) { |
93 int value; | 96 int value; |
94 base::StringToInt(prepopulate_id, &value); | 97 base::StringToInt(prepopulate_id, &value); |
95 default_provider_data->prepopulate_id = value; | 98 default_provider_data->prepopulate_id = value; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void ConfigureDefaultSearchPrefMigrationToDictionaryValue( | 160 void ConfigureDefaultSearchPrefMigrationToDictionaryValue( |
158 PrefService* pref_service) { | 161 PrefService* pref_service) { |
159 if (pref_service->GetInitializationStatus() == | 162 if (pref_service->GetInitializationStatus() == |
160 PrefService::INITIALIZATION_STATUS_WAITING) { | 163 PrefService::INITIALIZATION_STATUS_WAITING) { |
161 pref_service->AddPrefInitObserver( | 164 pref_service->AddPrefInitObserver( |
162 base::Bind(&OnPrefsInitialized, base::Unretained(pref_service))); | 165 base::Bind(&OnPrefsInitialized, base::Unretained(pref_service))); |
163 } else { | 166 } else { |
164 MigrateDefaultSearchPref(pref_service); | 167 MigrateDefaultSearchPref(pref_service); |
165 } | 168 } |
166 } | 169 } |
OLD | NEW |