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_URL_ACTIONS_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ | |
7 | |
8 #include <string> | |
9 #include "base/string16.h" | |
10 #include "base/time.h" | |
11 #include "chrome/browser/extensions/activity_actions.h" | |
12 #include "googleurl/src/gurl.h" | |
13 | |
14 namespace extensions { | |
15 | |
16 // This class describes extension actions that pertain to Content Script | |
17 // insertion, Content Script DOM manipulations, and extension XHRs. | |
18 class UrlAction : public Action { | |
19 public: | |
20 enum UrlActionType { | |
21 MODIFIED, // For Content Script DOM manipulations | |
22 READ, // For Content Script DOM manipulations | |
23 INSERTED, // For when Content Scripts are added to pages | |
24 XHR, // When an extension core sends an XHR | |
25 }; | |
26 | |
27 static const char* kTableName; | |
28 static const char* kTableStructure; | |
29 | |
30 // Create a new UrlAction to describe a ContentScript action | |
31 // or XHR. All of the parameters should have values except for | |
32 // url_title, which can be an empty string if the ActionType is XHR. | |
33 UrlAction(const std::string& extension_id, | |
34 const base::Time& time, | |
35 const UrlActionType verb, // what happened | |
36 const GURL& url, // the url of the page or XHR | |
37 const string16& url_title, // the page title | |
38 const std::string& tech_message, // what goes under "More" | |
39 const std::string& extra); // any extra logging info | |
40 | |
41 // Record the action in the database. | |
42 virtual void Record(sql::Connection* db) OVERRIDE; | |
43 | |
44 // Print a UrlAction with il8n substitutions for display. | |
45 virtual std::string PrettyPrintFori18n() OVERRIDE; | |
46 | |
47 // Print a UrlAction as a regular string for debugging purposes. | |
48 virtual std::string PrettyPrintForDebug() OVERRIDE; | |
49 | |
50 // Helper methods for retrieving the values. | |
51 const std::string& extension_id() const { return extension_id_; } | |
52 const base::Time& time() const { return time_; } | |
53 std::string VerbAsString() const; | |
54 const GURL& url() const { return url_; } | |
55 const string16& url_title() const { return url_title_; } | |
56 const std::string& technical_message() const { return technical_message_; } | |
57 const std::string& extra() const { return extra_; } | |
58 | |
59 // Helper methods for restoring a UrlAction from the db. | |
60 static UrlActionType StringAsUrlActionType(const std::string& str); | |
61 | |
62 protected: | |
63 virtual ~UrlAction(); | |
64 | |
65 private: | |
66 std::string extension_id_; | |
67 base::Time time_; | |
68 UrlActionType verb_; | |
69 GURL url_; | |
70 string16 url_title_; | |
71 std::string technical_message_; | |
72 std::string extra_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(UrlAction); | |
75 }; | |
76 | |
77 } // namespace extensions | |
78 | |
79 #endif // CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ | |
80 | |
OLD | NEW |