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

Side by Side Diff: chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/activity_log_private/activity_log_privat e_api.h" 5 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 void ActivityLogAPI::OnListenerAdded(const EventListenerInfo& details) { 81 void ActivityLogAPI::OnListenerAdded(const EventListenerInfo& details) {
82 // TODO(felt): Only observe activity_log_ events when we have a customer. 82 // TODO(felt): Only observe activity_log_ events when we have a customer.
83 } 83 }
84 84
85 void ActivityLogAPI::OnListenerRemoved(const EventListenerInfo& details) { 85 void ActivityLogAPI::OnListenerRemoved(const EventListenerInfo& details) {
86 // TODO(felt): Only observe activity_log_ events when we have a customer. 86 // TODO(felt): Only observe activity_log_ events when we have a customer.
87 } 87 }
88 88
89 void ActivityLogAPI::OnExtensionActivity(scoped_refptr<Action> activity) { 89 void ActivityLogAPI::OnExtensionActivity(scoped_refptr<Action> activity) {
90 scoped_ptr<base::ListValue> value(new base::ListValue()); 90 std::unique_ptr<base::ListValue> value(new base::ListValue());
91 ExtensionActivity activity_arg = activity->ConvertToExtensionActivity(); 91 ExtensionActivity activity_arg = activity->ConvertToExtensionActivity();
92 value->Append(activity_arg.ToValue()); 92 value->Append(activity_arg.ToValue());
93 scoped_ptr<Event> event(new Event( 93 std::unique_ptr<Event> event(new Event(
94 events::ACTIVITY_LOG_PRIVATE_ON_EXTENSION_ACTIVITY, 94 events::ACTIVITY_LOG_PRIVATE_ON_EXTENSION_ACTIVITY,
95 activity_log_private::OnExtensionActivity::kEventName, std::move(value))); 95 activity_log_private::OnExtensionActivity::kEventName, std::move(value)));
96 event->restrict_to_browser_context = browser_context_; 96 event->restrict_to_browser_context = browser_context_;
97 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); 97 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
98 } 98 }
99 99
100 bool ActivityLogPrivateGetExtensionActivitiesFunction::RunAsync() { 100 bool ActivityLogPrivateGetExtensionActivitiesFunction::RunAsync() {
101 scoped_ptr<activity_log_private::GetExtensionActivities::Params> params( 101 std::unique_ptr<activity_log_private::GetExtensionActivities::Params> params(
102 activity_log_private::GetExtensionActivities::Params::Create(*args_)); 102 activity_log_private::GetExtensionActivities::Params::Create(*args_));
103 EXTENSION_FUNCTION_VALIDATE(params.get()); 103 EXTENSION_FUNCTION_VALIDATE(params.get());
104 104
105 // Get the arguments in the right format. 105 // Get the arguments in the right format.
106 scoped_ptr<Filter> filter; 106 std::unique_ptr<Filter> filter;
107 filter.reset(&params.release()->filter); 107 filter.reset(&params.release()->filter);
108 Action::ActionType action_type = Action::ACTION_API_CALL; 108 Action::ActionType action_type = Action::ACTION_API_CALL;
109 switch (filter->activity_type) { 109 switch (filter->activity_type) {
110 case activity_log_private::EXTENSION_ACTIVITY_FILTER_API_CALL: 110 case activity_log_private::EXTENSION_ACTIVITY_FILTER_API_CALL:
111 action_type = Action::ACTION_API_CALL; 111 action_type = Action::ACTION_API_CALL;
112 break; 112 break;
113 case activity_log_private::EXTENSION_ACTIVITY_FILTER_API_EVENT: 113 case activity_log_private::EXTENSION_ACTIVITY_FILTER_API_EVENT:
114 action_type = Action::ACTION_API_EVENT; 114 action_type = Action::ACTION_API_EVENT;
115 break; 115 break;
116 case activity_log_private::EXTENSION_ACTIVITY_FILTER_CONTENT_SCRIPT: 116 case activity_log_private::EXTENSION_ACTIVITY_FILTER_CONTENT_SCRIPT:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 arg_url, 152 arg_url,
153 days_ago, 153 days_ago,
154 base::Bind( 154 base::Bind(
155 &ActivityLogPrivateGetExtensionActivitiesFunction::OnLookupCompleted, 155 &ActivityLogPrivateGetExtensionActivitiesFunction::OnLookupCompleted,
156 this)); 156 this));
157 157
158 return true; 158 return true;
159 } 159 }
160 160
161 void ActivityLogPrivateGetExtensionActivitiesFunction::OnLookupCompleted( 161 void ActivityLogPrivateGetExtensionActivitiesFunction::OnLookupCompleted(
162 scoped_ptr<std::vector<scoped_refptr<Action> > > activities) { 162 std::unique_ptr<std::vector<scoped_refptr<Action>>> activities) {
163 // Convert Actions to ExtensionActivities. 163 // Convert Actions to ExtensionActivities.
164 std::vector<ExtensionActivity> result_arr; 164 std::vector<ExtensionActivity> result_arr;
165 for (const auto& activity : *activities) 165 for (const auto& activity : *activities)
166 result_arr.push_back(activity->ConvertToExtensionActivity()); 166 result_arr.push_back(activity->ConvertToExtensionActivity());
167 167
168 // Populate the return object. 168 // Populate the return object.
169 scoped_ptr<ActivityResultSet> result_set(new ActivityResultSet); 169 std::unique_ptr<ActivityResultSet> result_set(new ActivityResultSet);
170 result_set->activities = std::move(result_arr); 170 result_set->activities = std::move(result_arr);
171 results_ = activity_log_private::GetExtensionActivities::Results::Create( 171 results_ = activity_log_private::GetExtensionActivities::Results::Create(
172 *result_set); 172 *result_set);
173 173
174 SendResponse(true); 174 SendResponse(true);
175 } 175 }
176 176
177 bool ActivityLogPrivateDeleteActivitiesFunction::RunAsync() { 177 bool ActivityLogPrivateDeleteActivitiesFunction::RunAsync() {
178 scoped_ptr<activity_log_private::DeleteActivities::Params> params( 178 std::unique_ptr<activity_log_private::DeleteActivities::Params> params(
179 activity_log_private::DeleteActivities::Params::Create(*args_)); 179 activity_log_private::DeleteActivities::Params::Create(*args_));
180 EXTENSION_FUNCTION_VALIDATE(params.get()); 180 EXTENSION_FUNCTION_VALIDATE(params.get());
181 181
182 // Put the arguments in the right format. 182 // Put the arguments in the right format.
183 std::vector<int64_t> action_ids; 183 std::vector<int64_t> action_ids;
184 int64_t value; 184 int64_t value;
185 for (size_t i = 0; i < params->activity_ids.size(); i++) { 185 for (size_t i = 0; i < params->activity_ids.size(); i++) {
186 if (base::StringToInt64(params->activity_ids[i], &value)) 186 if (base::StringToInt64(params->activity_ids[i], &value))
187 action_ids.push_back(value); 187 action_ids.push_back(value);
188 } 188 }
189 189
190 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); 190 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile());
191 DCHECK(activity_log); 191 DCHECK(activity_log);
192 activity_log->RemoveActions(action_ids); 192 activity_log->RemoveActions(action_ids);
193 return true; 193 return true;
194 } 194 }
195 195
196 bool ActivityLogPrivateDeleteDatabaseFunction::RunAsync() { 196 bool ActivityLogPrivateDeleteDatabaseFunction::RunAsync() {
197 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); 197 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile());
198 DCHECK(activity_log); 198 DCHECK(activity_log);
199 activity_log->DeleteDatabase(); 199 activity_log->DeleteDatabase();
200 return true; 200 return true;
201 } 201 }
202 202
203 bool ActivityLogPrivateDeleteUrlsFunction::RunAsync() { 203 bool ActivityLogPrivateDeleteUrlsFunction::RunAsync() {
204 scoped_ptr<activity_log_private::DeleteUrls::Params> params( 204 std::unique_ptr<activity_log_private::DeleteUrls::Params> params(
205 activity_log_private::DeleteUrls::Params::Create(*args_)); 205 activity_log_private::DeleteUrls::Params::Create(*args_));
206 EXTENSION_FUNCTION_VALIDATE(params.get()); 206 EXTENSION_FUNCTION_VALIDATE(params.get());
207 207
208 // Put the arguments in the right format. 208 // Put the arguments in the right format.
209 std::vector<GURL> gurls; 209 std::vector<GURL> gurls;
210 std::vector<std::string> urls = *params->urls.get(); 210 std::vector<std::string> urls = *params->urls.get();
211 for (std::vector<std::string>::iterator it = urls.begin(); 211 for (std::vector<std::string>::iterator it = urls.begin();
212 it != urls.end(); 212 it != urls.end();
213 ++it) { 213 ++it) {
214 gurls.push_back(GURL(*it)); 214 gurls.push_back(GURL(*it));
215 } 215 }
216 216
217 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); 217 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile());
218 DCHECK(activity_log); 218 DCHECK(activity_log);
219 activity_log->RemoveURLs(gurls); 219 activity_log->RemoveURLs(gurls);
220 return true; 220 return true;
221 } 221 }
222 222
223 } // namespace extensions 223 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698