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 #ifndef CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/extensions/activity_actions.h" | 10 #include "chrome/browser/extensions/activity_actions.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 TABS, | 39 TABS, |
40 HISTORY, | 40 HISTORY, |
41 COOKIES, | 41 COOKIES, |
42 BROWSER_ACTION, | 42 BROWSER_ACTION, |
43 NOTIFICATION, | 43 NOTIFICATION, |
44 OMNIBOX, | 44 OMNIBOX, |
45 UNKNOWN_TARGET | 45 UNKNOWN_TARGET |
46 }; | 46 }; |
47 | 47 |
48 static const char* kTableName; | 48 static const char* kTableName; |
49 static const char* kTableStructure; | 49 static const char* kTableBasicFields; |
| 50 static const char* kTableContentFields[]; |
50 | 51 |
51 // Create the database table for storing APIActions, or update the schema if | 52 // Create the database table for storing APIActions, or update the schema if |
52 // it is out of date. Any existing data is preserved. | 53 // it is out of date. Any existing data is preserved. |
53 static bool InitializeTable(sql::Connection* db); | 54 static bool InitializeTable(sql::Connection* db); |
54 | 55 |
55 // Create a new APIAction to describe a successful API call. All | 56 // Create a new APIAction to describe a successful API call. All |
56 // parameters are required. | 57 // parameters are required. |
57 APIAction(const std::string& extension_id, | 58 APIAction(const std::string& extension_id, |
58 const base::Time& time, | 59 const base::Time& time, |
59 const Type type, // e.g. "CALL" | 60 const Type type, // e.g. "CALL" |
60 const Verb verb, // e.g. "ADDED" | 61 const Verb verb, // e.g. "ADDED" |
61 const Target target, // e.g. "BOOKMARK" | 62 const Target target, // e.g. "BOOKMARK" |
62 const std::string& api_call, // full method signature incl args | 63 const std::string& api_call, // full method name |
| 64 const std::string& args, // the argument list |
63 const std::string& extra); // any extra logging info | 65 const std::string& extra); // any extra logging info |
64 | 66 |
65 // Record the action in the database. | 67 // Record the action in the database. |
66 virtual void Record(sql::Connection* db) OVERRIDE; | 68 virtual void Record(sql::Connection* db) OVERRIDE; |
67 | 69 |
68 // Print a APIAction with il8n substitutions for display. | 70 // Print a APIAction with il8n substitutions for display. |
69 virtual std::string PrettyPrintFori18n() OVERRIDE; | 71 virtual std::string PrettyPrintFori18n() OVERRIDE; |
70 | 72 |
71 // Print a APIAction as a regular string for debugging purposes. | 73 // Print a APIAction as a regular string for debugging purposes. |
72 virtual std::string PrettyPrintForDebug() OVERRIDE; | 74 virtual std::string PrettyPrintForDebug() OVERRIDE; |
73 | 75 |
74 // Helper methods for recording the values into the db. | 76 // Helper methods for recording the values into the db. |
75 const std::string& extension_id() const { return extension_id_; } | 77 const std::string& extension_id() const { return extension_id_; } |
76 const base::Time& time() const { return time_; } | 78 const base::Time& time() const { return time_; } |
77 const std::string& api_call() const { return api_call_; } | 79 const std::string& api_call() const { return api_call_; } |
| 80 const std::string& args() const { return args_; } |
78 std::string TypeAsString() const; | 81 std::string TypeAsString() const; |
79 std::string VerbAsString() const; | 82 std::string VerbAsString() const; |
80 std::string TargetAsString() const; | 83 std::string TargetAsString() const; |
81 std::string extra() const { return extra_; } | 84 std::string extra() const { return extra_; } |
82 | 85 |
83 // Helper methods for creating a APIAction. | 86 // Helper methods for creating a APIAction. |
84 static Type StringAsType(const std::string& str); | 87 static Type StringAsType(const std::string& str); |
85 static Verb StringAsVerb(const std::string& str); | 88 static Verb StringAsVerb(const std::string& str); |
86 static Target StringAsTarget(const std::string& str); | 89 static Target StringAsTarget(const std::string& str); |
87 | 90 |
88 protected: | 91 protected: |
89 virtual ~APIAction(); | 92 virtual ~APIAction(); |
90 | 93 |
91 private: | 94 private: |
92 std::string extension_id_; | 95 std::string extension_id_; |
93 base::Time time_; | 96 base::Time time_; |
94 Type type_; | 97 Type type_; |
95 Verb verb_; | 98 Verb verb_; |
96 Target target_; | 99 Target target_; |
97 std::string api_call_; | 100 std::string api_call_; |
| 101 std::string args_; |
98 std::string extra_; | 102 std::string extra_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(APIAction); | 104 DISALLOW_COPY_AND_ASSIGN(APIAction); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace | 107 } // namespace |
104 | 108 |
105 #endif // CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | 109 #endif // CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ |
OLD | NEW |