OLD | NEW |
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 "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 DCHECK(posted); | 214 DCHECK(posted); |
215 } | 215 } |
216 | 216 |
217 virtual void SetExtraRequestHeaders( | 217 virtual void SetExtraRequestHeaders( |
218 const net::HttpRequestHeaders& headers) OVERRIDE { | 218 const net::HttpRequestHeaders& headers) OVERRIDE { |
219 // TODO(asargent) - we'll need to add proper support for range headers. | 219 // TODO(asargent) - we'll need to add proper support for range headers. |
220 // crbug.com/369895. | 220 // crbug.com/369895. |
221 std::string range_header; | 221 std::string range_header; |
222 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { | 222 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { |
223 if (verify_job_.get()) | 223 if (verify_job_.get()) |
224 verify_job_ = NULL; | 224 verify_job_ = nullptr; |
225 } | 225 } |
226 URLRequestFileJob::SetExtraRequestHeaders(headers); | 226 URLRequestFileJob::SetExtraRequestHeaders(headers); |
227 } | 227 } |
228 | 228 |
229 virtual void OnSeekComplete(int64 result) OVERRIDE { | 229 virtual void OnSeekComplete(int64 result) OVERRIDE { |
230 DCHECK_EQ(seek_position_, 0); | 230 DCHECK_EQ(seek_position_, 0); |
231 seek_position_ = result; | 231 seek_position_ = result; |
232 // TODO(asargent) - we'll need to add proper support for range headers. | 232 // TODO(asargent) - we'll need to add proper support for range headers. |
233 // crbug.com/369895. | 233 // crbug.com/369895. |
234 if (result > 0 && verify_job_.get()) | 234 if (result > 0 && verify_job_.get()) |
235 verify_job_ = NULL; | 235 verify_job_ = nullptr; |
236 } | 236 } |
237 | 237 |
238 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { | 238 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { |
239 if (result >= 0) | 239 if (result >= 0) |
240 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); | 240 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); |
241 else | 241 else |
242 UMA_HISTOGRAM_SPARSE_SLOWLY("ExtensionUrlRequest.OnReadCompleteError", | 242 UMA_HISTOGRAM_SPARSE_SLOWLY("ExtensionUrlRequest.OnReadCompleteError", |
243 -result); | 243 -result); |
244 if (result > 0) { | 244 if (result > 0) { |
245 bytes_read_ += result; | 245 bytes_read_ += result; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 base::FilePath directory_path; | 411 base::FilePath directory_path; |
412 if (extension) | 412 if (extension) |
413 directory_path = extension->path(); | 413 directory_path = extension->path(); |
414 if (directory_path.value().empty()) { | 414 if (directory_path.value().empty()) { |
415 const Extension* disabled_extension = | 415 const Extension* disabled_extension = |
416 extension_info_map_->disabled_extensions().GetByID(extension_id); | 416 extension_info_map_->disabled_extensions().GetByID(extension_id); |
417 if (URLIsForExtensionIcon(request->url(), disabled_extension)) | 417 if (URLIsForExtensionIcon(request->url(), disabled_extension)) |
418 directory_path = disabled_extension->path(); | 418 directory_path = disabled_extension->path(); |
419 if (directory_path.value().empty()) { | 419 if (directory_path.value().empty()) { |
420 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; | 420 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; |
421 return NULL; | 421 return nullptr; |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 // Set up content security policy. | 425 // Set up content security policy. |
426 std::string content_security_policy; | 426 std::string content_security_policy; |
427 bool send_cors_header = false; | 427 bool send_cors_header = false; |
428 bool follow_symlinks_anywhere = false; | 428 bool follow_symlinks_anywhere = false; |
429 | 429 |
430 if (extension) { | 430 if (extension) { |
431 std::string resource_path = request->url().path(); | 431 std::string resource_path = request->url().path(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 499 } |
500 | 500 |
501 if (SharedModuleInfo::ImportsExtensionById(extension, new_extension_id) && | 501 if (SharedModuleInfo::ImportsExtensionById(extension, new_extension_id) && |
502 new_extension && | 502 new_extension && |
503 (first_party_in_import || | 503 (first_party_in_import || |
504 SharedModuleInfo::IsExportAllowed(new_extension, new_relative_path))) { | 504 SharedModuleInfo::IsExportAllowed(new_extension, new_relative_path))) { |
505 directory_path = new_extension->path(); | 505 directory_path = new_extension->path(); |
506 extension_id = new_extension_id; | 506 extension_id = new_extension_id; |
507 relative_path = base::FilePath::FromUTF8Unsafe(new_relative_path); | 507 relative_path = base::FilePath::FromUTF8Unsafe(new_relative_path); |
508 } else { | 508 } else { |
509 return NULL; | 509 return nullptr; |
510 } | 510 } |
511 } | 511 } |
512 ContentVerifyJob* verify_job = NULL; | 512 ContentVerifyJob* verify_job = nullptr; |
513 ContentVerifier* verifier = extension_info_map_->content_verifier(); | 513 ContentVerifier* verifier = extension_info_map_->content_verifier(); |
514 if (verifier) { | 514 if (verifier) { |
515 verify_job = | 515 verify_job = |
516 verifier->CreateJobFor(extension_id, directory_path, relative_path); | 516 verifier->CreateJobFor(extension_id, directory_path, relative_path); |
517 if (verify_job) | 517 if (verify_job) |
518 verify_job->Start(); | 518 verify_job->Start(); |
519 } | 519 } |
520 | 520 |
521 return new URLRequestExtensionJob(request, | 521 return new URLRequestExtensionJob(request, |
522 network_delegate, | 522 network_delegate, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return new net::HttpResponseHeaders(raw_headers); | 569 return new net::HttpResponseHeaders(raw_headers); |
570 } | 570 } |
571 | 571 |
572 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 572 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
573 bool is_incognito, | 573 bool is_incognito, |
574 extensions::InfoMap* extension_info_map) { | 574 extensions::InfoMap* extension_info_map) { |
575 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 575 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
576 } | 576 } |
577 | 577 |
578 } // namespace extensions | 578 } // namespace extensions |
OLD | NEW |