OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/autofill_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 void AutofillOptionsHandler::InitializePage() { | 327 void AutofillOptionsHandler::InitializePage() { |
328 if (personal_data_) | 328 if (personal_data_) |
329 LoadAutofillData(); | 329 LoadAutofillData(); |
330 } | 330 } |
331 | 331 |
332 void AutofillOptionsHandler::RegisterMessages() { | 332 void AutofillOptionsHandler::RegisterMessages() { |
333 personal_data_ = autofill::PersonalDataManagerFactory::GetForProfile( | 333 personal_data_ = autofill::PersonalDataManagerFactory::GetForProfile( |
334 Profile::FromWebUI(web_ui())); | 334 Profile::FromWebUI(web_ui())); |
335 | 335 |
| 336 #if defined(OS_MACOSX) |
| 337 web_ui()->RegisterMessageCallback( |
| 338 "accessAddressBook", |
| 339 base::Bind(&AutofillOptionsHandler::AccessAddressBook, |
| 340 base::Unretained(this))); |
| 341 #endif |
336 web_ui()->RegisterMessageCallback( | 342 web_ui()->RegisterMessageCallback( |
337 "removeData", | 343 "removeData", |
338 base::Bind(&AutofillOptionsHandler::RemoveData, | 344 base::Bind(&AutofillOptionsHandler::RemoveData, |
339 base::Unretained(this))); | 345 base::Unretained(this))); |
340 web_ui()->RegisterMessageCallback( | 346 web_ui()->RegisterMessageCallback( |
341 "loadAddressEditor", | 347 "loadAddressEditor", |
342 base::Bind(&AutofillOptionsHandler::LoadAddressEditor, | 348 base::Bind(&AutofillOptionsHandler::LoadAddressEditor, |
343 base::Unretained(this))); | 349 base::Unretained(this))); |
344 web_ui()->RegisterMessageCallback( | 350 web_ui()->RegisterMessageCallback( |
345 "loadAddressEditorComponents", | 351 "loadAddressEditorComponents", |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 webui::GetBitmapDataUrlFromResource( | 436 webui::GetBitmapDataUrlFromResource( |
431 CreditCard::IconResourceId(card->type())))); | 437 CreditCard::IconResourceId(card->type())))); |
432 entry->Append(new base::StringValue(card->TypeForDisplay())); | 438 entry->Append(new base::StringValue(card->TypeForDisplay())); |
433 credit_cards.Append(entry); | 439 credit_cards.Append(entry); |
434 } | 440 } |
435 | 441 |
436 web_ui()->CallJavascriptFunction("AutofillOptions.setCreditCardList", | 442 web_ui()->CallJavascriptFunction("AutofillOptions.setCreditCardList", |
437 credit_cards); | 443 credit_cards); |
438 } | 444 } |
439 | 445 |
| 446 #if defined(OS_MACOSX) |
| 447 void AutofillOptionsHandler::AccessAddressBook(const base::ListValue* args) { |
| 448 personal_data_->AccessAddressBook(); |
| 449 } |
| 450 #endif |
| 451 |
440 void AutofillOptionsHandler::RemoveData(const base::ListValue* args) { | 452 void AutofillOptionsHandler::RemoveData(const base::ListValue* args) { |
441 DCHECK(IsPersonalDataLoaded()); | 453 DCHECK(IsPersonalDataLoaded()); |
442 | 454 |
443 std::string guid; | 455 std::string guid; |
444 if (!args->GetString(0, &guid)) { | 456 if (!args->GetString(0, &guid)) { |
445 NOTREACHED(); | 457 NOTREACHED(); |
446 return; | 458 return; |
447 } | 459 } |
448 | 460 |
449 personal_data_->RemoveByGUID(guid); | 461 personal_data_->RemoveByGUID(guid); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 | 675 |
664 web_ui()->CallJavascriptFunction( | 676 web_ui()->CallJavascriptFunction( |
665 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); | 677 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); |
666 } | 678 } |
667 | 679 |
668 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { | 680 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { |
669 return personal_data_ && personal_data_->IsDataLoaded(); | 681 return personal_data_ && personal_data_->IsDataLoaded(); |
670 } | 682 } |
671 | 683 |
672 } // namespace options | 684 } // namespace options |
OLD | NEW |