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

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/search_engines/template_url_service.h" 5 #include "chrome/browser/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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 // static 322 // static
323 base::string16 TemplateURLService::GenerateKeyword(const GURL& url) { 323 base::string16 TemplateURLService::GenerateKeyword(const GURL& url) {
324 DCHECK(url.is_valid()); 324 DCHECK(url.is_valid());
325 // Strip "www." off the front of the keyword; otherwise the keyword won't work 325 // Strip "www." off the front of the keyword; otherwise the keyword won't work
326 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . 326 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 .
327 // Special case: if the host was exactly "www." (not sure this can happen but 327 // Special case: if the host was exactly "www." (not sure this can happen but
328 // perhaps with some weird intranet and custom DNS server?), ensure we at 328 // perhaps with some weird intranet and custom DNS server?), ensure we at
329 // least don't return the empty string. 329 // least don't return the empty string.
330 base::string16 keyword(net::StripWWWFromHost(url)); 330 base::string16 keyword(net::StripWWWFromHost(url));
331 return keyword.empty() ? ASCIIToUTF16("www") : keyword; 331 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword;
332 } 332 }
333 333
334 // static 334 // static
335 base::string16 TemplateURLService::CleanUserInputKeyword( 335 base::string16 TemplateURLService::CleanUserInputKeyword(
336 const base::string16& keyword) { 336 const base::string16& keyword) {
337 // Remove the scheme. 337 // Remove the scheme.
338 base::string16 result(base::i18n::ToLower(keyword)); 338 base::string16 result(base::i18n::ToLower(keyword));
339 TrimWhitespace(result, TRIM_ALL, &result); 339 TrimWhitespace(result, TRIM_ALL, &result);
340 url_parse::Component scheme_component; 340 url_parse::Component scheme_component;
341 if (url_parse::ExtractScheme(UTF16ToUTF8(keyword).c_str(), 341 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(),
342 static_cast<int>(keyword.length()), 342 static_cast<int>(keyword.length()),
343 &scheme_component)) { 343 &scheme_component)) {
344 // If the scheme isn't "http" or "https", bail. The user isn't trying to 344 // If the scheme isn't "http" or "https", bail. The user isn't trying to
345 // type a web address, but rather an FTP, file:, or other scheme URL, or a 345 // type a web address, but rather an FTP, file:, or other scheme URL, or a
346 // search query with some sort of initial operator (e.g. "site:"). 346 // search query with some sort of initial operator (e.g. "site:").
347 if (result.compare(0, scheme_component.end(), 347 if (result.compare(0, scheme_component.end(),
348 ASCIIToUTF16(content::kHttpScheme)) && 348 base::ASCIIToUTF16(content::kHttpScheme)) &&
349 result.compare(0, scheme_component.end(), 349 result.compare(0, scheme_component.end(),
350 ASCIIToUTF16(content::kHttpsScheme))) 350 base::ASCIIToUTF16(content::kHttpsScheme)))
351 return base::string16(); 351 return base::string16();
352 352
353 // Include trailing ':'. 353 // Include trailing ':'.
354 result.erase(0, scheme_component.end() + 1); 354 result.erase(0, scheme_component.end() + 1);
355 // Many schemes usually have "//" after them, so strip it too. 355 // Many schemes usually have "//" after them, so strip it too.
356 const base::string16 after_scheme(ASCIIToUTF16("//")); 356 const base::string16 after_scheme(base::ASCIIToUTF16("//"));
357 if (result.compare(0, after_scheme.length(), after_scheme) == 0) 357 if (result.compare(0, after_scheme.length(), after_scheme) == 0)
358 result.erase(0, after_scheme.length()); 358 result.erase(0, after_scheme.length());
359 } 359 }
360 360
361 // Remove leading "www.". 361 // Remove leading "www.".
362 result = net::StripWWW(result); 362 result = net::StripWWW(result);
363 363
364 // Remove trailing "/". 364 // Remove trailing "/".
365 return (result.length() > 0 && result[result.length() - 1] == '/') ? 365 return (result.length() > 0 && result[result.length() - 1] == '/') ?
366 result.substr(0, result.length() - 1) : result; 366 result.substr(0, result.length() - 1) : result;
(...skipping 18 matching lines...) Expand all
385 385
386 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data)) 386 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data))
387 return GURL(t_url->url()); 387 return GURL(t_url->url());
388 388
389 // Use something obscure for the search terms argument so that in the rare 389 // Use something obscure for the search terms argument so that in the rare
390 // case the term replaces the URL it's unlikely another keyword would have the 390 // case the term replaces the URL it's unlikely another keyword would have the
391 // same url. 391 // same url.
392 // TODO(jnd): Add additional parameters to get post data when the search URL 392 // TODO(jnd): Add additional parameters to get post data when the search URL
393 // has post parameters. 393 // has post parameters.
394 return GURL(search_ref.ReplaceSearchTermsUsingTermsData( 394 return GURL(search_ref.ReplaceSearchTermsUsingTermsData(
395 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah.blah.blah.blah.blah")), 395 TemplateURLRef::SearchTermsArgs(
396 base::ASCIIToUTF16("blah.blah.blah.blah.blah")),
396 search_terms_data, NULL)); 397 search_terms_data, NULL));
397 } 398 }
398 399
399 bool TemplateURLService::CanReplaceKeyword( 400 bool TemplateURLService::CanReplaceKeyword(
400 const base::string16& keyword, 401 const base::string16& keyword,
401 const GURL& url, 402 const GURL& url,
402 TemplateURL** template_url_to_replace) { 403 TemplateURL** template_url_to_replace) {
403 DCHECK(!keyword.empty()); // This should only be called for non-empty 404 DCHECK(!keyword.empty()); // This should only be called for non-empty
404 // keywords. If we need to support empty kewords 405 // keywords. If we need to support empty kewords
405 // the code needs to change slightly. 406 // the code needs to change slightly.
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 1269
1269 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 1270 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
1270 } 1271 }
1271 1272
1272 // static 1273 // static
1273 syncer::SyncData TemplateURLService::CreateSyncDataFromTemplateURL( 1274 syncer::SyncData TemplateURLService::CreateSyncDataFromTemplateURL(
1274 const TemplateURL& turl) { 1275 const TemplateURL& turl) {
1275 sync_pb::EntitySpecifics specifics; 1276 sync_pb::EntitySpecifics specifics;
1276 sync_pb::SearchEngineSpecifics* se_specifics = 1277 sync_pb::SearchEngineSpecifics* se_specifics =
1277 specifics.mutable_search_engine(); 1278 specifics.mutable_search_engine();
1278 se_specifics->set_short_name(UTF16ToUTF8(turl.short_name())); 1279 se_specifics->set_short_name(base::UTF16ToUTF8(turl.short_name()));
1279 se_specifics->set_keyword(UTF16ToUTF8(turl.keyword())); 1280 se_specifics->set_keyword(base::UTF16ToUTF8(turl.keyword()));
1280 se_specifics->set_favicon_url(turl.favicon_url().spec()); 1281 se_specifics->set_favicon_url(turl.favicon_url().spec());
1281 se_specifics->set_url(turl.url()); 1282 se_specifics->set_url(turl.url());
1282 se_specifics->set_safe_for_autoreplace(turl.safe_for_autoreplace()); 1283 se_specifics->set_safe_for_autoreplace(turl.safe_for_autoreplace());
1283 se_specifics->set_originating_url(turl.originating_url().spec()); 1284 se_specifics->set_originating_url(turl.originating_url().spec());
1284 se_specifics->set_date_created(turl.date_created().ToInternalValue()); 1285 se_specifics->set_date_created(turl.date_created().ToInternalValue());
1285 se_specifics->set_input_encodings(JoinString(turl.input_encodings(), ';')); 1286 se_specifics->set_input_encodings(JoinString(turl.input_encodings(), ';'));
1286 se_specifics->set_show_in_default_list(turl.show_in_default_list()); 1287 se_specifics->set_show_in_default_list(turl.show_in_default_list());
1287 se_specifics->set_suggestions_url(turl.suggestions_url()); 1288 se_specifics->set_suggestions_url(turl.suggestions_url());
1288 se_specifics->set_prepopulate_id(turl.prepopulate_id()); 1289 se_specifics->set_prepopulate_id(turl.prepopulate_id());
1289 se_specifics->set_instant_url(turl.instant_url()); 1290 se_specifics->set_instant_url(turl.instant_url());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 syncer::SyncChange(FROM_HERE, 1331 syncer::SyncChange(FROM_HERE,
1331 syncer::SyncChange::ACTION_DELETE, 1332 syncer::SyncChange::ACTION_DELETE,
1332 sync_data)); 1333 sync_data));
1333 UMA_HISTOGRAM_ENUMERATION(kDeleteSyncedEngineHistogramName, 1334 UMA_HISTOGRAM_ENUMERATION(kDeleteSyncedEngineHistogramName,
1334 DELETE_ENGINE_EMPTY_FIELD, DELETE_ENGINE_MAX); 1335 DELETE_ENGINE_EMPTY_FIELD, DELETE_ENGINE_MAX);
1335 return NULL; 1336 return NULL;
1336 } 1337 }
1337 1338
1338 TemplateURLData data(existing_turl ? 1339 TemplateURLData data(existing_turl ?
1339 existing_turl->data() : TemplateURLData()); 1340 existing_turl->data() : TemplateURLData());
1340 data.short_name = UTF8ToUTF16(specifics.short_name()); 1341 data.short_name = base::UTF8ToUTF16(specifics.short_name());
1341 data.originating_url = GURL(specifics.originating_url()); 1342 data.originating_url = GURL(specifics.originating_url());
1342 base::string16 keyword(UTF8ToUTF16(specifics.keyword())); 1343 base::string16 keyword(base::UTF8ToUTF16(specifics.keyword()));
1343 // NOTE: Once this code has shipped in a couple of stable releases, we can 1344 // NOTE: Once this code has shipped in a couple of stable releases, we can
1344 // probably remove the migration portion, comment out the 1345 // probably remove the migration portion, comment out the
1345 // "autogenerate_keyword" field entirely in the .proto file, and fold the 1346 // "autogenerate_keyword" field entirely in the .proto file, and fold the
1346 // empty keyword case into the "delete data" block above. 1347 // empty keyword case into the "delete data" block above.
1347 bool reset_keyword = 1348 bool reset_keyword =
1348 specifics.autogenerate_keyword() || specifics.keyword().empty(); 1349 specifics.autogenerate_keyword() || specifics.keyword().empty();
1349 if (reset_keyword) 1350 if (reset_keyword)
1350 keyword = ASCIIToUTF16("dummy"); // Will be replaced below. 1351 keyword = base::ASCIIToUTF16("dummy"); // Will be replaced below.
1351 DCHECK(!keyword.empty()); 1352 DCHECK(!keyword.empty());
1352 data.SetKeyword(keyword); 1353 data.SetKeyword(keyword);
1353 data.SetURL(specifics.url()); 1354 data.SetURL(specifics.url());
1354 data.suggestions_url = specifics.suggestions_url(); 1355 data.suggestions_url = specifics.suggestions_url();
1355 data.instant_url = specifics.instant_url(); 1356 data.instant_url = specifics.instant_url();
1356 data.image_url = specifics.image_url(); 1357 data.image_url = specifics.image_url();
1357 data.new_tab_url = specifics.new_tab_url(); 1358 data.new_tab_url = specifics.new_tab_url();
1358 data.search_url_post_params = specifics.search_url_post_params(); 1359 data.search_url_post_params = specifics.search_url_post_params();
1359 data.suggestions_url_post_params = specifics.suggestions_url_post_params(); 1360 data.suggestions_url_post_params = specifics.suggestions_url_post_params();
1360 data.instant_url_post_params = specifics.instant_url_post_params(); 1361 data.instant_url_post_params = specifics.instant_url_post_params();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 1464
1464 // Add specific initializers, if any. 1465 // Add specific initializers, if any.
1465 for (int i(0); i < num_initializers; ++i) { 1466 for (int i(0); i < num_initializers; ++i) {
1466 DCHECK(initializers[i].keyword); 1467 DCHECK(initializers[i].keyword);
1467 DCHECK(initializers[i].url); 1468 DCHECK(initializers[i].url);
1468 DCHECK(initializers[i].content); 1469 DCHECK(initializers[i].content);
1469 1470
1470 // TemplateURLService ends up owning the TemplateURL, don't try and free 1471 // TemplateURLService ends up owning the TemplateURL, don't try and free
1471 // it. 1472 // it.
1472 TemplateURLData data; 1473 TemplateURLData data;
1473 data.short_name = UTF8ToUTF16(initializers[i].content); 1474 data.short_name = base::UTF8ToUTF16(initializers[i].content);
1474 data.SetKeyword(UTF8ToUTF16(initializers[i].keyword)); 1475 data.SetKeyword(base::UTF8ToUTF16(initializers[i].keyword));
1475 data.SetURL(initializers[i].url); 1476 data.SetURL(initializers[i].url);
1476 TemplateURL* template_url = new TemplateURL(profile_, data); 1477 TemplateURL* template_url = new TemplateURL(profile_, data);
1477 AddNoNotify(template_url, true); 1478 AddNoNotify(template_url, true);
1478 1479
1479 // Set the first provided identifier to be the default. 1480 // Set the first provided identifier to be the default.
1480 if (i == 0) 1481 if (i == 0)
1481 SetDefaultSearchProviderNoNotify(template_url); 1482 SetDefaultSearchProviderNoNotify(template_url);
1482 } 1483 }
1483 } 1484 }
1484 1485
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 image_url = t_url->image_url(); 1638 image_url = t_url->image_url();
1638 new_tab_url = t_url->new_tab_url(); 1639 new_tab_url = t_url->new_tab_url();
1639 search_url_post_params = t_url->search_url_post_params(); 1640 search_url_post_params = t_url->search_url_post_params();
1640 suggest_url_post_params = t_url->suggestions_url_post_params(); 1641 suggest_url_post_params = t_url->suggestions_url_post_params();
1641 instant_url_post_params = t_url->instant_url_post_params(); 1642 instant_url_post_params = t_url->instant_url_post_params();
1642 image_url_post_params = t_url->image_url_post_params(); 1643 image_url_post_params = t_url->image_url_post_params();
1643 GURL icon_gurl = t_url->favicon_url(); 1644 GURL icon_gurl = t_url->favicon_url();
1644 if (!icon_gurl.is_empty()) 1645 if (!icon_gurl.is_empty())
1645 icon_url = icon_gurl.spec(); 1646 icon_url = icon_gurl.spec();
1646 encodings = JoinString(t_url->input_encodings(), ';'); 1647 encodings = JoinString(t_url->input_encodings(), ';');
1647 short_name = UTF16ToUTF8(t_url->short_name()); 1648 short_name = base::UTF16ToUTF8(t_url->short_name());
1648 keyword = UTF16ToUTF8(t_url->keyword()); 1649 keyword = base::UTF16ToUTF8(t_url->keyword());
1649 id_string = base::Int64ToString(t_url->id()); 1650 id_string = base::Int64ToString(t_url->id());
1650 prepopulate_id = base::Int64ToString(t_url->prepopulate_id()); 1651 prepopulate_id = base::Int64ToString(t_url->prepopulate_id());
1651 for (size_t i = 0; i < t_url->alternate_urls().size(); ++i) 1652 for (size_t i = 0; i < t_url->alternate_urls().size(); ++i)
1652 alternate_urls.AppendString(t_url->alternate_urls()[i]); 1653 alternate_urls.AppendString(t_url->alternate_urls()[i]);
1653 search_terms_replacement_key = t_url->search_terms_replacement_key(); 1654 search_terms_replacement_key = t_url->search_terms_replacement_key();
1654 } 1655 }
1655 prefs->SetBoolean(prefs::kDefaultSearchProviderEnabled, enabled); 1656 prefs->SetBoolean(prefs::kDefaultSearchProviderEnabled, enabled);
1656 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, search_url); 1657 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, search_url);
1657 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, suggest_url); 1658 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, suggest_url);
1658 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, instant_url); 1659 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, instant_url);
(...skipping 29 matching lines...) Expand all
1688 prefs->FindPreference(prefs::kDefaultSearchProviderSearchURL); 1689 prefs->FindPreference(prefs::kDefaultSearchProviderSearchURL);
1689 *is_managed = pref && pref->IsManaged(); 1690 *is_managed = pref && pref->IsManaged();
1690 1691
1691 if (!prefs->GetBoolean(prefs::kDefaultSearchProviderEnabled)) { 1692 if (!prefs->GetBoolean(prefs::kDefaultSearchProviderEnabled)) {
1692 // The user doesn't want a default search provider. 1693 // The user doesn't want a default search provider.
1693 default_provider->reset(NULL); 1694 default_provider->reset(NULL);
1694 return true; 1695 return true;
1695 } 1696 }
1696 1697
1697 base::string16 name = 1698 base::string16 name =
1698 UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderName)); 1699 base::UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderName));
1699 base::string16 keyword = 1700 base::string16 keyword =
1700 UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderKeyword)); 1701 base::UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderKeyword));
1701 // Force keyword to be non-empty. 1702 // Force keyword to be non-empty.
1702 // TODO(pkasting): This is only necessary as long as we're potentially loading 1703 // TODO(pkasting): This is only necessary as long as we're potentially loading
1703 // older prefs where empty keywords are theoretically possible. Eventually 1704 // older prefs where empty keywords are theoretically possible. Eventually
1704 // this code can be replaced with a DCHECK(!keyword.empty());. 1705 // this code can be replaced with a DCHECK(!keyword.empty());.
1705 bool update_keyword = keyword.empty(); 1706 bool update_keyword = keyword.empty();
1706 if (update_keyword) 1707 if (update_keyword)
1707 keyword = ASCIIToUTF16("dummy"); 1708 keyword = base::ASCIIToUTF16("dummy");
1708 std::string search_url = 1709 std::string search_url =
1709 prefs->GetString(prefs::kDefaultSearchProviderSearchURL); 1710 prefs->GetString(prefs::kDefaultSearchProviderSearchURL);
1710 // Force URL to be non-empty. We've never supported this case, but past bugs 1711 // Force URL to be non-empty. We've never supported this case, but past bugs
1711 // might have resulted in it slipping through; eventually this code can be 1712 // might have resulted in it slipping through; eventually this code can be
1712 // replaced with a DCHECK(!search_url.empty());. 1713 // replaced with a DCHECK(!search_url.empty());.
1713 if (search_url.empty()) 1714 if (search_url.empty())
1714 return false; 1715 return false;
1715 std::string suggest_url = 1716 std::string suggest_url =
1716 prefs->GetString(prefs::kDefaultSearchProviderSuggestURL); 1717 prefs->GetString(prefs::kDefaultSearchProviderSuggestURL);
1717 std::string instant_url = 1718 std::string instant_url =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 return; 1958 return;
1958 1959
1959 if (!profile_) 1960 if (!profile_)
1960 return; 1961 return;
1961 1962
1962 HistoryService* history = 1963 HistoryService* history =
1963 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 1964 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
1964 if (!history) 1965 if (!history)
1965 return; 1966 return;
1966 1967
1967 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()), 1968 GURL url(URLFixerUpper::FixupURL(base::UTF16ToUTF8(t_url.keyword()),
1968 std::string())); 1969 std::string()));
1969 if (!url.is_valid()) 1970 if (!url.is_valid())
1970 return; 1971 return;
1971 1972
1972 // Synthesize a visit for the keyword. This ensures the url for the keyword is 1973 // Synthesize a visit for the keyword. This ensures the url for the keyword is
1973 // autocompleted even if the user doesn't type the url in directly. 1974 // autocompleted even if the user doesn't type the url in directly.
1974 history->AddPage(url, base::Time::Now(), NULL, 0, GURL(), 1975 history->AddPage(url, base::Time::Now(), NULL, 0, GURL(),
1975 history::RedirectList(), 1976 history::RedirectList(),
1976 content::PAGE_TRANSITION_KEYWORD_GENERATED, 1977 content::PAGE_TRANSITION_KEYWORD_GENERATED,
1977 history::SOURCE_BROWSED, false); 1978 history::SOURCE_BROWSED, false);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 if (!GetTemplateURLForKeyword(keyword_candidate)) 2378 if (!GetTemplateURLForKeyword(keyword_candidate))
2378 return keyword_candidate; 2379 return keyword_candidate;
2379 } 2380 }
2380 } 2381 }
2381 2382
2382 // We try to uniquify the keyword by appending a special character to the end. 2383 // We try to uniquify the keyword by appending a special character to the end.
2383 // This is a best-effort approach where we try to preserve the original 2384 // This is a best-effort approach where we try to preserve the original
2384 // keyword and let the user do what they will after our attempt. 2385 // keyword and let the user do what they will after our attempt.
2385 base::string16 keyword_candidate(turl.keyword()); 2386 base::string16 keyword_candidate(turl.keyword());
2386 do { 2387 do {
2387 keyword_candidate.append(ASCIIToUTF16("_")); 2388 keyword_candidate.append(base::ASCIIToUTF16("_"));
2388 } while (GetTemplateURLForKeyword(keyword_candidate)); 2389 } while (GetTemplateURLForKeyword(keyword_candidate));
2389 2390
2390 return keyword_candidate; 2391 return keyword_candidate;
2391 } 2392 }
2392 2393
2393 bool TemplateURLService::IsLocalTemplateURLBetter( 2394 bool TemplateURLService::IsLocalTemplateURLBetter(
2394 const TemplateURL* local_turl, 2395 const TemplateURL* local_turl,
2395 const TemplateURL* sync_turl) { 2396 const TemplateURL* sync_turl) {
2396 DCHECK(GetTemplateURLForGUID(local_turl->sync_guid())); 2397 DCHECK(GetTemplateURLForGUID(local_turl->sync_guid()));
2397 return local_turl->last_modified() > sync_turl->last_modified() || 2398 return local_turl->last_modified() > sync_turl->last_modified() ||
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 "Search.DefaultSearchProvider", 2678 "Search.DefaultSearchProvider",
2678 default_search_provider_->prepopulate_id(), 2679 default_search_provider_->prepopulate_id(),
2679 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); 2680 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID);
2680 } 2681 }
2681 } 2682 }
2682 } 2683 }
2683 2684
2684 TemplateURL* TemplateURLService::CreateTemplateURLForExtension( 2685 TemplateURL* TemplateURLService::CreateTemplateURLForExtension(
2685 const ExtensionKeyword& extension_keyword) const { 2686 const ExtensionKeyword& extension_keyword) const {
2686 TemplateURLData data; 2687 TemplateURLData data;
2687 data.short_name = UTF8ToUTF16(extension_keyword.extension_name); 2688 data.short_name = base::UTF8ToUTF16(extension_keyword.extension_name);
2688 data.SetKeyword(UTF8ToUTF16(extension_keyword.extension_keyword)); 2689 data.SetKeyword(base::UTF8ToUTF16(extension_keyword.extension_keyword));
2689 // This URL is not actually used for navigation. It holds the extension's 2690 // This URL is not actually used for navigation. It holds the extension's
2690 // ID, as well as forcing the TemplateURL to be treated as a search keyword. 2691 // ID, as well as forcing the TemplateURL to be treated as a search keyword.
2691 data.SetURL(std::string(extensions::kExtensionScheme) + "://" + 2692 data.SetURL(std::string(extensions::kExtensionScheme) + "://" +
2692 extension_keyword.extension_id + "/?q={searchTerms}"); 2693 extension_keyword.extension_id + "/?q={searchTerms}");
2693 return new TemplateURL(profile_, data); 2694 return new TemplateURL(profile_, data);
2694 } 2695 }
2695 2696
2696 TemplateURL* TemplateURLService::FindTemplateURLForExtension( 2697 TemplateURL* TemplateURLService::FindTemplateURLForExtension(
2697 const std::string& extension_id, 2698 const std::string& extension_id,
2698 TemplateURL::Type type) const { 2699 TemplateURL::Type type) const {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 new_dse = *i; 2739 new_dse = *i;
2739 break; 2740 break;
2740 } 2741 }
2741 } 2742 }
2742 } 2743 }
2743 } 2744 }
2744 if (!new_dse) 2745 if (!new_dse)
2745 new_dse = FindNewDefaultSearchProvider(); 2746 new_dse = FindNewDefaultSearchProvider();
2746 SetDefaultSearchProviderNoNotify(new_dse); 2747 SetDefaultSearchProviderNoNotify(new_dse);
2747 } 2748 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698