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/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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
156 return net::registry_controlled_domains::GetRegistryLength( | 156 // TODO(bug 657199) this is wrong! This function converts UTF-16 to UTF-8 |
| 157 // then it gets canonicalized by the registry controlled domain function, and |
| 158 // then the length in the canonicalized string is returned. This length is |
| 159 // not the length in UTF-8 or even UTF-16 in the input! |
| 160 return net::registry_controlled_domains::BuggyGetHostRegistryLength( |
157 base::UTF16ToUTF8(host), | 161 base::UTF16ToUTF8(host), |
158 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 162 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
159 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 163 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
160 } | 164 } |
161 | 165 |
162 // Returns the domain name (including registry) of a hostname. For example, | 166 // Returns the domain name (including registry) of a hostname. For example, |
163 // www.google.co.uk will return google.co.uk. | 167 // www.google.co.uk will return google.co.uk. |
164 base::string16 GetDomainAndRegistry(const base::string16& host) { | 168 base::string16 GetDomainAndRegistry(const base::string16& host) { |
165 return base::UTF8ToUTF16( | 169 return base::UTF8ToUTF16( |
166 net::registry_controlled_domains::GetDomainAndRegistry( | 170 net::registry_controlled_domains::GetDomainAndRegistry( |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 | 2478 |
2475 if (most_recently_intalled_default) { | 2479 if (most_recently_intalled_default) { |
2476 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2480 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2477 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2481 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2478 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2482 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2479 most_recently_intalled_default->data()); | 2483 most_recently_intalled_default->data()); |
2480 } else { | 2484 } else { |
2481 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2485 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2482 } | 2486 } |
2483 } | 2487 } |
OLD | NEW |