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

Side by Side Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 598453004: Replace some hard coded schemes with the constants in /url/url_constants.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address the comment. Created 6 years, 3 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
« no previous file with comments | « content/renderer/savable_resources.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/shell/renderer/test_runner/web_test_proxy.h" 5 #include "content/shell/renderer/test_runner/web_test_proxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 delegate->PrintMessage("(null)"); 142 delegate->PrintMessage("(null)");
143 return; 143 return;
144 } 144 }
145 delegate->PrintMessage(base::StringPrintf( 145 delegate->PrintMessage(base::StringPrintf(
146 "<NSURLResponse %s, http status code %d>", 146 "<NSURLResponse %s, http status code %d>",
147 DescriptionSuitableForTestResult(response.url().spec()).c_str(), 147 DescriptionSuitableForTestResult(response.url().spec()).c_str(),
148 response.httpStatusCode())); 148 response.httpStatusCode()));
149 } 149 }
150 150
151 std::string URLDescription(const GURL& url) { 151 std::string URLDescription(const GURL& url) {
152 if (url.SchemeIs("file")) 152 if (url.SchemeIs(url::kFileScheme))
153 return url.ExtractFileName(); 153 return url.ExtractFileName();
154 return url.possibly_invalid_spec(); 154 return url.possibly_invalid_spec();
155 } 155 }
156 156
157 std::string PriorityDescription( 157 std::string PriorityDescription(
158 const blink::WebURLRequest::Priority& priority) { 158 const blink::WebURLRequest::Priority& priority) {
159 switch (priority) { 159 switch (priority) {
160 case blink::WebURLRequest::PriorityVeryLow: 160 case blink::WebURLRequest::PriorityVeryLow:
161 return "VeryLow"; 161 return "VeryLow";
162 case blink::WebURLRequest::PriorityLow: 162 case blink::WebURLRequest::PriorityLow:
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 if (test_interfaces_->GetTestRunner()->httpHeadersToClear()) { 1151 if (test_interfaces_->GetTestRunner()->httpHeadersToClear()) {
1152 const std::set<std::string>* clearHeaders = 1152 const std::set<std::string>* clearHeaders =
1153 test_interfaces_->GetTestRunner()->httpHeadersToClear(); 1153 test_interfaces_->GetTestRunner()->httpHeadersToClear();
1154 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); 1154 for (std::set<std::string>::const_iterator header = clearHeaders->begin();
1155 header != clearHeaders->end(); 1155 header != clearHeaders->end();
1156 ++header) 1156 ++header)
1157 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); 1157 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header));
1158 } 1158 }
1159 1159
1160 std::string host = url.host(); 1160 std::string host = url.host();
1161 if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { 1161 if (!host.empty() &&
1162 (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))) {
1162 if (!IsLocalHost(host) && !IsTestHost(host) && 1163 if (!IsLocalHost(host) && !IsTestHost(host) &&
1163 !HostIsUsedBySomeTestsToGenerateError(host) && 1164 !HostIsUsedBySomeTestsToGenerateError(host) &&
1164 ((!main_document_url.SchemeIs("http") && 1165 ((!main_document_url.SchemeIs(url::kHttpScheme) &&
1165 !main_document_url.SchemeIs("https")) || 1166 !main_document_url.SchemeIs(url::kHttpsScheme)) ||
1166 IsLocalHost(main_document_url.host())) && 1167 IsLocalHost(main_document_url.host())) &&
1167 !delegate_->AllowExternalPages()) { 1168 !delegate_->AllowExternalPages()) {
1168 delegate_->PrintMessage(std::string("Blocked access to external URL ") + 1169 delegate_->PrintMessage(std::string("Blocked access to external URL ") +
1169 request_url + "\n"); 1170 request_url + "\n");
1170 BlockRequest(request); 1171 BlockRequest(request);
1171 return; 1172 return;
1172 } 1173 }
1173 } 1174 }
1174 1175
1175 // Set the new substituted URL. 1176 // Set the new substituted URL.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 if (!push_client_.get()) 1354 if (!push_client_.get())
1354 push_client_.reset(new MockWebPushClient); 1355 push_client_.reset(new MockWebPushClient);
1355 return push_client_.get(); 1356 return push_client_.get();
1356 } 1357 }
1357 1358
1358 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { 1359 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() {
1359 return GetPushClientMock(); 1360 return GetPushClientMock();
1360 } 1361 }
1361 1362
1362 } // namespace content 1363 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/savable_resources.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698