OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | |
7 | |
8 #include <string> | |
9 #include "base/time.h" | |
10 #include "chrome/browser/extensions/activity_actions.h" | |
11 | |
12 namespace extensions { | |
13 | |
14 // This class describes API calls that did not run into permissions or quota | |
15 // problems. See BlockedActions for API calls that did not succeed. | |
16 class APIAction : public Action { | |
17 public: | |
18 // TODO(felt): I'll finalize this list when making the UI. | |
19 enum APIActionType { | |
20 READ, | |
21 MODIFIED, | |
22 DELETED, | |
23 ADDED, | |
24 ENABLED, | |
25 DISABLED, | |
26 CREATED, | |
27 UNKNOWN_ACTION | |
28 }; | |
29 | |
30 // TODO(felt): I'll finalize this list when making the UI. | |
31 enum APITargetType { | |
32 BOOKMARK, | |
33 TABS, | |
34 HISTORY, | |
35 COOKIES, | |
36 BROWSER_ACTION, | |
37 NOTIFICATION, | |
38 OMNIBOX, | |
39 UNKNOWN_TARGET | |
40 }; | |
41 | |
42 static const char* kTableName; | |
43 static const char* kTableStructure; | |
44 | |
45 // Create a new APIAction to describe a successful API call. All | |
46 // parameters are required. | |
47 APIAction(const std::string& extension_id, | |
48 const base::Time& time, | |
49 const APIActionType verb, // e.g. "ADDED" | |
50 const APITargetType target, // e.g. "BOOKMARK" | |
51 const std::string& api_call, // full method signature incl args | |
52 const std::string& extra); // any extra logging info | |
53 | |
54 // Record the action in the database. | |
55 virtual void Record(sql::Connection* db) OVERRIDE; | |
56 | |
57 // Print a APIAction with il8n substitutions for display. | |
58 virtual std::string PrettyPrintFori18n() OVERRIDE; | |
59 | |
60 // Print a APIAction as a regular string for debugging purposes. | |
61 virtual std::string PrettyPrintForDebug() OVERRIDE; | |
62 | |
63 // Helper methods for recording the values into the db. | |
64 const std::string& extension_id() const { return extension_id_; } | |
65 const base::Time& time() const { return time_; } | |
66 const std::string& api_call() const { return api_call_; } | |
67 std::string VerbAsString() const; | |
68 std::string TargetAsString() const; | |
69 std::string extra() const { return extra_; } | |
70 | |
71 // Helper methods for creating a APIAction. | |
72 static APIActionType StringAsActionType(const std::string& str); | |
73 static APITargetType StringAsTargetType(const std::string& str); | |
74 | |
75 protected: | |
76 virtual ~APIAction(); | |
77 | |
78 private: | |
79 std::string extension_id_; | |
80 base::Time time_; | |
81 APIActionType verb_; | |
82 APITargetType target_; | |
83 std::string api_call_; | |
84 std::string extra_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(APIAction); | |
87 }; | |
88 | |
89 } // namespace | |
90 | |
91 #endif // CHROME_BROWSER_EXTENSIONS_API_ACTIONS_H_ | |
92 | |
OLD | NEW |