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_MANAGER_ACTIONS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_MANAGER_ACTIONS_H_ |
| 7 |
| 8 #include <string> |
| 9 #include "base/time.h" |
| 10 #include "chrome/browser/extensions/activity_actions.h" |
| 11 |
| 12 namespace extensions { |
| 13 |
| 14 extern const char* manager_table_name_; |
| 15 extern const char* manager_table_structure_; |
| 16 |
| 17 // This class describes extension actions that pertain to Content Script |
| 18 // insertion, Content Script DOM manipulations, and extension XHRs. |
| 19 class ManagerAction : public Action, |
| 20 public base::RefCountedThreadSafe<ManagerAction> { |
| 21 public: |
| 22 // TODO(felt): I'll finalize this list when making the UI. |
| 23 enum ManagerActionType { |
| 24 READ, |
| 25 MODIFIED, |
| 26 DELETED, |
| 27 ADDED, |
| 28 ENABLED, |
| 29 DISABLED, |
| 30 CREATED, |
| 31 UNKNOWN_ACTION |
| 32 }; |
| 33 |
| 34 // TODO(felt): I'll finalize this list when making the UI. |
| 35 enum ManagerTargetType { |
| 36 BOOKMARK, |
| 37 TABS, |
| 38 HISTORY, |
| 39 COOKIES, |
| 40 BROWSER_ACTION, |
| 41 NOTIFICATION, |
| 42 OMNIBOX, |
| 43 UNKNOWN_TARGET |
| 44 }; |
| 45 |
| 46 // Create a new ManagerAction to describe a ContentScript action |
| 47 // or XHR. All of the parameters should have values except for |
| 48 // url_title, which can be an empty string if the ActionType is XHR. |
| 49 ManagerAction(const std::string& extension_id, |
| 50 const ManagerActionType verb, |
| 51 const ManagerTargetType target, |
| 52 const std::string& api_call, |
| 53 const base::Time& time); |
| 54 |
| 55 // Print a ManagerAction with il8n substitutions for display. |
| 56 virtual std::string PrettyPrintFori18n() OVERRIDE; |
| 57 |
| 58 // Print a ManagerAction as a regular string for debugging purposes. |
| 59 virtual std::string PrettyPrintForDebug() OVERRIDE; |
| 60 |
| 61 // Helper methods for recording the values into the db. |
| 62 const std::string& extension_id() const { return extension_id_; } |
| 63 const base::Time& time() const { return time_; } |
| 64 const std::string& api_call() const { return api_call_; } |
| 65 std::string VerbAsString() const; |
| 66 std::string TargetAsString() const; |
| 67 |
| 68 // Helper methods for creating a ManagerAction. |
| 69 static ManagerActionType StringAsActionType(const std::string& str); |
| 70 static ManagerTargetType StringAsTargetType(const std::string& str); |
| 71 |
| 72 protected: |
| 73 virtual ~ManagerAction(); |
| 74 |
| 75 private: |
| 76 friend class base::RefCountedThreadSafe<ManagerAction>; |
| 77 |
| 78 std::string extension_id_; |
| 79 ManagerActionType verb_; |
| 80 ManagerTargetType target_; |
| 81 std::string api_call_; |
| 82 base::Time time_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(ManagerAction); |
| 85 }; |
| 86 |
| 87 } // namespace |
| 88 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_MANAGER_ACTIONS_H_ |
| 90 |
OLD | NEW |