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

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

Issue 1238683003: Unpunycode search keywords and short names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix grammar. Created 5 years, 5 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
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 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 if (!force) { 2100 if (!force) {
2101 // Already unique. 2101 // Already unique.
2102 if (!GetTemplateURLForKeyword(turl.keyword())) 2102 if (!GetTemplateURLForKeyword(turl.keyword()))
2103 return turl.keyword(); 2103 return turl.keyword();
2104 2104
2105 // First, try to return the generated keyword for the TemplateURL (except 2105 // First, try to return the generated keyword for the TemplateURL (except
2106 // for extensions, as their keywords are not associated with their URLs). 2106 // for extensions, as their keywords are not associated with their URLs).
2107 GURL gurl(turl.url()); 2107 GURL gurl(turl.url());
2108 if (gurl.is_valid() && 2108 if (gurl.is_valid() &&
2109 (turl.GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { 2109 (turl.GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) {
2110 base::string16 keyword_candidate = TemplateURL::GenerateKeyword(gurl); 2110 base::string16 keyword_candidate = TemplateURL::GenerateKeyword(
2111 gurl, search_terms_data().GetAcceptLanguages());
2111 if (!GetTemplateURLForKeyword(keyword_candidate)) 2112 if (!GetTemplateURLForKeyword(keyword_candidate))
2112 return keyword_candidate; 2113 return keyword_candidate;
2113 } 2114 }
2114 } 2115 }
2115 2116
2116 // We try to uniquify the keyword by appending a special character to the end. 2117 // We try to uniquify the keyword by appending a special character to the end.
2117 // This is a best-effort approach where we try to preserve the original 2118 // This is a best-effort approach where we try to preserve the original
2118 // keyword and let the user do what they will after our attempt. 2119 // keyword and let the user do what they will after our attempt.
2119 base::string16 keyword_candidate(turl.keyword()); 2120 base::string16 keyword_candidate(turl.keyword());
2120 do { 2121 do {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 2329
2329 if (most_recently_intalled_default) { 2330 if (most_recently_intalled_default) {
2330 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2331 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2331 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2332 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2332 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2333 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2333 most_recently_intalled_default->data()); 2334 most_recently_intalled_default->data());
2334 } else { 2335 } else {
2335 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2336 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2336 } 2337 }
2337 } 2338 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url_parser.cc ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698