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_BLOCKED_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BLOCKED_ACTIONS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_BLOCKED_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BLOCKED_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" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 // This class describes API calls that ran into permissions or quota problems. | 14 // This class describes API calls that ran into permissions or quota problems. |
15 // See APIActions for API calls that succeeded. | 15 // See APIActions for API calls that succeeded. |
16 class BlockedAction : public Action { | 16 class BlockedAction : public Action { |
17 public: | 17 public: |
18 static const char* kTableName; | 18 static const char* kTableName; |
19 static const char* kTableStructure; | 19 static const char* kTableBasicFields; |
| 20 static const char* kTableContentFields[]; |
20 | 21 |
| 22 // Create a new database table for storing BlockedActions, or update the |
| 23 // schema if it is out of date. Any existing data is preserved. |
| 24 static bool InitializeTable(sql::Connection* db); |
| 25 |
| 26 // You must supply the id, time, api_call, and reason. |
21 BlockedAction(const std::string& extension_id, | 27 BlockedAction(const std::string& extension_id, |
22 const base::Time& time, | 28 const base::Time& time, |
23 const std::string& blocked_action, // the blocked API call | 29 const std::string& api_call, // the blocked API call |
| 30 const std::string& args, // the arguments |
24 const std::string& reason, // the reason it's blocked | 31 const std::string& reason, // the reason it's blocked |
25 const std::string& extra); // any extra logging info | 32 const std::string& extra); // any extra logging info |
26 | 33 |
27 // Record the action in the database. | 34 // Record the action in the database. |
28 virtual void Record(sql::Connection* db) OVERRIDE; | 35 virtual void Record(sql::Connection* db) OVERRIDE; |
29 | 36 |
30 // Print a BlockedAction with il8n substitutions for display. | 37 // Print a BlockedAction with il8n substitutions for display. |
31 virtual std::string PrettyPrintFori18n() OVERRIDE; | 38 virtual std::string PrettyPrintFori18n() OVERRIDE; |
32 | 39 |
33 // Print a BlockedAction as a regular string for debugging purposes. | 40 // Print a BlockedAction as a regular string for debugging purposes. |
34 virtual std::string PrettyPrintForDebug() OVERRIDE; | 41 virtual std::string PrettyPrintForDebug() OVERRIDE; |
35 | 42 |
36 // Helper methods for recording the values into the db. | 43 // Helper methods for recording the values into the db. |
37 const std::string& extension_id() const { return extension_id_; } | 44 const std::string& extension_id() const { return extension_id_; } |
38 const base::Time& time() const { return time_; } | 45 const base::Time& time() const { return time_; } |
39 const std::string& reason() const { return reason_; } | 46 const std::string& reason() const { return reason_; } |
40 const std::string& blocked_action() const { return blocked_action_; } | 47 const std::string& api_call() const { return api_call_; } |
| 48 const std::string& args() const { return args_; } |
41 const std::string& extra() const { return extra_; } | 49 const std::string& extra() const { return extra_; } |
42 | 50 |
43 protected: | 51 protected: |
44 virtual ~BlockedAction(); | 52 virtual ~BlockedAction(); |
45 | 53 |
46 private: | 54 private: |
47 std::string extension_id_; | 55 std::string extension_id_; |
48 base::Time time_; | 56 base::Time time_; |
49 std::string blocked_action_; | 57 std::string api_call_; |
| 58 std::string args_; |
50 std::string reason_; | 59 std::string reason_; |
51 std::string extra_; | 60 std::string extra_; |
52 | 61 |
53 DISALLOW_COPY_AND_ASSIGN(BlockedAction); | 62 DISALLOW_COPY_AND_ASSIGN(BlockedAction); |
54 }; | 63 }; |
55 | 64 |
56 } // namespace extensions | 65 } // namespace extensions |
57 | 66 |
58 #endif // CHROME_BROWSER_EXTENSIONS_BLOCKED_ACTIONS_H_ | 67 #endif // CHROME_BROWSER_EXTENSIONS_BLOCKED_ACTIONS_H_ |
59 | 68 |
OLD | NEW |