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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_helpers.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 net::NetLog::ParametersCallback CreateNetLogExtensionIdCallback( 209 net::NetLog::ParametersCallback CreateNetLogExtensionIdCallback(
210 const EventResponseDelta* delta) { 210 const EventResponseDelta* delta) {
211 return net::NetLog::StringCallback("extension_id", &delta->extension_id); 211 return net::NetLog::StringCallback("extension_id", &delta->extension_id);
212 } 212 }
213 213
214 // Creates NetLog parameters to indicate that an extension modified a request. 214 // Creates NetLog parameters to indicate that an extension modified a request.
215 // Caller takes ownership of returned value. 215 // Caller takes ownership of returned value.
216 Value* NetLogModificationCallback( 216 Value* NetLogModificationCallback(
217 const EventResponseDelta* delta, 217 const EventResponseDelta* delta,
218 net::NetLog::LogLevel log_level) { 218 net::NetLog::LogLevel log_level) {
219 DictionaryValue* dict = new DictionaryValue(); 219 base::DictionaryValue* dict = new base::DictionaryValue();
220 dict->SetString("extension_id", delta->extension_id); 220 dict->SetString("extension_id", delta->extension_id);
221 221
222 ListValue* modified_headers = new ListValue(); 222 base::ListValue* modified_headers = new base::ListValue();
223 net::HttpRequestHeaders::Iterator modification( 223 net::HttpRequestHeaders::Iterator modification(
224 delta->modified_request_headers); 224 delta->modified_request_headers);
225 while (modification.GetNext()) { 225 while (modification.GetNext()) {
226 std::string line = modification.name() + ": " + modification.value(); 226 std::string line = modification.name() + ": " + modification.value();
227 modified_headers->Append(Value::CreateStringValue(line)); 227 modified_headers->Append(Value::CreateStringValue(line));
228 } 228 }
229 dict->Set("modified_headers", modified_headers); 229 dict->Set("modified_headers", modified_headers);
230 230
231 ListValue* deleted_headers = new ListValue(); 231 base::ListValue* deleted_headers = new base::ListValue();
232 for (std::vector<std::string>::const_iterator key = 232 for (std::vector<std::string>::const_iterator key =
233 delta->deleted_request_headers.begin(); 233 delta->deleted_request_headers.begin();
234 key != delta->deleted_request_headers.end(); 234 key != delta->deleted_request_headers.end();
235 ++key) { 235 ++key) {
236 deleted_headers->Append(Value::CreateStringValue(*key)); 236 deleted_headers->Append(Value::CreateStringValue(*key));
237 } 237 }
238 dict->Set("deleted_headers", deleted_headers); 238 dict->Set("deleted_headers", deleted_headers);
239 return dict; 239 return dict;
240 } 240 }
241 241
242 bool InDecreasingExtensionInstallationTimeOrder( 242 bool InDecreasingExtensionInstallationTimeOrder(
243 const linked_ptr<EventResponseDelta>& a, 243 const linked_ptr<EventResponseDelta>& a,
244 const linked_ptr<EventResponseDelta>& b) { 244 const linked_ptr<EventResponseDelta>& b) {
245 return a->extension_install_time > b->extension_install_time; 245 return a->extension_install_time > b->extension_install_time;
246 } 246 }
247 247
248 ListValue* StringToCharList(const std::string& s) { 248 base::ListValue* StringToCharList(const std::string& s) {
249 ListValue* result = new ListValue; 249 base::ListValue* result = new base::ListValue;
250 for (size_t i = 0, n = s.size(); i < n; ++i) { 250 for (size_t i = 0, n = s.size(); i < n; ++i) {
251 result->Append( 251 result->Append(
252 Value::CreateIntegerValue( 252 Value::CreateIntegerValue(
253 *reinterpret_cast<const unsigned char*>(&s[i]))); 253 *reinterpret_cast<const unsigned char*>(&s[i])));
254 } 254 }
255 return result; 255 return result;
256 } 256 }
257 257
258 bool CharListToString(const ListValue* list, std::string* out) { 258 bool CharListToString(const base::ListValue* list, std::string* out) {
259 if (!list) 259 if (!list)
260 return false; 260 return false;
261 const size_t list_length = list->GetSize(); 261 const size_t list_length = list->GetSize();
262 out->resize(list_length); 262 out->resize(list_length);
263 int value = 0; 263 int value = 0;
264 for (size_t i = 0; i < list_length; ++i) { 264 for (size_t i = 0; i < list_length; ++i) {
265 if (!list->GetInteger(i, &value) || value < 0 || value > 255) 265 if (!list->GetInteger(i, &value) || value < 0 || value > 255)
266 return false; 266 return false;
267 unsigned char tmp = static_cast<unsigned char>(value); 267 unsigned char tmp = static_cast<unsigned char>(value);
268 (*out)[i] = *reinterpret_cast<char*>(&tmp); 268 (*out)[i] = *reinterpret_cast<char*>(&tmp);
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 for (content::RenderProcessHost::iterator it = 1271 for (content::RenderProcessHost::iterator it =
1272 content::RenderProcessHost::AllHostsIterator(); 1272 content::RenderProcessHost::AllHostsIterator();
1273 !it.IsAtEnd(); it.Advance()) { 1273 !it.IsAtEnd(); it.Advance()) {
1274 content::RenderProcessHost* host = it.GetCurrentValue(); 1274 content::RenderProcessHost* host = it.GetCurrentValue();
1275 if (host->GetBrowserContext() == browser_context) 1275 if (host->GetBrowserContext() == browser_context)
1276 SendExtensionWebRequestStatusToHost(host); 1276 SendExtensionWebRequestStatusToHost(host);
1277 } 1277 }
1278 } 1278 }
1279 1279
1280 } // namespace extension_web_request_api_helpers 1280 } // namespace extension_web_request_api_helpers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698