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

Side by Side Diff: chrome/browser/webdata/web_database.cc

Issue 6633001: Convert autofill messages to use the new IPC macros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webdata/web_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 // track this. Add up to |kMaximumUniqueNames| unique entries per form. 1394 // track this. Add up to |kMaximumUniqueNames| unique entries per form.
1395 const size_t kMaximumUniqueNames = 256; 1395 const size_t kMaximumUniqueNames = 256;
1396 std::set<string16> seen_names; 1396 std::set<string16> seen_names;
1397 bool result = true; 1397 bool result = true;
1398 for (std::vector<FormField>::const_iterator 1398 for (std::vector<FormField>::const_iterator
1399 itr = elements.begin(); 1399 itr = elements.begin();
1400 itr != elements.end(); 1400 itr != elements.end();
1401 itr++) { 1401 itr++) {
1402 if (seen_names.size() >= kMaximumUniqueNames) 1402 if (seen_names.size() >= kMaximumUniqueNames)
1403 break; 1403 break;
1404 if (seen_names.find(itr->name()) != seen_names.end()) 1404 if (seen_names.find(itr->name) != seen_names.end())
1405 continue; 1405 continue;
1406 result = result && AddFormFieldValueTime(*itr, changes, time); 1406 result = result && AddFormFieldValueTime(*itr, changes, time);
1407 seen_names.insert(itr->name()); 1407 seen_names.insert(itr->name);
1408 } 1408 }
1409 return result; 1409 return result;
1410 } 1410 }
1411 1411
1412 bool WebDatabase::ClearAutofillEmptyValueElements() { 1412 bool WebDatabase::ClearAutofillEmptyValueElements() {
1413 sql::Statement s(db_.GetUniqueStatement( 1413 sql::Statement s(db_.GetUniqueStatement(
1414 "SELECT pair_id FROM autofill WHERE TRIM(value)= \"\"")); 1414 "SELECT pair_id FROM autofill WHERE TRIM(value)= \"\""));
1415 if (!s) { 1415 if (!s) {
1416 NOTREACHED() << "Statement prepare failed"; 1416 NOTREACHED() << "Statement prepare failed";
1417 return false; 1417 return false;
(...skipping 18 matching lines...) Expand all
1436 int64* pair_id, 1436 int64* pair_id,
1437 int* count) { 1437 int* count) {
1438 sql::Statement s(db_.GetUniqueStatement( 1438 sql::Statement s(db_.GetUniqueStatement(
1439 "SELECT pair_id, count FROM autofill " 1439 "SELECT pair_id, count FROM autofill "
1440 "WHERE name = ? AND value = ?")); 1440 "WHERE name = ? AND value = ?"));
1441 if (!s) { 1441 if (!s) {
1442 NOTREACHED() << "Statement prepare failed"; 1442 NOTREACHED() << "Statement prepare failed";
1443 return false; 1443 return false;
1444 } 1444 }
1445 1445
1446 s.BindString16(0, element.name()); 1446 s.BindString16(0, element.name);
1447 s.BindString16(1, element.value()); 1447 s.BindString16(1, element.value);
1448 1448
1449 *pair_id = 0; 1449 *pair_id = 0;
1450 *count = 0; 1450 *count = 0;
1451 1451
1452 if (s.Step()) { 1452 if (s.Step()) {
1453 *pair_id = s.ColumnInt64(0); 1453 *pair_id = s.ColumnInt64(0);
1454 *count = s.ColumnInt(1); 1454 *count = s.ColumnInt(1);
1455 } 1455 }
1456 1456
1457 return true; 1457 return true;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 1615
1616 bool WebDatabase::InsertFormElement(const FormField& element, 1616 bool WebDatabase::InsertFormElement(const FormField& element,
1617 int64* pair_id) { 1617 int64* pair_id) {
1618 sql::Statement s(db_.GetUniqueStatement( 1618 sql::Statement s(db_.GetUniqueStatement(
1619 "INSERT INTO autofill (name, value, value_lower) VALUES (?,?,?)")); 1619 "INSERT INTO autofill (name, value, value_lower) VALUES (?,?,?)"));
1620 if (!s) { 1620 if (!s) {
1621 NOTREACHED() << "Statement prepare failed"; 1621 NOTREACHED() << "Statement prepare failed";
1622 return false; 1622 return false;
1623 } 1623 }
1624 1624
1625 s.BindString16(0, element.name()); 1625 s.BindString16(0, element.name);
1626 s.BindString16(1, element.value()); 1626 s.BindString16(1, element.value);
1627 s.BindString16(2, l10n_util::ToLower(element.value())); 1627 s.BindString16(2, l10n_util::ToLower(element.value));
1628 1628
1629 if (!s.Run()) { 1629 if (!s.Run()) {
1630 NOTREACHED(); 1630 NOTREACHED();
1631 return false; 1631 return false;
1632 } 1632 }
1633 1633
1634 *pair_id = db_.GetLastInsertRowId(); 1634 *pair_id = db_.GetLastInsertRowId();
1635 return true; 1635 return true;
1636 } 1636 }
1637 1637
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 if (!SetCountOfFormElement(pair_id, count + 1)) 1694 if (!SetCountOfFormElement(pair_id, count + 1))
1695 return false; 1695 return false;
1696 1696
1697 if (!InsertPairIDAndDate(pair_id, time)) 1697 if (!InsertPairIDAndDate(pair_id, time))
1698 return false; 1698 return false;
1699 1699
1700 AutofillChange::Type change_type = 1700 AutofillChange::Type change_type =
1701 count == 0 ? AutofillChange::ADD : AutofillChange::UPDATE; 1701 count == 0 ? AutofillChange::ADD : AutofillChange::UPDATE;
1702 changes->push_back( 1702 changes->push_back(
1703 AutofillChange(change_type, 1703 AutofillChange(change_type,
1704 AutofillKey(element.name(), element.value()))); 1704 AutofillKey(element.name, element.value)));
1705 return true; 1705 return true;
1706 } 1706 }
1707 1707
1708 bool WebDatabase::GetFormValuesForElementName(const string16& name, 1708 bool WebDatabase::GetFormValuesForElementName(const string16& name,
1709 const string16& prefix, 1709 const string16& prefix,
1710 std::vector<string16>* values, 1710 std::vector<string16>* values,
1711 int limit) { 1711 int limit) {
1712 DCHECK(values); 1712 DCHECK(values);
1713 sql::Statement s; 1713 sql::Statement s;
1714 1714
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 3094
3095 // Add successive versions here. Each should set the version number and 3095 // Add successive versions here. Each should set the version number and
3096 // compatible version number as appropriate, then fall through to the next 3096 // compatible version number as appropriate, then fall through to the next
3097 // case. 3097 // case.
3098 3098
3099 case kCurrentVersionNumber: 3099 case kCurrentVersionNumber:
3100 // No migration needed. 3100 // No migration needed.
3101 return sql::INIT_OK; 3101 return sql::INIT_OK;
3102 } 3102 }
3103 } 3103 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698