| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 // Populate the return object. | 168 // Populate the return object. |
| 169 std::unique_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 ExtensionFunction::ResponseAction |
| 178 ActivityLogPrivateDeleteActivitiesFunction::Run() { |
| 178 std::unique_ptr<activity_log_private::DeleteActivities::Params> params( | 179 std::unique_ptr<activity_log_private::DeleteActivities::Params> params( |
| 179 activity_log_private::DeleteActivities::Params::Create(*args_)); | 180 activity_log_private::DeleteActivities::Params::Create(*args_)); |
| 180 EXTENSION_FUNCTION_VALIDATE(params.get()); | 181 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 181 | 182 |
| 182 // Put the arguments in the right format. | 183 // Put the arguments in the right format. |
| 183 std::vector<int64_t> action_ids; | 184 std::vector<int64_t> action_ids; |
| 184 int64_t value; | 185 int64_t value; |
| 185 for (size_t i = 0; i < params->activity_ids.size(); i++) { | 186 for (size_t i = 0; i < params->activity_ids.size(); i++) { |
| 186 if (base::StringToInt64(params->activity_ids[i], &value)) | 187 if (base::StringToInt64(params->activity_ids[i], &value)) |
| 187 action_ids.push_back(value); | 188 action_ids.push_back(value); |
| 188 } | 189 } |
| 189 | 190 |
| 190 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 191 ActivityLog* activity_log = ActivityLog::GetInstance(browser_context()); |
| 191 DCHECK(activity_log); | 192 DCHECK(activity_log); |
| 192 activity_log->RemoveActions(action_ids); | 193 activity_log->RemoveActions(action_ids); |
| 193 return true; | 194 return RespondNow(NoArguments()); |
| 194 } | 195 } |
| 195 | 196 |
| 196 bool ActivityLogPrivateDeleteDatabaseFunction::RunAsync() { | 197 ExtensionFunction::ResponseAction |
| 197 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 198 ActivityLogPrivateDeleteDatabaseFunction::Run() { |
| 199 ActivityLog* activity_log = ActivityLog::GetInstance(browser_context()); |
| 198 DCHECK(activity_log); | 200 DCHECK(activity_log); |
| 199 activity_log->DeleteDatabase(); | 201 activity_log->DeleteDatabase(); |
| 200 return true; | 202 return RespondNow(NoArguments()); |
| 201 } | 203 } |
| 202 | 204 |
| 203 bool ActivityLogPrivateDeleteUrlsFunction::RunAsync() { | 205 ExtensionFunction::ResponseAction ActivityLogPrivateDeleteUrlsFunction::Run() { |
| 204 std::unique_ptr<activity_log_private::DeleteUrls::Params> params( | 206 std::unique_ptr<activity_log_private::DeleteUrls::Params> params( |
| 205 activity_log_private::DeleteUrls::Params::Create(*args_)); | 207 activity_log_private::DeleteUrls::Params::Create(*args_)); |
| 206 EXTENSION_FUNCTION_VALIDATE(params.get()); | 208 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 207 | 209 |
| 208 // Put the arguments in the right format. | 210 // Put the arguments in the right format. |
| 209 std::vector<GURL> gurls; | 211 std::vector<GURL> gurls; |
| 210 std::vector<std::string> urls = *params->urls.get(); | 212 std::vector<std::string> urls = *params->urls.get(); |
| 211 for (std::vector<std::string>::iterator it = urls.begin(); | 213 for (std::vector<std::string>::iterator it = urls.begin(); |
| 212 it != urls.end(); | 214 it != urls.end(); |
| 213 ++it) { | 215 ++it) { |
| 214 gurls.push_back(GURL(*it)); | 216 gurls.push_back(GURL(*it)); |
| 215 } | 217 } |
| 216 | 218 |
| 217 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 219 ActivityLog* activity_log = ActivityLog::GetInstance(browser_context()); |
| 218 DCHECK(activity_log); | 220 DCHECK(activity_log); |
| 219 activity_log->RemoveURLs(gurls); | 221 activity_log->RemoveURLs(gurls); |
| 220 return true; | 222 return RespondNow(NoArguments()); |
| 221 } | 223 } |
| 222 | 224 |
| 223 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |