| 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_LOG_DOM_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "chrome/browser/extensions/activity_log/activity_actions.h" | 9 #include "chrome/browser/extensions/activity_log/activity_actions.h" |
| 10 #include "chrome/common/extensions/dom_action_types.h" | 10 #include "chrome/common/extensions/dom_action_types.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 // This class describes extension actions that pertain to DOM API calls and | 15 // This class describes extension actions that pertain to DOM API calls and |
| 16 // content script insertions. | 16 // content script insertions. |
| 17 class DOMAction : public Action { | 17 class DOMAction : public Action { |
| 18 public: | 18 public: |
| 19 static const char* kTableName; | |
| 20 static const char* kTableContentFields[]; | |
| 21 static const char* kTableFieldTypes[]; | |
| 22 | |
| 23 // Create a new database table for storing DOMActions, or update the schema if | |
| 24 // it is out of date. Any existing data is preserved. | |
| 25 static bool InitializeTable(sql::Connection* db); | |
| 26 | |
| 27 // Create a new DOMAction to describe a new DOM API call. | 19 // Create a new DOMAction to describe a new DOM API call. |
| 28 // If the DOMAction is on a background page, the url & url_title may be null. | 20 // If the DOMAction is on a background page, the url & url_title may be null. |
| 29 // If the DOMAction refers to a content script insertion, api_call may be null | 21 // If the DOMAction refers to a content script insertion, api_call may be null |
| 30 // but args should be the name of the content script. | 22 // but args should be the name of the content script. |
| 31 DOMAction(const std::string& extension_id, | 23 DOMAction(const std::string& extension_id, |
| 32 const base::Time& time, | 24 const base::Time& time, |
| 33 const DomActionType::Type verb, // what happened | 25 const DomActionType::Type verb, // what happened |
| 34 const GURL& url, // the url of the page the | 26 const GURL& url, // the url of the page the |
| 35 // script is running on | 27 // script is running on |
| 36 const string16& url_title, // the page title | 28 const string16& url_title, // the page title |
| 37 const std::string& api_call, // the DOM API call | 29 const std::string& api_call, // the DOM API call |
| 38 const std::string& args, // the args | 30 const std::string& args, // the args |
| 39 const std::string& extra); // any extra logging info | 31 const std::string& extra); // any extra logging info |
| 40 | 32 |
| 41 // Create a new DOMAction from a database row. | |
| 42 explicit DOMAction(const sql::Statement& s); | |
| 43 | |
| 44 virtual scoped_ptr<api::activity_log_private::ExtensionActivity> | 33 virtual scoped_ptr<api::activity_log_private::ExtensionActivity> |
| 45 ConvertToExtensionActivity() OVERRIDE; | 34 ConvertToExtensionActivity() OVERRIDE; |
| 46 | 35 |
| 47 // Record the action in the database. | 36 // Record the action in the database. |
| 48 virtual bool Record(sql::Connection* db) OVERRIDE; | 37 virtual bool Record(sql::Connection* db) OVERRIDE; |
| 49 | 38 |
| 50 // Print a DOMAction as a regular string for debugging purposes. | 39 // Print a DOMAction as a regular string for debugging purposes. |
| 51 virtual std::string PrintForDebug() OVERRIDE; | 40 virtual std::string PrintForDebug() OVERRIDE; |
| 52 | 41 |
| 53 // Helper methods for retrieving the values and debugging. | 42 // Helper methods for retrieving the values and debugging. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 69 std::string args_; | 58 std::string args_; |
| 70 std::string extra_; | 59 std::string extra_; |
| 71 | 60 |
| 72 DISALLOW_COPY_AND_ASSIGN(DOMAction); | 61 DISALLOW_COPY_AND_ASSIGN(DOMAction); |
| 73 }; | 62 }; |
| 74 | 63 |
| 75 } // namespace extensions | 64 } // namespace extensions |
| 76 | 65 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ |
| 78 | 67 |
| OLD | NEW |