OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/json/json_string_value_serializer.h" | 6 #include "base/json/json_string_value_serializer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "chrome/browser/extensions/activity_log/activity_database.h" | 9 #include "chrome/browser/extensions/activity_log/activity_database.h" |
10 #include "chrome/browser/extensions/activity_log/api_actions.h" | 10 #include "chrome/browser/extensions/activity_log/api_actions.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 case PARAM_KEY_DETAILS_STRING: | 87 case PARAM_KEY_DETAILS_STRING: |
88 return std::string(kKeyDetailsString); | 88 return std::string(kKeyDetailsString); |
89 default: | 89 default: |
90 return std::string(); | 90 return std::string(); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 std::string FullStreamUIPolicy::ProcessArguments( | 94 std::string FullStreamUIPolicy::ProcessArguments( |
95 ActionType action_type, | 95 ActionType action_type, |
96 const std::string& name, | 96 const std::string& name, |
97 const ListValue* args) const { | 97 const base::ListValue* args) const { |
98 std::string processed_args; | 98 std::string processed_args; |
99 if (args) { | 99 if (args) { |
100 ListValue::const_iterator it = args->begin(); | 100 base::ListValue::const_iterator it = args->begin(); |
101 // TODO(felt,dbabic) Think about replacing the loop with a single | 101 // TODO(felt,dbabic) Think about replacing the loop with a single |
102 // call to SerializeAndOmitBinaryValues. | 102 // call to SerializeAndOmitBinaryValues. |
103 for (; it != args->end(); ++it) { | 103 for (; it != args->end(); ++it) { |
104 std::string arg; | 104 std::string arg; |
105 JSONStringValueSerializer serializer(&arg); | 105 JSONStringValueSerializer serializer(&arg); |
106 if (serializer.SerializeAndOmitBinaryValues(**it)) { | 106 if (serializer.SerializeAndOmitBinaryValues(**it)) { |
107 if (it != args->begin()) { | 107 if (it != args->begin()) { |
108 processed_args.append(", "); | 108 processed_args.append(", "); |
109 } | 109 } |
110 processed_args.append(arg); | 110 processed_args.append(arg); |
111 } | 111 } |
112 } | 112 } |
113 } | 113 } |
114 return processed_args; | 114 return processed_args; |
115 } | 115 } |
116 | 116 |
117 void FullStreamUIPolicy::ProcessWebRequestModifications( | 117 void FullStreamUIPolicy::ProcessWebRequestModifications( |
118 DictionaryValue& details, | 118 DictionaryValue& details, |
119 std::string& details_string) const { | 119 std::string& details_string) const { |
120 JSONStringValueSerializer serializer(&details_string); | 120 JSONStringValueSerializer serializer(&details_string); |
121 serializer.Serialize(details); | 121 serializer.Serialize(details); |
122 } | 122 } |
123 | 123 |
124 void FullStreamUIPolicy::ProcessAction( | 124 void FullStreamUIPolicy::ProcessAction( |
125 ActionType action_type, | 125 ActionType action_type, |
126 const std::string& extension_id, | 126 const std::string& extension_id, |
127 const std::string& name, | 127 const std::string& name, |
128 const GURL& url_param, | 128 const GURL& url_param, |
129 const ListValue* args, | 129 const base::ListValue* args, |
130 const DictionaryValue* details) { | 130 const DictionaryValue* details) { |
131 std::string concatenated_args = ProcessArguments(action_type, name, args); | 131 std::string concatenated_args = ProcessArguments(action_type, name, args); |
132 const Time now = Time::Now(); | 132 const Time now = Time::Now(); |
133 scoped_refptr<Action> action; | 133 scoped_refptr<Action> action; |
134 std::string extra; | 134 std::string extra; |
135 if (details) { | 135 if (details) { |
136 details->GetString(GetKey(PARAM_KEY_EXTRA), &extra); | 136 details->GetString(GetKey(PARAM_KEY_EXTRA), &extra); |
137 } | 137 } |
138 | 138 |
139 switch (action_type) { | 139 switch (action_type) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 break; | 213 break; |
214 } | 214 } |
215 default: | 215 default: |
216 NOTREACHED(); | 216 NOTREACHED(); |
217 } | 217 } |
218 | 218 |
219 ScheduleAndForget(db_, &ActivityDatabase::RecordAction, action); | 219 ScheduleAndForget(db_, &ActivityDatabase::RecordAction, action); |
220 } | 220 } |
221 | 221 |
222 } // namespace extensions | 222 } // namespace extensions |
OLD | NEW |