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 API calls that did not run into permissions or quota |
| 18 // problems. See BlockedActions for API calls that did not succeed. |
| 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 successful API call. All |
| 47 // parameters are required. |
| 48 ManagerAction(const std::string& extension_id, |
| 49 const ManagerActionType verb, |
| 50 const ManagerTargetType target, |
| 51 const std::string& api_call, |
| 52 const base::Time& time); |
| 53 |
| 54 // Print a ManagerAction with il8n substitutions for display. |
| 55 virtual std::string PrettyPrintFori18n() OVERRIDE; |
| 56 |
| 57 // Print a ManagerAction as a regular string for debugging purposes. |
| 58 virtual std::string PrettyPrintForDebug() OVERRIDE; |
| 59 |
| 60 // Helper methods for recording the values into the db. |
| 61 const std::string& extension_id() const { return extension_id_; } |
| 62 const base::Time& time() const { return time_; } |
| 63 const std::string& api_call() const { return api_call_; } |
| 64 std::string VerbAsString() const; |
| 65 std::string TargetAsString() const; |
| 66 |
| 67 // Helper methods for creating a ManagerAction. |
| 68 static ManagerActionType StringAsActionType(const std::string& str); |
| 69 static ManagerTargetType StringAsTargetType(const std::string& str); |
| 70 |
| 71 protected: |
| 72 virtual ~ManagerAction(); |
| 73 |
| 74 private: |
| 75 friend class base::RefCountedThreadSafe<ManagerAction>; |
| 76 |
| 77 std::string extension_id_; |
| 78 ManagerActionType verb_; |
| 79 ManagerTargetType target_; |
| 80 std::string api_call_; |
| 81 base::Time time_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(ManagerAction); |
| 84 }; |
| 85 |
| 86 } // namespace |
| 87 |
| 88 #endif // CHROME_BROWSER_EXTENSIONS_MANAGER_ACTIONS_H_ |
| 89 |
OLD | NEW |