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 "mojo/services/html_viewer/blink_platform_impl.h" | 5 #include "mojo/services/html_viewer/blink_platform_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "mojo/services/html_viewer/blink_resource_constants.h" | 15 #include "mojo/services/html_viewer/blink_resource_constants.h" |
16 #include "mojo/services/html_viewer/webthread_impl.h" | 16 #include "mojo/services/html_viewer/webthread_impl.h" |
17 #include "net/base/data_url.h" | 17 #include "net/base/data_url.h" |
18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" |
20 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | 21 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" |
21 | 22 |
22 namespace html_viewer { | 23 namespace html_viewer { |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Allows overriding user agent scring. | 26 // Allows overriding user agent scring. |
26 const char kUserAgentSwitch[] = "user-agent"; | 27 const char kUserAgentSwitch[] = "user-agent"; |
27 | 28 |
28 // TODO(darin): Figure out what our UA should really be. | 29 // TODO(darin): Figure out what our UA should really be. |
29 const char kDefaultUserAgentString[] = | 30 const char kDefaultUserAgentString[] = |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 const { | 203 const { |
203 blink::WebURLError error; | 204 blink::WebURLError error; |
204 error.domain = blink::WebString::fromUTF8(net::kErrorDomain); | 205 error.domain = blink::WebString::fromUTF8(net::kErrorDomain); |
205 error.reason = net::ERR_ABORTED; | 206 error.reason = net::ERR_ABORTED; |
206 error.unreachableURL = url; | 207 error.unreachableURL = url; |
207 error.staleCopyInCache = false; | 208 error.staleCopyInCache = false; |
208 error.isCancellation = true; | 209 error.isCancellation = true; |
209 return error; | 210 return error; |
210 } | 211 } |
211 | 212 |
| 213 bool BlinkPlatformImpl::isReservedIPAddress( |
| 214 const blink::WebString& host) const { |
| 215 net::IPAddressNumber address; |
| 216 if (!net::ParseURLHostnameToNumber(host.utf8(), &address)) |
| 217 return false; |
| 218 return net::IsIPAddressReserved(address); |
| 219 } |
| 220 |
212 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { | 221 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { |
213 return new WebThreadImpl(name); | 222 return new WebThreadImpl(name); |
214 } | 223 } |
215 | 224 |
216 blink::WebThread* BlinkPlatformImpl::currentThread() { | 225 blink::WebThread* BlinkPlatformImpl::currentThread() { |
217 WebThreadImplForMessageLoop* thread = | 226 WebThreadImplForMessageLoop* thread = |
218 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); | 227 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); |
219 if (thread) | 228 if (thread) |
220 return (thread); | 229 return (thread); |
221 | 230 |
(...skipping 27 matching lines...) Expand all Loading... |
249 } | 258 } |
250 | 259 |
251 // static | 260 // static |
252 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 261 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
253 WebThreadImplForMessageLoop* impl = | 262 WebThreadImplForMessageLoop* impl = |
254 static_cast<WebThreadImplForMessageLoop*>(thread); | 263 static_cast<WebThreadImplForMessageLoop*>(thread); |
255 delete impl; | 264 delete impl; |
256 } | 265 } |
257 | 266 |
258 } // namespace html_viewer | 267 } // namespace html_viewer |
OLD | NEW |