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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 keys::kOnCompletedEvent, | 88 keys::kOnCompletedEvent, |
89 keys::kOnErrorOccurredEvent, | 89 keys::kOnErrorOccurredEvent, |
90 keys::kOnSendHeadersEvent, | 90 keys::kOnSendHeadersEvent, |
91 keys::kOnAuthRequiredEvent, | 91 keys::kOnAuthRequiredEvent, |
92 keys::kOnResponseStartedEvent, | 92 keys::kOnResponseStartedEvent, |
93 keys::kOnHeadersReceivedEvent, | 93 keys::kOnHeadersReceivedEvent, |
94 }; | 94 }; |
95 | 95 |
96 #define ARRAYEND(array) (array + arraysize(array)) | 96 #define ARRAYEND(array) (array + arraysize(array)) |
97 | 97 |
98 // Access to request body (crbug.com/91191/) is currently only enabled in dev | |
99 // and canary channels. | |
100 bool IsWebRequestBodyDataAccessEnabled() { | |
101 return Feature::GetCurrentChannel() <= VersionInfo::CHANNEL_DEV; | |
102 } | |
103 | |
104 const char* GetRequestStageAsString( | 98 const char* GetRequestStageAsString( |
105 ExtensionWebRequestEventRouter::EventTypes type) { | 99 ExtensionWebRequestEventRouter::EventTypes type) { |
106 switch (type) { | 100 switch (type) { |
107 case ExtensionWebRequestEventRouter::kInvalidEvent: | 101 case ExtensionWebRequestEventRouter::kInvalidEvent: |
108 return "Invalid"; | 102 return "Invalid"; |
109 case ExtensionWebRequestEventRouter::kOnBeforeRequest: | 103 case ExtensionWebRequestEventRouter::kOnBeforeRequest: |
110 return keys::kOnBeforeRequest; | 104 return keys::kOnBeforeRequest; |
111 case ExtensionWebRequestEventRouter::kOnBeforeSendHeaders: | 105 case ExtensionWebRequestEventRouter::kOnBeforeSendHeaders: |
112 return keys::kOnBeforeSendHeaders; | 106 return keys::kOnBeforeSendHeaders; |
113 case ExtensionWebRequestEventRouter::kOnSendHeaders: | 107 case ExtensionWebRequestEventRouter::kOnSendHeaders: |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 520 |
527 if (str == "requestHeaders") | 521 if (str == "requestHeaders") |
528 *extra_info_spec |= REQUEST_HEADERS; | 522 *extra_info_spec |= REQUEST_HEADERS; |
529 else if (str == "responseHeaders") | 523 else if (str == "responseHeaders") |
530 *extra_info_spec |= RESPONSE_HEADERS; | 524 *extra_info_spec |= RESPONSE_HEADERS; |
531 else if (str == "blocking") | 525 else if (str == "blocking") |
532 *extra_info_spec |= BLOCKING; | 526 *extra_info_spec |= BLOCKING; |
533 else if (str == "asyncBlocking") | 527 else if (str == "asyncBlocking") |
534 *extra_info_spec |= ASYNC_BLOCKING; | 528 *extra_info_spec |= ASYNC_BLOCKING; |
535 else if (str == "requestBody") | 529 else if (str == "requestBody") |
536 *extra_info_spec |= | 530 *extra_info_spec |= REQUEST_BODY; |
537 IsWebRequestBodyDataAccessEnabled() ? REQUEST_BODY : 0; | |
538 else | 531 else |
539 return false; | 532 return false; |
540 | 533 |
541 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. | 534 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. |
542 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING)) | 535 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING)) |
543 return false; | 536 return false; |
544 } | 537 } |
545 return true; | 538 return true; |
546 } | 539 } |
547 | 540 |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2028 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2036 adblock = true; | 2029 adblock = true; |
2037 } else { | 2030 } else { |
2038 other = true; | 2031 other = true; |
2039 } | 2032 } |
2040 } | 2033 } |
2041 } | 2034 } |
2042 | 2035 |
2043 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2036 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2044 } | 2037 } |
OLD | NEW |