OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/autofill_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/autofill_options_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/guid.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/string16.h" | 12 #include "base/string16.h" |
12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/autofill/autofill_profile.h" | 15 #include "chrome/browser/autofill/autofill_profile.h" |
15 #include "chrome/browser/autofill/credit_card.h" | 16 #include "chrome/browser/autofill/credit_card.h" |
16 #include "chrome/browser/guid.h" | |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
19 | 19 |
20 AutoFillOptionsHandler::AutoFillOptionsHandler() | 20 AutoFillOptionsHandler::AutoFillOptionsHandler() |
21 : personal_data_(NULL) { | 21 : personal_data_(NULL) { |
22 } | 22 } |
23 | 23 |
24 AutoFillOptionsHandler::~AutoFillOptionsHandler() { | 24 AutoFillOptionsHandler::~AutoFillOptionsHandler() { |
25 if (personal_data_) | 25 if (personal_data_) |
26 personal_data_->RemoveObserver(this); | 26 personal_data_->RemoveObserver(this); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), value); | 209 profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), value); |
210 if (args->GetString(8, &value)) | 210 if (args->GetString(8, &value)) |
211 profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), value); | 211 profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), value); |
212 if (args->GetString(9, &value)) | 212 if (args->GetString(9, &value)) |
213 profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), value); | 213 profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), value); |
214 if (args->GetString(10, &value)) | 214 if (args->GetString(10, &value)) |
215 profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), value); | 215 profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), value); |
216 if (args->GetString(11, &value)) | 216 if (args->GetString(11, &value)) |
217 profile.SetInfo(AutoFillType(EMAIL_ADDRESS), value); | 217 profile.SetInfo(AutoFillType(EMAIL_ADDRESS), value); |
218 | 218 |
219 if (!guid::IsValidGUID(profile.guid())) { | 219 if (!base::IsValidGUID(profile.guid())) { |
220 profile.set_guid(guid::GenerateGUID()); | 220 profile.set_guid(base::GenerateGUID()); |
221 personal_data_->AddProfile(profile); | 221 personal_data_->AddProfile(profile); |
222 } else { | 222 } else { |
223 personal_data_->UpdateProfile(profile); | 223 personal_data_->UpdateProfile(profile); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void AutoFillOptionsHandler::EditAddress(const ListValue* args) { | 227 void AutoFillOptionsHandler::EditAddress(const ListValue* args) { |
228 if (!personal_data_->IsDataLoaded()) | 228 if (!personal_data_->IsDataLoaded()) |
229 return; | 229 return; |
230 | 230 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 string16 value; | 303 string16 value; |
304 if (args->GetString(1, &value)) | 304 if (args->GetString(1, &value)) |
305 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), value); | 305 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), value); |
306 if (args->GetString(2, &value)) | 306 if (args->GetString(2, &value)) |
307 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), value); | 307 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), value); |
308 if (args->GetString(3, &value)) | 308 if (args->GetString(3, &value)) |
309 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), value); | 309 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), value); |
310 if (args->GetString(4, &value)) | 310 if (args->GetString(4, &value)) |
311 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), value); | 311 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), value); |
312 | 312 |
313 if (!guid::IsValidGUID(credit_card.guid())) { | 313 if (!base::IsValidGUID(credit_card.guid())) { |
314 credit_card.set_guid(guid::GenerateGUID()); | 314 credit_card.set_guid(base::GenerateGUID()); |
315 personal_data_->AddCreditCard(credit_card); | 315 personal_data_->AddCreditCard(credit_card); |
316 } else { | 316 } else { |
317 personal_data_->UpdateCreditCard(credit_card); | 317 personal_data_->UpdateCreditCard(credit_card); |
318 } | 318 } |
319 | 319 |
320 } | 320 } |
321 | 321 |
322 void AutoFillOptionsHandler::EditCreditCard(const ListValue* args) { | 322 void AutoFillOptionsHandler::EditCreditCard(const ListValue* args) { |
323 if (!personal_data_->IsDataLoaded()) | 323 if (!personal_data_->IsDataLoaded()) |
324 return; | 324 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 return; | 364 return; |
365 | 365 |
366 std::string guid; | 366 std::string guid; |
367 if (!args->GetString(0, &guid)) { | 367 if (!args->GetString(0, &guid)) { |
368 NOTREACHED(); | 368 NOTREACHED(); |
369 return; | 369 return; |
370 } | 370 } |
371 | 371 |
372 personal_data_->RemoveCreditCard(guid); | 372 personal_data_->RemoveCreditCard(guid); |
373 } | 373 } |
OLD | NEW |