Index: chrome/browser/extensions/url_actions.h |
=================================================================== |
--- chrome/browser/extensions/url_actions.h (revision 0) |
+++ chrome/browser/extensions/url_actions.h (revision 0) |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// User of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ |
+#define CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ |
+ |
+#include <string> |
+#include "base/string16.h" |
+#include "base/time.h" |
+#include "chrome/browser/extensions/activity_actions.h" |
+#include "googleurl/src/gurl.h" |
+ |
+namespace extensions { |
+ |
+extern const char* url_table_name_; |
+extern const char* url_table_structure_; |
+ |
+// This class describes extension actions that pertain to Content Script |
+// insertion, Content Script DOM manipulations, and extension XHRs. |
+class UrlAction : public Action, |
+ public base::RefCountedThreadSafe<UrlAction> { |
+ public: |
+ enum UrlActionType { |
+ MODIFIED, // For Content Script DOM manipulations |
+ READ, // For Content Script DOM manipulations |
+ INSERTED, // For when Content Scripts are added to pages |
+ XHR, // When an extension core sends an XHR |
+ UNKNOWN, // Something is wrong; this value shouldn't be used |
+ }; |
+ |
+ // Create a new UrlAction to describe a ContentScript action |
+ // or XHR. All of the parameters should have values except for |
+ // url_title, which can be an empty string if the ActionType is XHR. |
+ UrlAction(const std::string& extension_id, |
+ const UrlActionType verb, |
+ const GURL& url, |
+ const string16& url_title, |
+ const std::string& ext_script, |
+ const base::Time& time); |
+ |
+ // Print a UrlAction with il8n substitutions for display. |
+ virtual std::string PrettyPrintFori18n() OVERRIDE; |
+ |
+ // Print a UrlAction as a regular string for debugging purposes. |
+ virtual std::string PrettyPrintForDebug() OVERRIDE; |
+ |
+ // Helper methods for recording the values into the db. |
+ const std::string& extension_id() const { return extension_id_; } |
+ const base::Time& time() const { return time_; } |
+ std::string VerbAsString() const; |
+ const GURL& url() const { return url_; } |
+ const string16& url_title() const { return url_title_; } |
+ const std::string& script() const { return script_; } |
+ |
+ // Helper methods for restoring a UrlAction from the db. |
+ static UrlActionType StringAsUrlActionType(const std::string& str); |
+ |
+ protected: |
+ virtual ~UrlAction(); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<UrlAction>; |
+ |
+ std::string extension_id_; |
+ UrlActionType verb_; |
+ GURL url_; |
+ string16 url_title_; |
+ std::string script_; |
+ base::Time time_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(UrlAction); |
+}; |
+ |
+} // namespace |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ |
+ |