Chromium Code Reviews| 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 "ios/web/webui/url_data_manager_ios_backend.h" | 5 #include "ios/web/webui/url_data_manager_ios_backend.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" | |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
| 24 #include "ios/web/public/browser_state.h" | 25 #include "ios/web/public/browser_state.h" |
| 25 #import "ios/web/public/web_client.h" | 26 #import "ios/web/public/web_client.h" |
| 26 #include "ios/web/public/web_thread.h" | 27 #include "ios/web/public/web_thread.h" |
| 27 #include "ios/web/webui/shared_resources_data_source_ios.h" | 28 #include "ios/web/webui/shared_resources_data_source_ios.h" |
| 28 #include "ios/web/webui/url_data_source_ios_impl.h" | 29 #include "ios/web/webui/url_data_source_ios_impl.h" |
| 29 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
| 30 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed. | 50 // TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed. |
| 50 const char kChromeURLContentSecurityPolicyHeaderBase[] = | 51 const char kChromeURLContentSecurityPolicyHeaderBase[] = |
| 51 "Content-Security-Policy: script-src chrome://resources " | 52 "Content-Security-Policy: script-src chrome://resources " |
| 52 "'self' 'unsafe-eval'; "; | 53 "'self' 'unsafe-eval'; "; |
| 53 | 54 |
| 54 const char kChromeURLXFrameOptionsHeader[] = "X-Frame-Options: DENY"; | 55 const char kChromeURLXFrameOptionsHeader[] = "X-Frame-Options: DENY"; |
| 55 | 56 |
| 56 bool SchemeIsInSchemes(const std::string& scheme, | 57 bool SchemeIsInSchemes(const std::string& scheme, |
|
sdefresne
2017/06/23 14:31:21
ditto, just inline base::ContainsValue in the one
Tripta
2017/06/27 06:41:28
Done.
| |
| 57 const std::vector<std::string>& schemes) { | 58 const std::vector<std::string>& schemes) { |
| 58 return std::find(schemes.begin(), schemes.end(), scheme) != schemes.end(); | 59 return base::ContainsValue(schemes, scheme); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // Returns whether |url| passes some sanity checks and is a valid GURL. | 62 // Returns whether |url| passes some sanity checks and is a valid GURL. |
| 62 bool CheckURLIsValid(const GURL& url) { | 63 bool CheckURLIsValid(const GURL& url) { |
| 63 std::vector<std::string> additional_schemes; | 64 std::vector<std::string> additional_schemes; |
| 64 DCHECK(GetWebClient()->IsAppSpecificURL(url) || | 65 DCHECK(GetWebClient()->IsAppSpecificURL(url) || |
| 65 (GetWebClient()->GetAdditionalWebUISchemes(&additional_schemes), | 66 (GetWebClient()->GetAdditionalWebUISchemes(&additional_schemes), |
| 66 SchemeIsInSchemes(url.scheme(), additional_schemes))); | 67 SchemeIsInSchemes(url.scheme(), additional_schemes))); |
| 67 | 68 |
| 68 if (!url.is_valid()) { | 69 if (!url.is_valid()) { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 // Forward this data on to the pending net::URLRequest, if it exists. | 516 // Forward this data on to the pending net::URLRequest, if it exists. |
| 516 PendingRequestMap::iterator i = pending_requests_.find(request_id); | 517 PendingRequestMap::iterator i = pending_requests_.find(request_id); |
| 517 if (i != pending_requests_.end()) { | 518 if (i != pending_requests_.end()) { |
| 518 URLRequestChromeJob* job(i->second); | 519 URLRequestChromeJob* job(i->second); |
| 519 pending_requests_.erase(i); | 520 pending_requests_.erase(i); |
| 520 job->DataAvailable(bytes); | 521 job->DataAvailable(bytes); |
| 521 } | 522 } |
| 522 } | 523 } |
| 523 | 524 |
| 524 } // namespace web | 525 } // namespace web |
| OLD | NEW |