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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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 <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/autofill/personal_data_manager_factory.h" 13 #include "chrome/browser/autofill/personal_data_manager_factory.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/api/autofill_private/autofill_util.h" 15 #include "chrome/browser/extensions/api/autofill_private/autofill_util.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 77 }
77 78
78 void AutofillPrivateEventRouter::OnPersonalDataChanged() { 79 void AutofillPrivateEventRouter::OnPersonalDataChanged() {
79 DCHECK(personal_data_ && personal_data_->IsDataLoaded()); 80 DCHECK(personal_data_ && personal_data_->IsDataLoaded());
80 81
81 scoped_ptr<AddressEntryList> addressList = 82 scoped_ptr<AddressEntryList> addressList =
82 extensions::autofill_util::GenerateAddressList(*personal_data_); 83 extensions::autofill_util::GenerateAddressList(*personal_data_);
83 scoped_ptr<base::ListValue> args( 84 scoped_ptr<base::ListValue> args(
84 api::autofill_private::OnAddressListChanged::Create(*addressList) 85 api::autofill_private::OnAddressListChanged::Create(*addressList)
85 .release()); 86 .release());
86 scoped_ptr<Event> extension_event(new Event( 87 scoped_ptr<Event> extension_event(
87 events::AUTOFILL_PRIVATE_ON_ADDRESS_LIST_CHANGED, 88 new Event(events::AUTOFILL_PRIVATE_ON_ADDRESS_LIST_CHANGED,
88 api::autofill_private::OnAddressListChanged::kEventName, args.Pass())); 89 api::autofill_private::OnAddressListChanged::kEventName,
89 event_router_->BroadcastEvent(extension_event.Pass()); 90 std::move(args)));
91 event_router_->BroadcastEvent(std::move(extension_event));
90 92
91 scoped_ptr<CreditCardEntryList> creditCardList = 93 scoped_ptr<CreditCardEntryList> creditCardList =
92 extensions::autofill_util::GenerateCreditCardList(*personal_data_); 94 extensions::autofill_util::GenerateCreditCardList(*personal_data_);
93 args.reset( 95 args.reset(
94 api::autofill_private::OnCreditCardListChanged::Create(*creditCardList) 96 api::autofill_private::OnCreditCardListChanged::Create(*creditCardList)
95 .release()); 97 .release());
96 extension_event.reset(new Event( 98 extension_event.reset(
97 events::AUTOFILL_PRIVATE_ON_CREDIT_CARD_LIST_CHANGED, 99 new Event(events::AUTOFILL_PRIVATE_ON_CREDIT_CARD_LIST_CHANGED,
98 api::autofill_private::OnCreditCardListChanged::kEventName, args.Pass())); 100 api::autofill_private::OnCreditCardListChanged::kEventName,
99 event_router_->BroadcastEvent(extension_event.Pass()); 101 std::move(args)));
102 event_router_->BroadcastEvent(std::move(extension_event));
100 } 103 }
101 104
102 void AutofillPrivateEventRouter::StartOrStopListeningForChanges() { 105 void AutofillPrivateEventRouter::StartOrStopListeningForChanges() {
103 if (!personal_data_ || !personal_data_->IsDataLoaded()) 106 if (!personal_data_ || !personal_data_->IsDataLoaded())
104 return; 107 return;
105 108
106 bool should_listen_for_address_changes = event_router_->HasEventListener( 109 bool should_listen_for_address_changes = event_router_->HasEventListener(
107 api::autofill_private::OnAddressListChanged::kEventName); 110 api::autofill_private::OnAddressListChanged::kEventName);
108 bool should_listen_for_credit_card_changes = event_router_->HasEventListener( 111 bool should_listen_for_credit_card_changes = event_router_->HasEventListener(
109 api::autofill_private::OnCreditCardListChanged::kEventName); 112 api::autofill_private::OnCreditCardListChanged::kEventName);
110 bool should_listen = should_listen_for_address_changes || 113 bool should_listen = should_listen_for_address_changes ||
111 should_listen_for_credit_card_changes; 114 should_listen_for_credit_card_changes;
112 115
113 if (should_listen && !listening_) 116 if (should_listen && !listening_)
114 personal_data_->AddObserver(this); 117 personal_data_->AddObserver(this);
115 else if (!should_listen && listening_) 118 else if (!should_listen && listening_)
116 personal_data_->RemoveObserver(this); 119 personal_data_->RemoveObserver(this);
117 120
118 listening_ = should_listen; 121 listening_ = should_listen;
119 } 122 }
120 123
121 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create( 124 AutofillPrivateEventRouter* AutofillPrivateEventRouter::Create(
122 content::BrowserContext* context) { 125 content::BrowserContext* context) {
123 return new AutofillPrivateEventRouter(context); 126 return new AutofillPrivateEventRouter(context);
124 } 127 }
125 128
126 } // namespace extensions 129 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698