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/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 <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 base::string16 keyword(s.ColumnString16(1)); | 439 base::string16 keyword(s.ColumnString16(1)); |
440 bool generate_keyword = keyword.empty() || s.ColumnBool(3); | 440 bool generate_keyword = keyword.empty() || s.ColumnBool(3); |
441 if (generate_keyword) | 441 if (generate_keyword) |
442 keyword = placeholder_keyword; | 442 keyword = placeholder_keyword; |
443 TemplateURLData data; | 443 TemplateURLData data; |
444 data.SetKeyword(keyword); | 444 data.SetKeyword(keyword); |
445 data.SetURL(s.ColumnString(2)); | 445 data.SetURL(s.ColumnString(2)); |
446 TemplateURL turl(data); | 446 TemplateURL turl(data); |
447 // Don't persist extension keywords to disk. These will get added to the | 447 // Don't persist extension keywords to disk. These will get added to the |
448 // TemplateURLService as the extensions are loaded. | 448 // TemplateURLService as the extensions are loaded. |
449 bool delete_entry = turl.GetType() == TemplateURL::OMNIBOX_API_EXTENSION; | 449 bool delete_entry = turl.type() == TemplateURL::OMNIBOX_API_EXTENSION; |
450 if (!delete_entry && generate_keyword) { | 450 if (!delete_entry && generate_keyword) { |
451 // Explicitly generate keywords for all rows with the autogenerate bit set | 451 // Explicitly generate keywords for all rows with the autogenerate bit set |
452 // or where the keyword is empty. | 452 // or where the keyword is empty. |
453 SearchTermsData terms_data; | 453 SearchTermsData terms_data; |
454 GURL url(turl.GenerateSearchURL(terms_data)); | 454 GURL url(turl.GenerateSearchURL(terms_data)); |
455 if (!url.is_valid()) { | 455 if (!url.is_valid()) { |
456 delete_entry = true; | 456 delete_entry = true; |
457 } else { | 457 } else { |
458 // Ensure autogenerated keywords are unique. | 458 // Ensure autogenerated keywords are unique. |
459 keyword = TemplateURL::GenerateKeyword(url); | 459 keyword = TemplateURL::GenerateKeyword(url); |
(...skipping 18 matching lines...) Expand all Loading... |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 // Replace the old table with the new one. | 481 // Replace the old table with the new one. |
482 sql = "DROP TABLE " + name; | 482 sql = "DROP TABLE " + name; |
483 if (!db_->Execute(sql.c_str())) | 483 if (!db_->Execute(sql.c_str())) |
484 return false; | 484 return false; |
485 sql = "ALTER TABLE keywords_temp RENAME TO " + name; | 485 sql = "ALTER TABLE keywords_temp RENAME TO " + name; |
486 return db_->Execute(sql.c_str()); | 486 return db_->Execute(sql.c_str()); |
487 } | 487 } |
OLD | NEW |