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

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc

Issue 1853283002: Map webRequest filter type to multiple internal ResourceTypes if needed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 keys::kResourceTypeKey); 150 keys::kResourceTypeKey);
151 return scoped_refptr<const WebRequestConditionAttribute>(NULL); 151 return scoped_refptr<const WebRequestConditionAttribute>(NULL);
152 } 152 }
153 153
154 size_t number_types = value_as_list->GetSize(); 154 size_t number_types = value_as_list->GetSize();
155 155
156 std::vector<ResourceType> passed_types; 156 std::vector<ResourceType> passed_types;
157 passed_types.reserve(number_types); 157 passed_types.reserve(number_types);
158 for (size_t i = 0; i < number_types; ++i) { 158 for (size_t i = 0; i < number_types; ++i) {
159 std::string resource_type_string; 159 std::string resource_type_string;
160 ResourceType type = content::RESOURCE_TYPE_LAST_TYPE;
161 if (!value_as_list->GetString(i, &resource_type_string) || 160 if (!value_as_list->GetString(i, &resource_type_string) ||
162 !helpers::ParseResourceType(resource_type_string, &type)) { 161 !helpers::ParseResourceType(resource_type_string, &passed_types)) {
163 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, 162 *error = ErrorUtils::FormatErrorMessage(kInvalidValue,
164 keys::kResourceTypeKey); 163 keys::kResourceTypeKey);
165 return scoped_refptr<const WebRequestConditionAttribute>(NULL); 164 return scoped_refptr<const WebRequestConditionAttribute>(NULL);
166 } 165 }
167 passed_types.push_back(type);
168 } 166 }
169 167
170 return scoped_refptr<const WebRequestConditionAttribute>( 168 return scoped_refptr<const WebRequestConditionAttribute>(
171 new WebRequestConditionAttributeResourceType(passed_types)); 169 new WebRequestConditionAttributeResourceType(passed_types));
172 } 170 }
173 171
174 int WebRequestConditionAttributeResourceType::GetStages() const { 172 int WebRequestConditionAttributeResourceType::GetStages() const {
175 return ON_BEFORE_REQUEST | ON_BEFORE_SEND_HEADERS | ON_SEND_HEADERS | 173 return ON_BEFORE_REQUEST | ON_BEFORE_SEND_HEADERS | ON_SEND_HEADERS |
176 ON_HEADERS_RECEIVED | ON_AUTH_REQUIRED | ON_BEFORE_REDIRECT | 174 ON_HEADERS_RECEIVED | ON_AUTH_REQUIRED | ON_BEFORE_REDIRECT |
177 ON_RESPONSE_STARTED | ON_COMPLETED | ON_ERROR; 175 ON_RESPONSE_STARTED | ON_COMPLETED | ON_ERROR;
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 bool WebRequestConditionAttributeStages::Equals( 874 bool WebRequestConditionAttributeStages::Equals(
877 const WebRequestConditionAttribute* other) const { 875 const WebRequestConditionAttribute* other) const {
878 if (!WebRequestConditionAttribute::Equals(other)) 876 if (!WebRequestConditionAttribute::Equals(other))
879 return false; 877 return false;
880 const WebRequestConditionAttributeStages* casted_other = 878 const WebRequestConditionAttributeStages* casted_other =
881 static_cast<const WebRequestConditionAttributeStages*>(other); 879 static_cast<const WebRequestConditionAttributeStages*>(other);
882 return allowed_stages_ == casted_other->allowed_stages_; 880 return allowed_stages_ == casted_other->allowed_stages_;
883 } 881 }
884 882
885 } // namespace extensions 883 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/webrequest/test_types.js ('k') | extensions/browser/api/web_request/web_request_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698