Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: chrome/browser/extensions/manager_actions.cc

Issue 11421192: Save extension activity log to a file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include <string>
6 #include "base/logging.h"
7 #include "chrome/browser/extensions/manager_actions.h"
8
9 namespace extensions {
10
11 const char* manager_table_name_ = "activitylog_managers";
12 const char* manager_table_structure_ = "("
13 "extension_id LONGVARCHAR NOT NULL, "
14 "time INTEGER NOT NULL, "
15 "manager_action_type LONGVARCHAR NOT NULL, "
16 "target_type LONGVARCHAR NOT NULL, "
17 "api_call LONGVARCHAR NOT NULL)";
18
19 ManagerAction::ManagerAction(const std::string& extension_id,
20 const ManagerActionType verb,
21 const ManagerTargetType target,
22 const std::string& api_call,
23 const base::Time& time)
24 : extension_id_(extension_id),
25 verb_(verb),
26 target_(target),
27 api_call_(api_call),
28 time_(time) { }
29
30 ManagerAction::~ManagerAction() {
31 }
32
33 std::string ManagerAction::PrettyPrintFori18n() {
34 // TODO(felt): implement this for real when the UI is redesigned.
35 return PrettyPrintForDebug();
36 }
37
38 std::string ManagerAction::PrettyPrintForDebug() {
39 // TODO(felt): implement this for real when the UI is redesigned.
40 return "ID: " + extension_id_ + ", VERB: " + VerbAsString() +
41 ", TARGET: " + TargetAsString() + ", API: " + api_call_;
42 }
43
44 std::string ManagerAction::VerbAsString() const {
45 switch (verb_) {
46 case READ:
47 return "READ";
48 case MODIFIED:
49 return "MODIFIED";
50 case DELETED:
51 return "DELETED";
52 case ADDED:
53 return "ADDED";
54 case ENABLED:
55 return "ENABLED";
56 case DISABLED:
57 return "DISABLED";
58 case CREATED:
59 return "CREATED";
60 default:
61 return "UNKNOWN_ACTION";
62 }
63 }
64
65 std::string ManagerAction::TargetAsString() const {
66 switch (target_) {
67 case BOOKMARK:
68 return "BOOKMARK";
69 case TABS:
70 return "TABS";
71 case HISTORY:
72 return "HISTORY";
73 case COOKIES:
74 return "COOKIES";
75 case BROWSER_ACTION:
76 return "BROWSER_ACTION";
77 case NOTIFICATION:
78 return "NOTIFICATION";
79 case OMNIBOX:
80 return "OMNIBOX";
81 default:
82 return "UNKNOWN_TARGET";
83 }
84 }
85
86 ManagerAction::ManagerActionType ManagerAction::StringAsActionType(
87 const std::string& str) {
88 if (str == "READ") {
89 return READ;
90 } else if (str == "MODIFIED") {
91 return MODIFIED;
92 } else if (str == "DELETED") {
93 return DELETED;
94 } else if (str == "ADDED") {
95 return ADDED;
96 } else if (str == "ENABLED") {
97 return ENABLED;
98 } else if (str == "DISABLED") {
99 return DISABLED;
100 } else if (str == "CREATED") {
101 return CREATED;
102 } else {
103 return UNKNOWN_ACTION;
104 }
105 }
106
107 // The all-caps strings match the enum names. The lowercase strings match the
108 // actual manager object names (e.g., cookies.remove(...);).
109 ManagerAction::ManagerTargetType ManagerAction::StringAsTargetType(
110 const std::string& str) {
111 if (str == "BOOKMARK" || str == "bookmark") {
112 return BOOKMARK;
113 } else if (str == "TABS" || str == "tabs") {
114 return TABS;
115 } else if (str == "HISTORY" || str == "history") {
116 return HISTORY;
117 } else if (str == "COOKIES" || str == "cookies") {
118 return COOKIES;
119 } else if (str == "BROWSER_ACTION" || str == "browser_action") {
120 return BROWSER_ACTION;
121 } else if (str == "NOTIFICATION" || str == "notification") {
122 return NOTIFICATION;
123 } else if (str == "OMNIBOX" || str == "omnibox") {
124 return OMNIBOX;
125 } else {
126 return UNKNOWN_TARGET;
127 }
128 }
129
130 } // namespace
131
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698