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 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 if (!force) { | 2178 if (!force) { |
2179 // Already unique. | 2179 // Already unique. |
2180 if (!GetTemplateURLForKeyword(turl.keyword())) | 2180 if (!GetTemplateURLForKeyword(turl.keyword())) |
2181 return turl.keyword(); | 2181 return turl.keyword(); |
2182 | 2182 |
2183 // First, try to return the generated keyword for the TemplateURL (except | 2183 // First, try to return the generated keyword for the TemplateURL (except |
2184 // for extensions, as their keywords are not associated with their URLs). | 2184 // for extensions, as their keywords are not associated with their URLs). |
2185 GURL gurl(turl.url()); | 2185 GURL gurl(turl.url()); |
2186 if (gurl.is_valid() && | 2186 if (gurl.is_valid() && |
2187 (turl.GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { | 2187 (turl.GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { |
2188 base::string16 keyword_candidate = TemplateURL::GenerateKeyword( | 2188 base::string16 keyword_candidate = TemplateURL::GenerateKeyword(gurl); |
2189 gurl, search_terms_data().GetAcceptLanguages()); | |
2190 if (!GetTemplateURLForKeyword(keyword_candidate)) | 2189 if (!GetTemplateURLForKeyword(keyword_candidate)) |
2191 return keyword_candidate; | 2190 return keyword_candidate; |
2192 } | 2191 } |
2193 } | 2192 } |
2194 | 2193 |
2195 // We try to uniquify the keyword by appending a special character to the end. | 2194 // We try to uniquify the keyword by appending a special character to the end. |
2196 // This is a best-effort approach where we try to preserve the original | 2195 // This is a best-effort approach where we try to preserve the original |
2197 // keyword and let the user do what they will after our attempt. | 2196 // keyword and let the user do what they will after our attempt. |
2198 base::string16 keyword_candidate(turl.keyword()); | 2197 base::string16 keyword_candidate(turl.keyword()); |
2199 do { | 2198 do { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 | 2435 |
2437 if (most_recently_intalled_default) { | 2436 if (most_recently_intalled_default) { |
2438 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2437 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2439 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2438 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2440 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2439 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2441 most_recently_intalled_default->data()); | 2440 most_recently_intalled_default->data()); |
2442 } else { | 2441 } else { |
2443 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2442 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2444 } | 2443 } |
2445 } | 2444 } |
OLD | NEW |