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

Side by Side Diff: chrome/browser/extensions/api/autofill_private/autofill_private_event_router.cc

Issue 1201063002: Set up the infrastructure for Extension event metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaaaaase Created 5 years, 5 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
OLDNEW
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 <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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void AutofillPrivateEventRouter::OnPersonalDataChanged() { 78 void AutofillPrivateEventRouter::OnPersonalDataChanged() {
79 DCHECK(personal_data_ && personal_data_->IsDataLoaded()); 79 DCHECK(personal_data_ && personal_data_->IsDataLoaded());
80 80
81 scoped_ptr<AddressEntryList> addressList = 81 scoped_ptr<AddressEntryList> addressList =
82 extensions::autofill_util::GenerateAddressList(*personal_data_); 82 extensions::autofill_util::GenerateAddressList(*personal_data_);
83 scoped_ptr<base::ListValue> args( 83 scoped_ptr<base::ListValue> args(
84 api::autofill_private::OnAddressListChanged::Create(*addressList) 84 api::autofill_private::OnAddressListChanged::Create(*addressList)
85 .release()); 85 .release());
86 scoped_ptr<Event> extension_event(new Event( 86 scoped_ptr<Event> extension_event(new Event(
87 api::autofill_private::OnAddressListChanged::kEventName, args.Pass())); 87 events::UNKNOWN, api::autofill_private::OnAddressListChanged::kEventName,
88 args.Pass()));
88 event_router_->BroadcastEvent(extension_event.Pass()); 89 event_router_->BroadcastEvent(extension_event.Pass());
89 90
90 scoped_ptr<CreditCardEntryList> creditCardList = 91 scoped_ptr<CreditCardEntryList> creditCardList =
91 extensions::autofill_util::GenerateCreditCardList(*personal_data_); 92 extensions::autofill_util::GenerateCreditCardList(*personal_data_);
92 args.reset( 93 args.reset(
93 api::autofill_private::OnCreditCardListChanged::Create(*creditCardList) 94 api::autofill_private::OnCreditCardListChanged::Create(*creditCardList)
94 .release()); 95 .release());
95 extension_event.reset(new Event( 96 extension_event.reset(new Event(
97 events::UNKNOWN,
96 api::autofill_private::OnCreditCardListChanged::kEventName, args.Pass())); 98 api::autofill_private::OnCreditCardListChanged::kEventName, args.Pass()));
97 event_router_->BroadcastEvent(extension_event.Pass()); 99 event_router_->BroadcastEvent(extension_event.Pass());
98 } 100 }
99 101
100 void AutofillPrivateEventRouter::StartOrStopListeningForChanges() { 102 void AutofillPrivateEventRouter::StartOrStopListeningForChanges() {
101 if (!personal_data_ || !personal_data_->IsDataLoaded()) 103 if (!personal_data_ || !personal_data_->IsDataLoaded())
102 return; 104 return;
103 105
104 bool should_listen_for_address_changes = event_router_->HasEventListener( 106 bool should_listen_for_address_changes = event_router_->HasEventListener(
105 api::autofill_private::OnAddressListChanged::kEventName); 107 api::autofill_private::OnAddressListChanged::kEventName);
106 bool should_listen_for_credit_card_changes = event_router_->HasEventListener( 108 bool should_listen_for_credit_card_changes = event_router_->HasEventListener(
107 api::autofill_private::OnCreditCardListChanged::kEventName); 109 api::autofill_private::OnCreditCardListChanged::kEventName);
108 bool should_listen = should_listen_for_address_changes || 110 bool should_listen = should_listen_for_address_changes ||
109 should_listen_for_credit_card_changes; 111 should_listen_for_credit_card_changes;
110 112
111 if (should_listen && !listening_) 113 if (should_listen && !listening_)
112 personal_data_->AddObserver(this); 114 personal_data_->AddObserver(this);
113 else if (!should_listen && listening_) 115 else if (!should_listen && listening_)
114 personal_data_->RemoveObserver(this); 116 personal_data_->RemoveObserver(this);
115 117
116 listening_ = should_listen; 118 listening_ = should_listen;
117 } 119 }
118 120
119 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create( 121 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create(
120 content::BrowserContext* context) { 122 content::BrowserContext* context) {
121 return new AutofillPrivateEventRouter(context); 123 return new AutofillPrivateEventRouter(context);
122 } 124 }
123 125
124 } // namespace extensions 126 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698