| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/activity_log/api_actions.h" | 9 #include "chrome/browser/extensions/activity_log/api_actions.h" |
| 10 #include "chrome/browser/extensions/activity_log/api_name_constants.h" | 10 #include "chrome/browser/extensions/activity_log/api_name_constants.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (!statement.Run()) { | 201 if (!statement.Run()) { |
| 202 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; | 202 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; |
| 203 statement.Clear(); | 203 statement.Clear(); |
| 204 return false; | 204 return false; |
| 205 } | 205 } |
| 206 return true; | 206 return true; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // static | 209 // static |
| 210 void APIAction::LookupTabId(const std::string& api_call, | 210 void APIAction::LookupTabId(const std::string& api_call, |
| 211 ListValue* args, | 211 base::ListValue* args, |
| 212 Profile* profile) { | 212 Profile* profile) { |
| 213 if (api_call == "tabs.get" || // api calls, ID as int | 213 if (api_call == "tabs.get" || // api calls, ID as int |
| 214 api_call == "tabs.connect" || | 214 api_call == "tabs.connect" || |
| 215 api_call == "tabs.sendMessage" || | 215 api_call == "tabs.sendMessage" || |
| 216 api_call == "tabs.duplicate" || | 216 api_call == "tabs.duplicate" || |
| 217 api_call == "tabs.update" || | 217 api_call == "tabs.update" || |
| 218 api_call == "tabs.reload" || | 218 api_call == "tabs.reload" || |
| 219 api_call == "tabs.detectLanguage" || | 219 api_call == "tabs.detectLanguage" || |
| 220 api_call == "tabs.executeScript" || | 220 api_call == "tabs.executeScript" || |
| 221 api_call == "tabs.insertCSS" || | 221 api_call == "tabs.insertCSS" || |
| 222 api_call == "tabs.move" || // api calls, IDs in array | 222 api_call == "tabs.move" || // api calls, IDs in array |
| 223 api_call == "tabs.remove" || | 223 api_call == "tabs.remove" || |
| 224 api_call == "tabs.onUpdated" || // events, ID as int | 224 api_call == "tabs.onUpdated" || // events, ID as int |
| 225 api_call == "tabs.onMoved" || | 225 api_call == "tabs.onMoved" || |
| 226 api_call == "tabs.onDetached" || | 226 api_call == "tabs.onDetached" || |
| 227 api_call == "tabs.onAttached" || | 227 api_call == "tabs.onAttached" || |
| 228 api_call == "tabs.onRemoved" || | 228 api_call == "tabs.onRemoved" || |
| 229 api_call == "tabs.onReplaced") { | 229 api_call == "tabs.onReplaced") { |
| 230 int tab_id; | 230 int tab_id; |
| 231 ListValue* id_list; | 231 base::ListValue* id_list; |
| 232 if (args->GetInteger(0, &tab_id)) { | 232 if (args->GetInteger(0, &tab_id)) { |
| 233 std::string url = GetURLForTabId(tab_id, profile); | 233 std::string url = GetURLForTabId(tab_id, profile); |
| 234 if (url != std::string()) | 234 if (url != std::string()) |
| 235 args->Set(0, new base::StringValue(url)); | 235 args->Set(0, new base::StringValue(url)); |
| 236 } else if ((api_call == "tabs.move" || api_call == "tabs.remove") && | 236 } else if ((api_call == "tabs.move" || api_call == "tabs.remove") && |
| 237 args->GetList(0, &id_list)) { | 237 args->GetList(0, &id_list)) { |
| 238 for (int i = 0; i < static_cast<int>(id_list->GetSize()); ++i) { | 238 for (int i = 0; i < static_cast<int>(id_list->GetSize()); ++i) { |
| 239 if (id_list->GetInteger(i, &tab_id)) { | 239 if (id_list->GetInteger(i, &tab_id)) { |
| 240 std::string url = GetURLForTabId(tab_id, profile); | 240 std::string url = GetURLForTabId(tab_id, profile); |
| 241 if (url != std::string()) | 241 if (url != std::string()) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 259 return "call"; | 259 return "call"; |
| 260 case EVENT_CALLBACK: | 260 case EVENT_CALLBACK: |
| 261 return "event_callback"; | 261 return "event_callback"; |
| 262 default: | 262 default: |
| 263 return "unknown_type"; | 263 return "unknown_type"; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace extensions | 267 } // namespace extensions |
| 268 | 268 |
| OLD | NEW |