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/string.h" |
+#include "base/string16.h" |
+#include "base/time.h" |
+#include "chrome/browser/extensions/activity_actions.h" |
+#include "googleurl/src/gurl.h" |
+ |
+namespace activity { |
+ |
+static const std::string url_table_name_ = "activitylog-urls"; |
mvrable
2012/12/04 01:00:13
"Static or global variables of class type are forb
mvrable
2012/12/04 01:00:13
The static keyword has several overloaded meanings
felt
2012/12/07 19:27:45
Done.
|
+static const std::string url_table_creator_ = "CREATE TABLE (" + |
mvrable
2012/12/04 01:00:13
For the reasons above, constructing this string dy
|
+ url_table_name_ + "(" |
+ "id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT," |
+ "extension_id LONGVARCHAR NOT NULL," |
+ "time INTEGER NOT NULL," |
+ "url_action_type LONGVARCHAR NOT NULL," |
+ "url LONGVARCHAR NOT NULL," |
+ "url_title LONGVARCHAR," |
+ "api_call LONGVARCHAR NOT NULL)"; |
+ |
+// This class describes extension actions that pertain to Content Script |
+// insertion, Content Script DOM manipulations, and extension XHRs. |
+class UrlAction : Action { |
+ 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& api_call, |
+ const base::Time& time); |
+ virtual ~UrlAction(); |
+ |
+ // Print a UrlAction with il8n substitutions for display. |
+ std::string PrettyPrintForil8n(); |
+ |
+ // Print a UrlAction as a regular string for debugging purposes. |
+ std::string PrettyPrintForDebug(); |
+ |
+ // Helper methods for recording the values into the db. |
+ const std::string& extension_id() const { return extension_id_; } |
+ base::Time time() const { return time_; } |
+ std::string VerbAsString(); |
+ const GURL& url() const { return url_; } |
+ const string16& url_title() { return url_title_; } |
+ const std::string& api_call() { return api_call_; } |
+ |
+ // Helper methods for restoring a UrlAction from the db. |
+ static UrlActionType StringAsUrlActionType(const std::string& str); |
+ |
+ private: |
+ std::string extension_id_; |
+ UrlActionType verb_; |
+ GURL url_; |
+ string16 url_title_; |
+ std::string api_call_; |
+ base::Time time_; |
+}; |
+} |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_URL_ACTIONS_H_ |