| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 bool KURL::isValid() const { | 300 bool KURL::isValid() const { |
| 301 return m_isValid; | 301 return m_isValid; |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool KURL::hasPort() const { | 304 bool KURL::hasPort() const { |
| 305 return hostEnd() < pathStart(); | 305 return hostEnd() < pathStart(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool KURL::protocolIsJavaScript() const { |
| 309 return componentStringView(m_parsed.scheme) == "javascript"; |
| 310 } |
| 311 |
| 308 bool KURL::protocolIsInHTTPFamily() const { | 312 bool KURL::protocolIsInHTTPFamily() const { |
| 309 return m_protocolIsInHTTPFamily; | 313 return m_protocolIsInHTTPFamily; |
| 310 } | 314 } |
| 311 | 315 |
| 312 bool KURL::hasPath() const { | 316 bool KURL::hasPath() const { |
| 313 // Note that http://www.google.com/" has a path, the path is "/". This can | 317 // Note that http://www.google.com/" has a path, the path is "/". This can |
| 314 // return false only for invalid or nonstandard URLs. | 318 // return false only for invalid or nonstandard URLs. |
| 315 return m_parsed.path.len >= 0; | 319 return m_parsed.path.len >= 0; |
| 316 } | 320 } |
| 317 | 321 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 if (!relative.isNull() && relative.impl()->isAtomic() && | 775 if (!relative.isNull() && relative.impl()->isAtomic() && |
| 772 StringView(output.data(), static_cast<unsigned>(output.length())) == | 776 StringView(output.data(), static_cast<unsigned>(output.length())) == |
| 773 relative) { | 777 relative) { |
| 774 m_string = relative; | 778 m_string = relative; |
| 775 } else { | 779 } else { |
| 776 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 780 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
| 777 } | 781 } |
| 778 | 782 |
| 779 initProtocolMetadata(); | 783 initProtocolMetadata(); |
| 780 initInnerURL(); | 784 initInnerURL(); |
| 785 DCHECK(!::blink::protocolIsJavaScript(m_string) || protocolIsJavaScript()); |
| 781 } | 786 } |
| 782 | 787 |
| 783 void KURL::initInnerURL() { | 788 void KURL::initInnerURL() { |
| 784 if (!m_isValid) { | 789 if (!m_isValid) { |
| 785 m_innerURL.reset(); | 790 m_innerURL.reset(); |
| 786 return; | 791 return; |
| 787 } | 792 } |
| 788 if (url::Parsed* innerParsed = m_parsed.inner_parsed()) | 793 if (url::Parsed* innerParsed = m_parsed.inner_parsed()) |
| 789 m_innerURL = WTF::wrapUnique(new KURL( | 794 m_innerURL = WTF::wrapUnique(new KURL( |
| 790 ParsedURLString, | 795 ParsedURLString, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 821 | 826 |
| 822 // JavaScript URLs are "valid" and should be executed even if KURL decides | 827 // JavaScript URLs are "valid" and should be executed even if KURL decides |
| 823 // they are invalid. The free function protocolIsJavaScript() should be used | 828 // they are invalid. The free function protocolIsJavaScript() should be used |
| 824 // instead. | 829 // instead. |
| 825 // FIXME: Chromium code needs to be fixed for this assert to be enabled. | 830 // FIXME: Chromium code needs to be fixed for this assert to be enabled. |
| 826 // ASSERT(strcmp(protocol, "javascript")); | 831 // ASSERT(strcmp(protocol, "javascript")); |
| 827 return m_protocol == protocol; | 832 return m_protocol == protocol; |
| 828 } | 833 } |
| 829 | 834 |
| 830 StringView KURL::stringViewForInvalidComponent() const { | 835 StringView KURL::stringViewForInvalidComponent() const { |
| 831 return m_string.isNull() ? StringView() : StringView("", 0); | 836 return m_string.isNull() ? StringView() : StringView(StringImpl::empty()); |
| 832 } | 837 } |
| 833 | 838 |
| 834 StringView KURL::componentStringView(const url::Component& component) const { | 839 StringView KURL::componentStringView(const url::Component& component) const { |
| 835 if (!m_isValid || component.len <= 0) | 840 if (!m_isValid || component.len <= 0) |
| 836 return stringViewForInvalidComponent(); | 841 return stringViewForInvalidComponent(); |
| 837 // begin and len are in terms of bytes which do not match | 842 // begin and len are in terms of bytes which do not match |
| 838 // if string() is UTF-16 and input contains non-ASCII characters. | 843 // if string() is UTF-16 and input contains non-ASCII characters. |
| 839 // However, the only part in urlString that can contain non-ASCII | 844 // However, the only part in urlString that can contain non-ASCII |
| 840 // characters is 'ref' at the end of the string. In that case, | 845 // characters is 'ref' at the end of the string. In that case, |
| 841 // begin will always match the actual value and len (in terms of | 846 // begin will always match the actual value and len (in terms of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 865 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 870 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
| 866 initProtocolMetadata(); | 871 initProtocolMetadata(); |
| 867 } | 872 } |
| 868 | 873 |
| 869 bool KURL::isSafeToSendToAnotherThread() const { | 874 bool KURL::isSafeToSendToAnotherThread() const { |
| 870 return m_string.isSafeToSendToAnotherThread() && | 875 return m_string.isSafeToSendToAnotherThread() && |
| 871 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); | 876 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); |
| 872 } | 877 } |
| 873 | 878 |
| 874 } // namespace blink | 879 } // namespace blink |
| OLD | NEW |