Index: chrome/browser/extensions/manager_actions.h |
=================================================================== |
--- chrome/browser/extensions/manager_actions.h (revision 0) |
+++ chrome/browser/extensions/manager_actions.h (revision 0) |
@@ -0,0 +1,86 @@ |
+// 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_MANAGER_ACTIONS_H_ |
+#define CHROME_BROWSER_EXTENSIONS_MANAGER_ACTIONS_H_ |
+ |
+#include <string> |
+#include "base/time.h" |
+#include "chrome/browser/extensions/activity_actions.h" |
+ |
+namespace activity { |
+ |
+static const std::string manager_table_name_ = "activitylog-managers"; |
+static const std::string manager_table_creator_ = "CREATE TABLE " + |
+ manager_table_name_ + "(" |
+ "id INTEGER PRIMARY KEY," |
+ "extension_id LONGVARCHAR NOT NULL," |
+ "time INTEGER NOT NULL," |
+ "manager_action_type LONGVARCHAR NOT NULL," |
+ "target_type LONGVARCHAR NOT NULL" |
mvrable
2012/12/04 01:00:13
Include spaces at before the closing quote so that
felt
2012/12/07 19:27:45
Done.
|
+ "api_call LONGVARCHAR NOT NULL)"; |
+ |
+// This class describes extension actions that pertain to Content Script |
+// insertion, Content Script DOM manipulations, and extension XHRs. |
+class ManagerAction { |
+ public: |
+ enum ManagerActionType { |
+ READ, |
+ MODIFIED, |
+ DELETED, |
+ ADDED, |
+ ENABLED, |
+ DISABLED, |
+ CREATED, |
+ UNKNOWN_ACTION |
+ }; |
+ |
+ enum ManagerTargetType { |
+ BOOKMARK, |
+ TABS, |
+ HISTORY, |
+ COOKIES, |
+ BROWSER_ACTION, |
+ NOTIFICATION, |
+ OMNIBOX, |
+ UNKNOWN_TARGET |
+ }; |
+ |
+ // Create a new ManagerAction 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. |
+ ManagerAction(const std::string& extension_id, |
+ const ManagerActionType& verb, |
mvrable
2012/12/04 01:00:13
An enum is like an integer so you should pass by v
felt
2012/12/07 19:27:45
Done.
|
+ const ManagerTargetType& target, |
+ const std::string& api_call, |
+ const base::Time& time); |
+ virtual ~ManagerAction(); |
+ |
+ // Print a ManagerAction with il8n substitutions for display. |
+ std::string PrettyPrintForil8n(); |
mvrable
2012/12/04 01:00:13
This (and the following PrettyPrint method) can pr
felt
2012/12/07 19:27:45
Done.
|
+ |
+ // Print a ManagerAction 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_; } |
+ const std::string& api_call() { return api_call_; } |
+ std::string VerbAsString(); |
+ std::string TargetAsString(); |
+ |
+ // Helper methods for restoring a ManagerAction from the db. |
+ static ManagerActionType StringAsManagerActionType(const std::string& str); |
+ static ManagerTargetType StringAsManagerTargetType(const std::string& str); |
+ |
+ private: |
+ std::string extension_id_; |
+ ManagerActionType verb_; |
+ ManagerTargetType target_; |
+ std::string api_call_; |
+ base::Time time_; |
+}; |
+} |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_MANAGER_ACTIONS_H_ |