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

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

Issue 2449913002: Support WebSocket in WebRequest API. (Closed)
Patch Set: Fix unittest; add 'websocket' type to WebRequest API. Created 3 years, 10 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return ON_BEFORE_REQUEST | ON_BEFORE_SEND_HEADERS | ON_SEND_HEADERS | 174 return ON_BEFORE_REQUEST | ON_BEFORE_SEND_HEADERS | ON_SEND_HEADERS |
175 ON_HEADERS_RECEIVED | ON_AUTH_REQUIRED | ON_BEFORE_REDIRECT | 175 ON_HEADERS_RECEIVED | ON_AUTH_REQUIRED | ON_BEFORE_REDIRECT |
176 ON_RESPONSE_STARTED | ON_COMPLETED | ON_ERROR; 176 ON_RESPONSE_STARTED | ON_COMPLETED | ON_ERROR;
177 } 177 }
178 178
179 bool WebRequestConditionAttributeResourceType::IsFulfilled( 179 bool WebRequestConditionAttributeResourceType::IsFulfilled(
180 const WebRequestData& request_data) const { 180 const WebRequestData& request_data) const {
181 if (!(request_data.stage & GetStages())) 181 if (!(request_data.stage & GetStages()))
182 return false; 182 return false;
183 183
184 if (request_data.request->url().SchemeIsWSOrWSS()) {
185 return std::find(types_.begin(), types_.end(), ResourceTypeExt(true)) !=
186 types_.end();
187 }
188
184 const content::ResourceRequestInfo* info = 189 const content::ResourceRequestInfo* info =
185 content::ResourceRequestInfo::ForRequest(request_data.request); 190 content::ResourceRequestInfo::ForRequest(request_data.request);
186 return info && 191 return info &&
187 std::find(types_.begin(), types_.end(), 192 std::find(types_.begin(), types_.end(),
188 ResourceTypeExt(info->GetResourceType())) != types_.end(); 193 ResourceTypeExt(info->GetResourceType())) != types_.end();
189 } 194 }
190 195
191 WebRequestConditionAttribute::Type 196 WebRequestConditionAttribute::Type
192 WebRequestConditionAttributeResourceType::GetType() const { 197 WebRequestConditionAttributeResourceType::GetType() const {
193 return CONDITION_RESOURCE_TYPE; 198 return CONDITION_RESOURCE_TYPE;
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 bool WebRequestConditionAttributeStages::Equals( 881 bool WebRequestConditionAttributeStages::Equals(
877 const WebRequestConditionAttribute* other) const { 882 const WebRequestConditionAttribute* other) const {
878 if (!WebRequestConditionAttribute::Equals(other)) 883 if (!WebRequestConditionAttribute::Equals(other))
879 return false; 884 return false;
880 const WebRequestConditionAttributeStages* casted_other = 885 const WebRequestConditionAttributeStages* casted_other =
881 static_cast<const WebRequestConditionAttributeStages*>(other); 886 static_cast<const WebRequestConditionAttributeStages*>(other);
882 return allowed_stages_ == casted_other->allowed_stages_; 887 return allowed_stages_ == casted_other->allowed_stages_;
883 } 888 }
884 889
885 } // namespace extensions 890 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698