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_ACTIVITY_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_ACTIONS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_ACTIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/history/url_database.h" | 11 #include "chrome/browser/history/url_database.h" |
12 #include "sql/connection.h" | 12 #include "sql/connection.h" |
13 #include "sql/transaction.h" | 13 #include "sql/transaction.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
17 // This is the interface for extension actions that are to be recorded in | 17 // This is the interface for extension actions that are to be recorded in |
18 // the activity log. | 18 // the activity log. |
19 class Action : public base::RefCountedThreadSafe<Action> { | 19 class Action : public base::RefCountedThreadSafe<Action> { |
20 public: | 20 public: |
| 21 // Initialize the table for a given action type. |
| 22 static bool InitializeTableInternal(sql::Connection* db); |
| 23 |
21 // Record the action in the database. | 24 // Record the action in the database. |
22 virtual void Record(sql::Connection* db) = 0; | 25 virtual void Record(sql::Connection* db) = 0; |
23 | 26 |
24 // Print an action with il8n substitutions for display. | 27 // Print an action with il8n substitutions for display. |
25 virtual std::string PrettyPrintFori18n() = 0; | 28 virtual std::string PrettyPrintFori18n() = 0; |
26 | 29 |
27 // Print an action as a regular string for debugging purposes. | 30 // Print an action as a regular string for debugging purposes. |
28 virtual std::string PrettyPrintForDebug() = 0; | 31 virtual std::string PrettyPrintForDebug() = 0; |
29 | 32 |
30 protected: | 33 protected: |
31 Action() {} | 34 Action() {} |
32 virtual ~Action() {} | 35 virtual ~Action() {} |
33 | 36 |
| 37 // Initialize the table for a given action type. |
| 38 static bool InitializeTableInternal(sql::Connection* db, |
| 39 const char* table_name, |
| 40 const char* basic_fields, |
| 41 const char* content_fields[], |
| 42 const int num_content_fields); |
| 43 |
34 private: | 44 private: |
35 friend class base::RefCountedThreadSafe<Action>; | 45 friend class base::RefCountedThreadSafe<Action>; |
36 | 46 |
37 DISALLOW_COPY_AND_ASSIGN(Action); | 47 DISALLOW_COPY_AND_ASSIGN(Action); |
38 }; | 48 }; |
39 | 49 |
40 } // namespace extensions | 50 } // namespace extensions |
41 | 51 |
42 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_ACTIONS_H_ | 52 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_ACTIONS_H_ |
43 | 53 |
OLD | NEW |