OLD | NEW |
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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 scoped_ptr<ExtensionActivity> activity_arg = | 88 scoped_ptr<ExtensionActivity> activity_arg = |
89 activity->ConvertToExtensionActivity(); | 89 activity->ConvertToExtensionActivity(); |
90 value->Append(activity_arg->ToValue().release()); | 90 value->Append(activity_arg->ToValue().release()); |
91 scoped_ptr<Event> event( | 91 scoped_ptr<Event> event( |
92 new Event(activity_log_private::OnExtensionActivity::kEventName, | 92 new Event(activity_log_private::OnExtensionActivity::kEventName, |
93 value.Pass())); | 93 value.Pass())); |
94 event->restrict_to_browser_context = browser_context_; | 94 event->restrict_to_browser_context = browser_context_; |
95 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 95 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
96 } | 96 } |
97 | 97 |
98 bool ActivityLogPrivateGetExtensionActivitiesFunction::RunImpl() { | 98 bool ActivityLogPrivateGetExtensionActivitiesFunction::RunAsync() { |
99 scoped_ptr<activity_log_private::GetExtensionActivities::Params> params( | 99 scoped_ptr<activity_log_private::GetExtensionActivities::Params> params( |
100 activity_log_private::GetExtensionActivities::Params::Create(*args_)); | 100 activity_log_private::GetExtensionActivities::Params::Create(*args_)); |
101 EXTENSION_FUNCTION_VALIDATE(params.get()); | 101 EXTENSION_FUNCTION_VALIDATE(params.get()); |
102 | 102 |
103 // Get the arguments in the right format. | 103 // Get the arguments in the right format. |
104 scoped_ptr<Filter> filter; | 104 scoped_ptr<Filter> filter; |
105 filter.reset(¶ms.release()->filter); | 105 filter.reset(¶ms.release()->filter); |
106 Action::ActionType action_type = Action::ACTION_API_CALL; | 106 Action::ActionType action_type = Action::ACTION_API_CALL; |
107 switch (filter->activity_type) { | 107 switch (filter->activity_type) { |
108 case Filter::ACTIVITY_TYPE_API_CALL: | 108 case Filter::ACTIVITY_TYPE_API_CALL: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 // Populate the return object. | 170 // Populate the return object. |
171 scoped_ptr<ActivityResultSet> result_set(new ActivityResultSet); | 171 scoped_ptr<ActivityResultSet> result_set(new ActivityResultSet); |
172 result_set->activities = result_arr; | 172 result_set->activities = result_arr; |
173 results_ = activity_log_private::GetExtensionActivities::Results::Create( | 173 results_ = activity_log_private::GetExtensionActivities::Results::Create( |
174 *result_set); | 174 *result_set); |
175 | 175 |
176 SendResponse(true); | 176 SendResponse(true); |
177 } | 177 } |
178 | 178 |
179 bool ActivityLogPrivateDeleteActivitiesFunction::RunImpl() { | 179 bool ActivityLogPrivateDeleteActivitiesFunction::RunAsync() { |
180 scoped_ptr<activity_log_private::DeleteActivities::Params> params( | 180 scoped_ptr<activity_log_private::DeleteActivities::Params> params( |
181 activity_log_private::DeleteActivities::Params::Create(*args_)); | 181 activity_log_private::DeleteActivities::Params::Create(*args_)); |
182 EXTENSION_FUNCTION_VALIDATE(params.get()); | 182 EXTENSION_FUNCTION_VALIDATE(params.get()); |
183 | 183 |
184 // Put the arguments in the right format. | 184 // Put the arguments in the right format. |
185 std::vector<int64> action_ids; | 185 std::vector<int64> action_ids; |
186 int64 value; | 186 int64 value; |
187 for (size_t i = 0; i < params->activity_ids.size(); i++) { | 187 for (size_t i = 0; i < params->activity_ids.size(); i++) { |
188 if (base::StringToInt64(params->activity_ids[i], &value)) | 188 if (base::StringToInt64(params->activity_ids[i], &value)) |
189 action_ids.push_back(value); | 189 action_ids.push_back(value); |
190 } | 190 } |
191 | 191 |
192 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 192 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
193 DCHECK(activity_log); | 193 DCHECK(activity_log); |
194 activity_log->RemoveActions(action_ids); | 194 activity_log->RemoveActions(action_ids); |
195 return true; | 195 return true; |
196 } | 196 } |
197 | 197 |
198 bool ActivityLogPrivateDeleteDatabaseFunction::RunImpl() { | 198 bool ActivityLogPrivateDeleteDatabaseFunction::RunAsync() { |
199 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 199 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
200 DCHECK(activity_log); | 200 DCHECK(activity_log); |
201 activity_log->DeleteDatabase(); | 201 activity_log->DeleteDatabase(); |
202 return true; | 202 return true; |
203 } | 203 } |
204 | 204 |
205 bool ActivityLogPrivateDeleteUrlsFunction::RunImpl() { | 205 bool ActivityLogPrivateDeleteUrlsFunction::RunAsync() { |
206 scoped_ptr<activity_log_private::DeleteUrls::Params> params( | 206 scoped_ptr<activity_log_private::DeleteUrls::Params> params( |
207 activity_log_private::DeleteUrls::Params::Create(*args_)); | 207 activity_log_private::DeleteUrls::Params::Create(*args_)); |
208 EXTENSION_FUNCTION_VALIDATE(params.get()); | 208 EXTENSION_FUNCTION_VALIDATE(params.get()); |
209 | 209 |
210 // Put the arguments in the right format. | 210 // Put the arguments in the right format. |
211 std::vector<GURL> gurls; | 211 std::vector<GURL> gurls; |
212 std::vector<std::string> urls = *params->urls.get(); | 212 std::vector<std::string> urls = *params->urls.get(); |
213 for (std::vector<std::string>::iterator it = urls.begin(); | 213 for (std::vector<std::string>::iterator it = urls.begin(); |
214 it != urls.end(); | 214 it != urls.end(); |
215 ++it) { | 215 ++it) { |
216 gurls.push_back(GURL(*it)); | 216 gurls.push_back(GURL(*it)); |
217 } | 217 } |
218 | 218 |
219 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 219 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
220 DCHECK(activity_log); | 220 DCHECK(activity_log); |
221 activity_log->RemoveURLs(gurls); | 221 activity_log->RemoveURLs(gurls); |
222 return true; | 222 return true; |
223 } | 223 } |
224 | 224 |
225 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |