Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: chrome/browser/extensions/activity_log/dom_actions.h

Issue 14774012: Replaced enum strings with ints in Activity Log database (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved a comment (pre-review) Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string16.h" 8 #include "base/string16.h"
9 #include "chrome/browser/extensions/activity_log/activity_actions.h" 9 #include "chrome/browser/extensions/activity_log/activity_actions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 // This class describes extension actions that pertain to DOM API calls and 14 // This class describes extension actions that pertain to DOM API calls and
15 // content script insertions. 15 // content script insertions.
16 class DOMAction : public Action { 16 class DOMAction : public Action {
17 public: 17 public:
18 enum DOMActionType { 18 enum DOMActionType {
19 GETTER, // For Content Script DOM manipulations 19 GETTER = 0, // For Content Script DOM manipulations
20 SETTER, // For Content Script DOM manipulations 20 SETTER = 1, // For Content Script DOM manipulations
21 METHOD, // For Content Script DOM manipulations 21 METHOD = 2, // For Content Script DOM manipulations
22 INSERTED, // For when Content Scripts are added to pages 22 INSERTED = 3, // For when Content Scripts are added to pages
23 XHR, // When an extension core sends an XHR 23 XHR = 4, // When an extension core sends an XHR
24 WEBREQUEST, // When a page request is modified with the WebRequest API 24 WEBREQUEST = 5, // When a page request is modified with the WebRequest API
25 MODIFIED, // For legacy, also used as a catch-all 25 MODIFIED = 6, // For legacy, also used as a catch-all
26 }; 26 };
27 27
28 static const char* kTableName; 28 static const char* kTableName;
29 static const char* kTableContentFields[]; 29 static const char* kTableContentFields[];
30 static const char* kTableFieldTypes[];
30 31
31 // Create a new database table for storing DOMActions, or update the schema if 32 // Create a new database table for storing DOMActions, or update the schema if
32 // it is out of date. Any existing data is preserved. 33 // it is out of date. Any existing data is preserved.
33 static bool InitializeTable(sql::Connection* db); 34 static bool InitializeTable(sql::Connection* db);
34 35
35 // Create a new DOMAction to describe a new DOM API call. 36 // Create a new DOMAction to describe a new DOM API call.
36 // If the DOMAction is on a background page, the url & url_title may be null. 37 // If the DOMAction is on a background page, the url & url_title may be null.
37 // If the DOMAction refers to a content script insertion, api_call may be null 38 // If the DOMAction refers to a content script insertion, api_call may be null
38 // but args should be the name of the content script. 39 // but args should be the name of the content script.
39 DOMAction(const std::string& extension_id, 40 DOMAction(const std::string& extension_id,
40 const base::Time& time, 41 const base::Time& time,
41 const DOMActionType verb, // what happened 42 const DOMActionType verb, // what happened
42 const GURL& url, // the url of the page the 43 const GURL& url, // the url of the page the
43 // script is running on 44 // script is running on
44 const string16& url_title, // the page title 45 const string16& url_title, // the page title
45 const std::string& api_call, // the DOM API call 46 const std::string& api_call, // the DOM API call
46 const std::string& args, // the args 47 const std::string& args, // the args
47 const std::string& extra); // any extra logging info 48 const std::string& extra); // any extra logging info
48 49
49 // Create a new DOMAction from a database row. 50 // Create a new DOMAction from a database row.
50 explicit DOMAction(const sql::Statement& s); 51 explicit DOMAction(const sql::Statement& s);
51 52
52 // Record the action in the database. 53 // Record the action in the database.
53 virtual void Record(sql::Connection* db) OVERRIDE; 54 virtual void Record(sql::Connection* db) OVERRIDE;
54 55
55 // Print a DOMAction as a regular string for debugging purposes. 56 // Print a DOMAction as a regular string for debugging purposes.
56 virtual std::string PrintForDebug() OVERRIDE; 57 virtual std::string PrintForDebug() OVERRIDE;
57 58
58 // Helper methods for retrieving the values. 59 // Helper methods for retrieving the values and debugging.
59 std::string VerbAsString() const; 60 std::string VerbAsString() const;
60 const GURL& url() const { return url_; } 61 const GURL& url() const { return url_; }
61 const string16& url_title() const { return url_title_; } 62 const string16& url_title() const { return url_title_; }
62 const std::string& api_call() const { return api_call_; } 63 const std::string& api_call() const { return api_call_; }
63 const std::string& args() const { return args_; } 64 const std::string& args() const { return args_; }
64 const std::string& extra() const { return extra_; } 65 const std::string& extra() const { return extra_; }
65 66
66 // Helper methods for restoring a DOMAction from the db.
67 static DOMActionType StringAsDOMActionType(const std::string& str);
68
69 protected: 67 protected:
70 virtual ~DOMAction(); 68 virtual ~DOMAction();
71 69
72 private: 70 private:
73 DOMActionType verb_; 71 DOMActionType verb_;
74 GURL url_; 72 GURL url_;
75 string16 url_title_; 73 string16 url_title_;
76 std::string api_call_; 74 std::string api_call_;
77 std::string args_; 75 std::string args_;
78 std::string extra_; 76 std::string extra_;
79 77
80 DISALLOW_COPY_AND_ASSIGN(DOMAction); 78 DISALLOW_COPY_AND_ASSIGN(DOMAction);
81 }; 79 };
82 80
83 } // namespace extensions 81 } // namespace extensions
84 82
85 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_ 83 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_DOM_ACTIONS_H_
86 84
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698