OLD | NEW |
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.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 ListValue* GetRequestHeadersList(const net::HttpRequestHeaders& headers) { | 309 ListValue* GetRequestHeadersList(const net::HttpRequestHeaders& headers) { |
310 ListValue* headers_value = new ListValue(); | 310 ListValue* headers_value = new ListValue(); |
311 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) | 311 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) |
312 headers_value->Append(ToHeaderDictionary(it.name(), it.value())); | 312 headers_value->Append(ToHeaderDictionary(it.name(), it.value())); |
313 return headers_value; | 313 return headers_value; |
314 } | 314 } |
315 | 315 |
316 // Creates a StringValue with the status line of |headers|. If |headers| is | 316 // Creates a StringValue with the status line of |headers|. If |headers| is |
317 // NULL, an empty string is returned. Ownership is passed to the caller. | 317 // NULL, an empty string is returned. Ownership is passed to the caller. |
318 StringValue* GetStatusLine(net::HttpResponseHeaders* headers) { | 318 StringValue* GetStatusLine(net::HttpResponseHeaders* headers) { |
319 return new StringValue(headers ? headers->GetStatusLine() : ""); | 319 return new StringValue(headers ? headers->GetStatusLine() : std::string()); |
320 } | 320 } |
321 | 321 |
322 void NotifyWebRequestAPIUsed(void* profile_id, const Extension* extension) { | 322 void NotifyWebRequestAPIUsed(void* profile_id, const Extension* extension) { |
323 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 323 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
324 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 324 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
325 return; | 325 return; |
326 | 326 |
327 if (profile->GetExtensionService()->HasUsedWebRequest(extension)) | 327 if (profile->GetExtensionService()->HasUsedWebRequest(extension)) |
328 return; | 328 return; |
329 profile->GetExtensionService()->SetHasUsedWebRequest(extension, true); | 329 profile->GetExtensionService()->SetHasUsedWebRequest(extension, true); |
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2033 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2034 adblock = true; | 2034 adblock = true; |
2035 } else { | 2035 } else { |
2036 other = true; | 2036 other = true; |
2037 } | 2037 } |
2038 } | 2038 } |
2039 } | 2039 } |
2040 | 2040 |
2041 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2041 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2042 } | 2042 } |
OLD | NEW |