| Index: chrome/browser/extensions/api_actions.cc
|
| diff --git a/chrome/browser/extensions/api_actions.cc b/chrome/browser/extensions/api_actions.cc
|
| index b628afa8384be40c752c9ed2723574b9ba10c4c1..bd94fd259926bb6345097a0e8471bed30b2da0ff 100644
|
| --- a/chrome/browser/extensions/api_actions.cc
|
| +++ b/chrome/browser/extensions/api_actions.cc
|
| @@ -15,6 +15,7 @@ const char* APIAction::kTableName = "activitylog_apis";
|
| const char* APIAction::kTableStructure = "("
|
| "extension_id LONGVARCHAR NOT NULL, "
|
| "time INTEGER NOT NULL, "
|
| + "api_category LONGVARCHAR NOT NULL, "
|
| "api_action_type LONGVARCHAR NOT NULL, "
|
| "target_type LONGVARCHAR NOT NULL, "
|
| "api_call LONGVARCHAR NOT NULL, "
|
| @@ -22,12 +23,14 @@ const char* APIAction::kTableStructure = "("
|
|
|
| APIAction::APIAction(const std::string& extension_id,
|
| const base::Time& time,
|
| + const APICategory category,
|
| const APIActionType verb,
|
| const APITargetType target,
|
| const std::string& api_call,
|
| const std::string& extra)
|
| : extension_id_(extension_id),
|
| time_(time),
|
| + category_(category),
|
| verb_(verb),
|
| target_(target),
|
| api_call_(api_call),
|
| @@ -38,16 +41,17 @@ APIAction::~APIAction() {
|
|
|
| void APIAction::Record(sql::Connection* db) {
|
| std::string sql_str = "INSERT INTO " + std::string(kTableName)
|
| - + " (extension_id, time, api_action_type, target_type, api_call, extra)"
|
| - " VALUES (?,?,?,?,?,?)";
|
| + + " (extension_id, time, api_category, api_action_type, target_type,"
|
| + " api_call, extra) VALUES (?,?,?,?,?,?,?)";
|
| sql::Statement statement(db->GetCachedStatement(
|
| sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
|
| statement.BindString(0, extension_id_);
|
| statement.BindInt64(1, time_.ToInternalValue());
|
| - statement.BindString(2, VerbAsString());
|
| - statement.BindString(3, TargetAsString());
|
| - statement.BindString(4, api_call_);
|
| - statement.BindString(5, extra_);
|
| + statement.BindString(2, CategoryAsString());
|
| + statement.BindString(3, VerbAsString());
|
| + statement.BindString(4, TargetAsString());
|
| + statement.BindString(5, api_call_);
|
| + statement.BindString(6, extra_);
|
|
|
| if (!statement.Run())
|
| LOG(ERROR) << "Activity log database I/O failed: " << sql_str;
|
| @@ -60,8 +64,20 @@ std::string APIAction::PrettyPrintFori18n() {
|
|
|
| std::string APIAction::PrettyPrintForDebug() {
|
| // TODO(felt): implement this for real when the UI is redesigned.
|
| - return "ID: " + extension_id_ + ", VERB: " + VerbAsString() +
|
| - ", TARGET: " + TargetAsString() + ", API: " + api_call_;
|
| + return "ID: " + extension_id_ + + ", CATEGORY: " + CategoryAsString() +
|
| + ", VERB: " + VerbAsString() + ", TARGET: " + TargetAsString() +
|
| + ", API: " + api_call_;
|
| +}
|
| +
|
| +std::string APIAction::CategoryAsString() const {
|
| + switch (category_) {
|
| + case CALL:
|
| + return "CALL";
|
| + case EVENT_CALLBACK:
|
| + return "EVENT_CALLBACK";
|
| + default:
|
| + return "UNKNOWN_CATEGORY";
|
| + }
|
| }
|
|
|
| std::string APIAction::VerbAsString() const {
|
| @@ -106,6 +122,17 @@ std::string APIAction::TargetAsString() const {
|
| }
|
| }
|
|
|
| +APIAction::APICategory APIAction::StringAsCategory(
|
| + const std::string& str) {
|
| + if (str == "CALL") {
|
| + return CALL;
|
| + } else if (str == "EVENT_CALLBACK") {
|
| + return EVENT_CALLBACK;
|
| + } else {
|
| + return UNKNOWN_CATEGORY;
|
| + }
|
| +}
|
| +
|
| APIAction::APIActionType APIAction::StringAsActionType(
|
| const std::string& str) {
|
| if (str == "READ") {
|
|
|