diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 03:24:55 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 03:24:55 +0000 |
commit | d3d728e9b36811fb77d8176297d607c84e6a2d18 (patch) | |
tree | 200690d244f5ab82d30283dd0ec16052225d3281 /chrome/browser/guid.cc | |
parent | e3322f4b2588371b962b0a7da5fbede0ace0cdd8 (diff) | |
download | chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.zip chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.tar.gz chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.tar.bz2 |
This is stage 1 of transition to GUIDs as primary identifier for AutoFill profiles and credit cards.
The transition will look like this in terms of table migration:
Current:
CREATE TABLE autofill_profiles (
label VARCHAR,
unique_id INTEGER PRIMARY KEY,
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR);
Transitional (adds guid column):
CREATE TABLE autofill_profiles (
label VARCHAR,
unique_id INTEGER PRIMARY KEY,
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR,
guid VARCHAR NOT NULL); // <- add guid
End goal (in follow up CL):
CREATE TABLE autofill_profiles (
// remove label
// remove unique_id
guid VARCHAR NOT NULL PRIMARY KEY // <- reorder guid, make primary
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR);
And similarly for the credit_cards table.
BUG=58813
TEST=AutoFillProfileTest.Compare, GUIDTest.GUIDCorrectlyFormatted, WebDataServiceAutofillTest.ProfileRemoveGUID, WebDataServiceAutofillTest.CreditCardRemoveGUID, WebDatabaseTest.AutoFillProfile, WebDatabaseTest.CreditCard, WebDatabaseMigrationTest.MigrateVersion30ToCurrent
Review URL: http://codereview.chromium.org/3760009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/guid.cc')
-rw-r--r-- | chrome/browser/guid.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/guid.cc b/chrome/browser/guid.cc new file mode 100644 index 0000000..b8f46db --- /dev/null +++ b/chrome/browser/guid.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/guid.h" + +#include "base/rand_util.h" +#include "base/stringprintf.h" + +namespace guid { + +bool IsValidGUID(const std::string& guid) { + const size_t kGUIDLength = 36U; + if (guid.length() != kGUIDLength) + return false; + + std::string hexchars = "0123456789ABCDEF"; + for (uint32 i = 0; i < guid.length(); ++i) { + char current = guid[i]; + if (i == 8 || i == 13 || i == 18 || i == 23) { + if (current != '-') + return false; + } else { + if (hexchars.find(current) == std::string::npos) + return false; + } + } + + return true; +} + +} // namespace guid |