OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // User 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 extern const char* url_table_name_; |
| 17 extern const char* url_table_structure_; |
| 18 |
| 19 // This class describes extension actions that pertain to Content Script |
| 20 // insertion, Content Script DOM manipulations, and extension XHRs. |
| 21 class UrlAction : public Action, |
| 22 public base::RefCountedThreadSafe<UrlAction> { |
| 23 public: |
| 24 enum UrlActionType { |
| 25 MODIFIED, // For Content Script DOM manipulations |
| 26 READ, // For Content Script DOM manipulations |
| 27 INSERTED, // For when Content Scripts are added to pages |
| 28 XHR, // When an extension core sends an XHR |
| 29 UNKNOWN, // Something is wrong; this value shouldn't be used |
| 30 }; |
| 31 |
| 32 // Create a new UrlAction to describe a ContentScript action |
| 33 // or XHR. All of the parameters should have values except for |
| 34 // url_title, which can be an empty string if the ActionType is XHR. |
| 35 UrlAction(const std::string& extension_id, |
| 36 const UrlActionType verb, |
| 37 const GURL& url, |
| 38 const string16& url_title, |
| 39 const std::string& ext_script, |
| 40 const base::Time& time); |
| 41 |
| 42 // Print a UrlAction with il8n substitutions for display. |
| 43 virtual std::string PrettyPrintFori18n() OVERRIDE; |
| 44 |
| 45 // Print a UrlAction as a regular string for debugging purposes. |
| 46 virtual std::string PrettyPrintForDebug() OVERRIDE; |
| 47 |
| 48 // Helper methods for recording the values into the db. |
| 49 const std::string& extension_id() const { return extension_id_; } |
| 50 const base::Time& time() const { return time_; } |
| 51 std::string VerbAsString() const; |
| 52 const GURL& url() const { return url_; } |
| 53 const string16& url_title() const { return url_title_; } |
| 54 const std::string& script() const { return script_; } |
| 55 |
| 56 // Helper methods for restoring a UrlAction from the db. |
| 57 static UrlActionType StringAsUrlActionType(const std::string& str); |
| 58 |
| 59 protected: |
| 60 virtual ~UrlAction(); |
| 61 |
| 62 private: |
| 63 friend class base::RefCountedThreadSafe<UrlAction>; |
| 64 |
| 65 std::string extension_id_; |
| 66 UrlActionType verb_; |
| 67 GURL url_; |
| 68 string16 url_title_; |
| 69 std::string script_; |
| 70 base::Time time_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(UrlAction); |
| 73 }; |
| 74 |
| 75 } // namespace |
| 76 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ |
| 78 |
OLD | NEW |