| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 742 |
| 743 Location* DOMWindow::location() const | 743 Location* DOMWindow::location() const |
| 744 { | 744 { |
| 745 if (!isCurrentlyDisplayedInFrame()) | 745 if (!isCurrentlyDisplayedInFrame()) |
| 746 return 0; | 746 return 0; |
| 747 if (!m_location) | 747 if (!m_location) |
| 748 m_location = Location::create(m_frame); | 748 m_location = Location::create(m_frame); |
| 749 return m_location.get(); | 749 return m_location.get(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 Storage* DOMWindow::sessionStorage(ExceptionState& es) const | 752 Storage* DOMWindow::sessionStorage(ExceptionState& exceptionState) const |
| 753 { | 753 { |
| 754 if (!isCurrentlyDisplayedInFrame()) | 754 if (!isCurrentlyDisplayedInFrame()) |
| 755 return 0; | 755 return 0; |
| 756 | 756 |
| 757 Document* document = this->document(); | 757 Document* document = this->document(); |
| 758 if (!document) | 758 if (!document) |
| 759 return 0; | 759 return 0; |
| 760 | 760 |
| 761 String accessDeniedMessage = "Access to 'sessionStorage' is denied for this
document."; | 761 String accessDeniedMessage = "Access to 'sessionStorage' is denied for this
document."; |
| 762 if (!document->securityOrigin()->canAccessLocalStorage()) { | 762 if (!document->securityOrigin()->canAccessLocalStorage()) { |
| 763 if (document->isSandboxed(SandboxOrigin)) | 763 if (document->isSandboxed(SandboxOrigin)) |
| 764 es.throwSecurityError(accessDeniedMessage + " The document is sandbo
xed and lacks the 'allow-same-origin' flag."); | 764 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); |
| 765 else if (document->url().protocolIs("data")) | 765 else if (document->url().protocolIs("data")) |
| 766 es.throwSecurityError(accessDeniedMessage + " Storage is disabled in
side 'data:' URLs."); | 766 exceptionState.throwSecurityError(accessDeniedMessage + " Storage is
disabled inside 'data:' URLs."); |
| 767 else | 767 else |
| 768 es.throwSecurityError(accessDeniedMessage); | 768 exceptionState.throwSecurityError(accessDeniedMessage); |
| 769 return 0; | 769 return 0; |
| 770 } | 770 } |
| 771 | 771 |
| 772 if (m_sessionStorage) { | 772 if (m_sessionStorage) { |
| 773 if (!m_sessionStorage->area()->canAccessStorage(m_frame)) { | 773 if (!m_sessionStorage->area()->canAccessStorage(m_frame)) { |
| 774 es.throwSecurityError(accessDeniedMessage); | 774 exceptionState.throwSecurityError(accessDeniedMessage); |
| 775 return 0; | 775 return 0; |
| 776 } | 776 } |
| 777 return m_sessionStorage.get(); | 777 return m_sessionStorage.get(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 Page* page = document->page(); | 780 Page* page = document->page(); |
| 781 if (!page) | 781 if (!page) |
| 782 return 0; | 782 return 0; |
| 783 | 783 |
| 784 OwnPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); | 784 OwnPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); |
| 785 if (!storageArea->canAccessStorage(m_frame)) { | 785 if (!storageArea->canAccessStorage(m_frame)) { |
| 786 es.throwSecurityError(accessDeniedMessage); | 786 exceptionState.throwSecurityError(accessDeniedMessage); |
| 787 return 0; | 787 return 0; |
| 788 } | 788 } |
| 789 | 789 |
| 790 m_sessionStorage = Storage::create(m_frame, storageArea.release()); | 790 m_sessionStorage = Storage::create(m_frame, storageArea.release()); |
| 791 return m_sessionStorage.get(); | 791 return m_sessionStorage.get(); |
| 792 } | 792 } |
| 793 | 793 |
| 794 Storage* DOMWindow::localStorage(ExceptionState& es) const | 794 Storage* DOMWindow::localStorage(ExceptionState& exceptionState) const |
| 795 { | 795 { |
| 796 if (!isCurrentlyDisplayedInFrame()) | 796 if (!isCurrentlyDisplayedInFrame()) |
| 797 return 0; | 797 return 0; |
| 798 | 798 |
| 799 Document* document = this->document(); | 799 Document* document = this->document(); |
| 800 if (!document) | 800 if (!document) |
| 801 return 0; | 801 return 0; |
| 802 | 802 |
| 803 String accessDeniedMessage = "Access to 'localStorage' is denied for this do
cument."; | 803 String accessDeniedMessage = "Access to 'localStorage' is denied for this do
cument."; |
| 804 if (!document->securityOrigin()->canAccessLocalStorage()) { | 804 if (!document->securityOrigin()->canAccessLocalStorage()) { |
| 805 if (document->isSandboxed(SandboxOrigin)) | 805 if (document->isSandboxed(SandboxOrigin)) |
| 806 es.throwSecurityError(accessDeniedMessage + " The document is sandbo
xed and lacks the 'allow-same-origin' flag."); | 806 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); |
| 807 else if (document->url().protocolIs("data")) | 807 else if (document->url().protocolIs("data")) |
| 808 es.throwSecurityError(accessDeniedMessage + " Storage is disabled in
side 'data:' URLs."); | 808 exceptionState.throwSecurityError(accessDeniedMessage + " Storage is
disabled inside 'data:' URLs."); |
| 809 else | 809 else |
| 810 es.throwSecurityError(accessDeniedMessage); | 810 exceptionState.throwSecurityError(accessDeniedMessage); |
| 811 return 0; | 811 return 0; |
| 812 } | 812 } |
| 813 | 813 |
| 814 if (m_localStorage) { | 814 if (m_localStorage) { |
| 815 if (!m_localStorage->area()->canAccessStorage(m_frame)) { | 815 if (!m_localStorage->area()->canAccessStorage(m_frame)) { |
| 816 es.throwSecurityError(accessDeniedMessage); | 816 exceptionState.throwSecurityError(accessDeniedMessage); |
| 817 return 0; | 817 return 0; |
| 818 } | 818 } |
| 819 return m_localStorage.get(); | 819 return m_localStorage.get(); |
| 820 } | 820 } |
| 821 | 821 |
| 822 Page* page = document->page(); | 822 Page* page = document->page(); |
| 823 if (!page) | 823 if (!page) |
| 824 return 0; | 824 return 0; |
| 825 | 825 |
| 826 if (!page->settings().localStorageEnabled()) | 826 if (!page->settings().localStorageEnabled()) |
| 827 return 0; | 827 return 0; |
| 828 | 828 |
| 829 OwnPtr<StorageArea> storageArea = StorageNamespace::localStorageArea(documen
t->securityOrigin()); | 829 OwnPtr<StorageArea> storageArea = StorageNamespace::localStorageArea(documen
t->securityOrigin()); |
| 830 if (!storageArea->canAccessStorage(m_frame)) { | 830 if (!storageArea->canAccessStorage(m_frame)) { |
| 831 es.throwSecurityError(accessDeniedMessage); | 831 exceptionState.throwSecurityError(accessDeniedMessage); |
| 832 return 0; | 832 return 0; |
| 833 } | 833 } |
| 834 | 834 |
| 835 m_localStorage = Storage::create(m_frame, storageArea.release()); | 835 m_localStorage = Storage::create(m_frame, storageArea.release()); |
| 836 return m_localStorage.get(); | 836 return m_localStorage.get(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionSt
ate& es) | 839 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionSt
ate& exceptionState) |
| 840 { | 840 { |
| 841 if (!isCurrentlyDisplayedInFrame()) | 841 if (!isCurrentlyDisplayedInFrame()) |
| 842 return; | 842 return; |
| 843 | 843 |
| 844 Document* sourceDocument = source->document(); | 844 Document* sourceDocument = source->document(); |
| 845 | 845 |
| 846 // Compute the target origin. We need to do this synchronously in order | 846 // Compute the target origin. We need to do this synchronously in order |
| 847 // to generate the SyntaxError exception correctly. | 847 // to generate the SyntaxError exception correctly. |
| 848 RefPtr<SecurityOrigin> target; | 848 RefPtr<SecurityOrigin> target; |
| 849 if (targetOrigin == "/") { | 849 if (targetOrigin == "/") { |
| 850 if (!sourceDocument) | 850 if (!sourceDocument) |
| 851 return; | 851 return; |
| 852 target = sourceDocument->securityOrigin(); | 852 target = sourceDocument->securityOrigin(); |
| 853 } else if (targetOrigin != "*") { | 853 } else if (targetOrigin != "*") { |
| 854 target = SecurityOrigin::createFromString(targetOrigin); | 854 target = SecurityOrigin::createFromString(targetOrigin); |
| 855 // It doesn't make sense target a postMessage at a unique origin | 855 // It doesn't make sense target a postMessage at a unique origin |
| 856 // because there's no way to represent a unique origin in a string. | 856 // because there's no way to represent a unique origin in a string. |
| 857 if (target->isUnique()) { | 857 if (target->isUnique()) { |
| 858 es.throwDOMException(SyntaxError, "Invalid target origin '" + target
Origin + "' in a call to 'postMessage'."); | 858 exceptionState.throwDOMException(SyntaxError, "Invalid target origin
'" + targetOrigin + "' in a call to 'postMessage'."); |
| 859 return; | 859 return; |
| 860 } | 860 } |
| 861 } | 861 } |
| 862 | 862 |
| 863 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por
ts, es); | 863 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por
ts, exceptionState); |
| 864 if (es.hadException()) | 864 if (exceptionState.hadException()) |
| 865 return; | 865 return; |
| 866 | 866 |
| 867 // Capture the source of the message. We need to do this synchronously | 867 // Capture the source of the message. We need to do this synchronously |
| 868 // in order to capture the source of the message correctly. | 868 // in order to capture the source of the message correctly. |
| 869 if (!sourceDocument) | 869 if (!sourceDocument) |
| 870 return; | 870 return; |
| 871 String sourceOrigin = sourceDocument->securityOrigin()->toString(); | 871 String sourceOrigin = sourceDocument->securityOrigin()->toString(); |
| 872 | 872 |
| 873 // Capture stack trace only when inspector front-end is loaded as it may be
time consuming. | 873 // Capture stack trace only when inspector front-end is loaded as it may be
time consuming. |
| 874 RefPtr<ScriptCallStack> stackTrace; | 874 RefPtr<ScriptCallStack> stackTrace; |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext::lifecycleN
otifier()); | 1868 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext::lifecycleN
otifier()); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() | 1871 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() |
| 1872 { | 1872 { |
| 1873 return DOMWindowLifecycleNotifier::create(this); | 1873 return DOMWindowLifecycleNotifier::create(this); |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 | 1876 |
| 1877 } // namespace WebCore | 1877 } // namespace WebCore |
| OLD | NEW |