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 const std::vector<std::string>& schemes) { | |
58 return std::find(schemes.begin(), schemes.end(), scheme) != schemes.end(); | |
59 } | |
60 | |
61 // Returns whether |url| passes some sanity checks and is a valid GURL. | 57 // Returns whether |url| passes some sanity checks and is a valid GURL. |
62 bool CheckURLIsValid(const GURL& url) { | 58 bool CheckURLIsValid(const GURL& url) { |
63 std::vector<std::string> additional_schemes; | 59 std::vector<std::string> additional_schemes; |
64 DCHECK(GetWebClient()->IsAppSpecificURL(url) || | 60 DCHECK(GetWebClient()->IsAppSpecificURL(url) || |
65 (GetWebClient()->GetAdditionalWebUISchemes(&additional_schemes), | 61 (GetWebClient()->GetAdditionalWebUISchemes(&additional_schemes), |
66 SchemeIsInSchemes(url.scheme(), additional_schemes))); | 62 base::ContainsValue(additional_schemes, url.scheme()))); |
67 | 63 |
68 if (!url.is_valid()) { | 64 if (!url.is_valid()) { |
69 NOTREACHED(); | 65 NOTREACHED(); |
70 return false; | 66 return false; |
71 } | 67 } |
72 | 68 |
73 return true; | 69 return true; |
74 } | 70 } |
75 | 71 |
76 // Parse |url| to get the path which will be used to resolve the request. The | 72 // Parse |url| to get the path which will be used to resolve the request. The |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Forward this data on to the pending net::URLRequest, if it exists. | 511 // Forward this data on to the pending net::URLRequest, if it exists. |
516 PendingRequestMap::iterator i = pending_requests_.find(request_id); | 512 PendingRequestMap::iterator i = pending_requests_.find(request_id); |
517 if (i != pending_requests_.end()) { | 513 if (i != pending_requests_.end()) { |
518 URLRequestChromeJob* job(i->second); | 514 URLRequestChromeJob* job(i->second); |
519 pending_requests_.erase(i); | 515 pending_requests_.erase(i); |
520 job->DataAvailable(bytes); | 516 job->DataAvailable(bytes); |
521 } | 517 } |
522 } | 518 } |
523 | 519 |
524 } // namespace web | 520 } // namespace web |
OLD | NEW |