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

Side by Side Diff: components/search_engines/template_url_service.cc

Issue 2016463003: [sync] DCHECK from UTF16ToASCII from TemplateURLService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « chrome/browser/search_engines/template_url_service_sync_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/template_url_service.h" 5 #include "components/search_engines/template_url_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Sync and TemplateURLs that were initially local, assuming |sync_data| is the 124 // Sync and TemplateURLs that were initially local, assuming |sync_data| is the
125 // |initial_sync_data| parameter. 125 // |initial_sync_data| parameter.
126 bool IsFromSync(const TemplateURL* turl, const SyncDataMap& sync_data) { 126 bool IsFromSync(const TemplateURL* turl, const SyncDataMap& sync_data) {
127 return !!sync_data.count(turl->sync_guid()); 127 return !!sync_data.count(turl->sync_guid());
128 } 128 }
129 129
130 // Log the number of instances of a keyword that exist, with zero or more 130 // Log the number of instances of a keyword that exist, with zero or more
131 // underscores, which could occur as the result of conflict resolution. 131 // underscores, which could occur as the result of conflict resolution.
132 void LogDuplicatesHistogram( 132 void LogDuplicatesHistogram(
133 const TemplateURLService::TemplateURLVector& template_urls) { 133 const TemplateURLService::TemplateURLVector& template_urls) {
134 std::map<std::string, int> duplicates; 134 std::map<base::string16, int> duplicates;
135 for (TemplateURLService::TemplateURLVector::const_iterator it = 135 for (TemplateURLService::TemplateURLVector::const_iterator it =
136 template_urls.begin(); it != template_urls.end(); ++it) { 136 template_urls.begin(); it != template_urls.end(); ++it) {
137 std::string keyword = base::UTF16ToASCII((*it)->keyword()); 137 base::string16 keyword = (*it)->keyword();
138 base::TrimString(keyword, "_", &keyword); 138 base::TrimString(keyword, base::ASCIIToUTF16("_"), &keyword);
139 duplicates[keyword]++; 139 duplicates[keyword]++;
140 } 140 }
141 141
142 // Count the keywords with duplicates. 142 // Count the keywords with duplicates.
143 int num_dupes = 0; 143 int num_dupes = 0;
144 for (std::map<std::string, int>::const_iterator it = duplicates.begin(); 144 for (std::map<base::string16, int>::const_iterator it = duplicates.begin();
145 it != duplicates.end(); ++it) { 145 it != duplicates.end(); ++it) {
146 if (it->second > 1) 146 if (it->second > 1)
147 num_dupes++; 147 num_dupes++;
148 } 148 }
149 149
150 UMA_HISTOGRAM_COUNTS_100("Search.SearchEngineDuplicateCounts", num_dupes); 150 UMA_HISTOGRAM_COUNTS_100("Search.SearchEngineDuplicateCounts", num_dupes);
151 } 151 }
152 152
153 // Returns the length of the registry portion of a hostname. For example, 153 // Returns the length of the registry portion of a hostname. For example,
154 // www.google.co.uk will return 5 (the length of co.uk). 154 // www.google.co.uk will return 5 (the length of co.uk).
155 size_t GetRegistryLength(const base::string16& host) { 155 size_t GetRegistryLength(const base::string16& host) {
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 2434
2435 if (most_recently_intalled_default) { 2435 if (most_recently_intalled_default) {
2436 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2436 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2437 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2437 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2438 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2438 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2439 most_recently_intalled_default->data()); 2439 most_recently_intalled_default->data());
2440 } else { 2440 } else {
2441 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2441 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2442 } 2442 }
2443 } 2443 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_sync_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698