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

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

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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/keyword_table.h" 5 #include "components/search_engines/keyword_table.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 bool delete_entry = turl.GetType() == TemplateURL::OMNIBOX_API_EXTENSION; 448 bool delete_entry = turl.GetType() == TemplateURL::OMNIBOX_API_EXTENSION;
449 if (!delete_entry && generate_keyword) { 449 if (!delete_entry && generate_keyword) {
450 // Explicitly generate keywords for all rows with the autogenerate bit set 450 // Explicitly generate keywords for all rows with the autogenerate bit set
451 // or where the keyword is empty. 451 // or where the keyword is empty.
452 SearchTermsData terms_data; 452 SearchTermsData terms_data;
453 GURL url(turl.GenerateSearchURL(terms_data)); 453 GURL url(turl.GenerateSearchURL(terms_data));
454 if (!url.is_valid()) { 454 if (!url.is_valid()) {
455 delete_entry = true; 455 delete_entry = true;
456 } else { 456 } else {
457 // Ensure autogenerated keywords are unique. 457 // Ensure autogenerated keywords are unique.
458 keyword = TemplateURL::GenerateKeyword( 458 keyword = TemplateURL::GenerateKeyword(url);
459 url, terms_data.GetAcceptLanguages());
460 while (keywords.count(keyword)) 459 while (keywords.count(keyword))
461 keyword.append(base::ASCIIToUTF16("_")); 460 keyword.append(base::ASCIIToUTF16("_"));
462 sql::Statement u(db_->GetUniqueStatement( 461 sql::Statement u(db_->GetUniqueStatement(
463 "UPDATE keywords_temp SET keyword=? WHERE id=?")); 462 "UPDATE keywords_temp SET keyword=? WHERE id=?"));
464 u.BindString16(0, keyword); 463 u.BindString16(0, keyword);
465 u.BindInt64(1, s.ColumnInt64(0)); 464 u.BindInt64(1, s.ColumnInt64(0));
466 if (!u.Run()) 465 if (!u.Run())
467 return false; 466 return false;
468 } 467 }
469 } 468 }
470 if (delete_entry) { 469 if (delete_entry) {
471 sql::Statement u(db_->GetUniqueStatement( 470 sql::Statement u(db_->GetUniqueStatement(
472 "DELETE FROM keywords_temp WHERE id=?")); 471 "DELETE FROM keywords_temp WHERE id=?"));
473 u.BindInt64(0, s.ColumnInt64(0)); 472 u.BindInt64(0, s.ColumnInt64(0));
474 if (!u.Run()) 473 if (!u.Run())
475 return false; 474 return false;
476 } else { 475 } else {
477 keywords.insert(keyword); 476 keywords.insert(keyword);
478 } 477 }
479 } 478 }
480 479
481 // Replace the old table with the new one. 480 // Replace the old table with the new one.
482 sql = "DROP TABLE " + name; 481 sql = "DROP TABLE " + name;
483 if (!db_->Execute(sql.c_str())) 482 if (!db_->Execute(sql.c_str()))
484 return false; 483 return false;
485 sql = "ALTER TABLE keywords_temp RENAME TO " + name; 484 sql = "ALTER TABLE keywords_temp RENAME TO " + name;
486 return db_->Execute(sql.c_str()); 485 return db_->Execute(sql.c_str());
487 } 486 }
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_ui_utils_unittest.cc ('k') | components/search_engines/search_terms_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698