| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/autofill_private/autofill_private_event_
router.h" | 5 #include "chrome/browser/extensions/api/autofill_private/autofill_private_event_
router.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 AutofillPrivateEventRouter::~AutofillPrivateEventRouter() { | 45 AutofillPrivateEventRouter::~AutofillPrivateEventRouter() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AutofillPrivateEventRouter::Shutdown() { | 48 void AutofillPrivateEventRouter::Shutdown() { |
| 49 if (personal_data_) | 49 if (personal_data_) |
| 50 personal_data_->RemoveObserver(this); | 50 personal_data_->RemoveObserver(this); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void AutofillPrivateEventRouter::OnPersonalDataChanged() { | 53 void AutofillPrivateEventRouter::OnPersonalDataChanged() { |
| 54 DCHECK(personal_data_ && personal_data_->IsDataLoaded()); | 54 // Ignore any updates before data is loaded. This can happen in tests. |
| 55 if (!(personal_data_ && personal_data_->IsDataLoaded())) |
| 56 return; |
| 55 | 57 |
| 56 autofill_util::AddressEntryList addressList = | 58 autofill_util::AddressEntryList addressList = |
| 57 extensions::autofill_util::GenerateAddressList(*personal_data_); | 59 extensions::autofill_util::GenerateAddressList(*personal_data_); |
| 58 std::unique_ptr<base::ListValue> args( | 60 std::unique_ptr<base::ListValue> args( |
| 59 api::autofill_private::OnAddressListChanged::Create(addressList) | 61 api::autofill_private::OnAddressListChanged::Create(addressList) |
| 60 .release()); | 62 .release()); |
| 61 std::unique_ptr<Event> extension_event( | 63 std::unique_ptr<Event> extension_event( |
| 62 new Event(events::AUTOFILL_PRIVATE_ON_ADDRESS_LIST_CHANGED, | 64 new Event(events::AUTOFILL_PRIVATE_ON_ADDRESS_LIST_CHANGED, |
| 63 api::autofill_private::OnAddressListChanged::kEventName, | 65 api::autofill_private::OnAddressListChanged::kEventName, |
| 64 std::move(args))); | 66 std::move(args))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 std::move(args))); | 77 std::move(args))); |
| 76 event_router_->BroadcastEvent(std::move(extension_event)); | 78 event_router_->BroadcastEvent(std::move(extension_event)); |
| 77 } | 79 } |
| 78 | 80 |
| 79 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create( | 81 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create( |
| 80 content::BrowserContext* context) { | 82 content::BrowserContext* context) { |
| 81 return new AutofillPrivateEventRouter(context); | 83 return new AutofillPrivateEventRouter(context); |
| 82 } | 84 } |
| 83 | 85 |
| 84 } // namespace extensions | 86 } // namespace extensions |
| OLD | NEW |