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

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 430193002: Wire 'blink::Platform::isHostnameReservedIPAddress()' to 'net::IsReservedIPAddress()'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/child/blink_platform_impl.h ('k') | content/child/blink_platform_unittest.cc » ('j') | 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/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 #include "content/child/websocket_bridge.h" 35 #include "content/child/websocket_bridge.h"
36 #include "content/child/webthread_impl.h" 36 #include "content/child/webthread_impl.h"
37 #include "content/child/worker_task_runner.h" 37 #include "content/child/worker_task_runner.h"
38 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
39 #include "grit/blink_resources.h" 39 #include "grit/blink_resources.h"
40 #include "grit/webkit_resources.h" 40 #include "grit/webkit_resources.h"
41 #include "grit/webkit_strings.h" 41 #include "grit/webkit_strings.h"
42 #include "net/base/data_url.h" 42 #include "net/base/data_url.h"
43 #include "net/base/mime_util.h" 43 #include "net/base/mime_util.h"
44 #include "net/base/net_errors.h" 44 #include "net/base/net_errors.h"
45 #include "net/base/net_util.h"
45 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" 46 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h"
46 #include "third_party/WebKit/public/platform/WebData.h" 47 #include "third_party/WebKit/public/platform/WebData.h"
47 #include "third_party/WebKit/public/platform/WebString.h" 48 #include "third_party/WebKit/public/platform/WebString.h"
48 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" 49 #include "third_party/WebKit/public/platform/WebWaitableEvent.h"
49 #include "ui/base/layout.h" 50 #include "ui/base/layout.h"
50 51
51 #if defined(OS_ANDROID) 52 #if defined(OS_ANDROID)
52 #include "content/child/fling_animator_impl_android.h" 53 #include "content/child/fling_animator_impl_android.h"
53 #endif 54 #endif
54 55
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 return data; 433 return data;
433 } 434 }
434 return WebData(); 435 return WebData();
435 } 436 }
436 437
437 WebURLError BlinkPlatformImpl::cancelledError( 438 WebURLError BlinkPlatformImpl::cancelledError(
438 const WebURL& unreachableURL) const { 439 const WebURL& unreachableURL) const {
439 return WebURLLoaderImpl::CreateError(unreachableURL, false, net::ERR_ABORTED); 440 return WebURLLoaderImpl::CreateError(unreachableURL, false, net::ERR_ABORTED);
440 } 441 }
441 442
443 bool BlinkPlatformImpl::isHostnameReservedIPAddress(
444 const blink::WebString& hostname) const {
445 // CanonicalizeHost requires surrounding brackets to parse an IPv6 address:
446 // these are provided by 'blink::SecurityOrigin::host()', so we don't have to
447 // add them here.
448 std::string host = hostname.utf8();
449 url::CanonHostInfo host_info;
450 std::string canonical_name = net::CanonicalizeHost(host, &host_info);
Ryan Sleevi 2014/08/05 00:01:38 Is there no way to pre-canonicalize? This seems a
Mike West 2014/08/05 07:20:29 That's fair. We're getting the hostname from eithe
451
452 // If it's not an IP address or canonicalization fails, it's not a reserved
453 // IP address.
454 if (canonical_name.empty() || !host_info.IsIPAddress())
455 return false;
456
457 host = host.substr(host_info.out_host.begin, host_info.out_host.len);
Ryan Sleevi 2014/08/05 00:01:38 BUG: host_info.out_host is "location of the host w
Mike West 2014/08/05 07:20:29 I can drop this entirely.
458 if (host_info.family == url::CanonHostInfo::IPV6) {
459 // ParseIPLiteralToNumber requires that IPv6 addresses _not_ have brackets,
460 // so we strip them here. Hooray for consistency.
Ryan Sleevi 2014/08/05 00:01:37 URLs vs not-URLs ;)
Mike West 2014/08/05 07:20:29 Acknowledged.
461 host = host.substr(1, host.size() - 2);
462 }
463
464 net::IPAddressNumber host_addr;
465 if (!net::ParseIPLiteralToNumber(host, &host_addr))
Ryan Sleevi 2014/08/05 00:01:37 If you do find it unavoidable to call this every t
Mike West 2014/08/05 07:20:29 What do you think of the current patchset, which d
466 return false;
467
468 switch (host_info.family) {
469 case url::CanonHostInfo::IPV4:
470 case url::CanonHostInfo::IPV6:
471 return net::IsIPAddressReserved(host_addr);
472 case url::CanonHostInfo::NEUTRAL:
473 case url::CanonHostInfo::BROKEN:
474 return false;
475 }
476 }
477
442 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { 478 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
443 return new WebThreadImpl(name); 479 return new WebThreadImpl(name);
444 } 480 }
445 481
446 blink::WebThread* BlinkPlatformImpl::currentThread() { 482 blink::WebThread* BlinkPlatformImpl::currentThread() {
447 WebThreadImplForMessageLoop* thread = 483 WebThreadImplForMessageLoop* thread =
448 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); 484 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get());
449 if (thread) 485 if (thread)
450 return (thread); 486 return (thread);
451 487
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 } 1169 }
1134 1170
1135 // static 1171 // static
1136 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { 1172 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) {
1137 WebThreadImplForMessageLoop* impl = 1173 WebThreadImplForMessageLoop* impl =
1138 static_cast<WebThreadImplForMessageLoop*>(thread); 1174 static_cast<WebThreadImplForMessageLoop*>(thread);
1139 delete impl; 1175 delete impl;
1140 } 1176 }
1141 1177
1142 } // namespace content 1178 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.h ('k') | content/child/blink_platform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698