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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const | 633 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const |
634 { | 634 { |
635 if (!isCurrentlyDisplayedInFrame()) | 635 if (!isCurrentlyDisplayedInFrame()) |
636 return 0; | 636 return 0; |
637 | 637 |
638 Document* document = this->document(); | 638 Document* document = this->document(); |
639 if (!document) | 639 if (!document) |
640 return 0; | 640 return 0; |
641 | 641 |
642 if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin()
)) { | 642 if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin()
)) { |
643 ec = SECURITY_ERR; | 643 ec = SecurityError; |
644 return 0; | 644 return 0; |
645 } | 645 } |
646 | 646 |
647 if (m_sessionStorage) { | 647 if (m_sessionStorage) { |
648 if (!m_sessionStorage->area()->canAccessStorage(m_frame)) { | 648 if (!m_sessionStorage->area()->canAccessStorage(m_frame)) { |
649 ec = SECURITY_ERR; | 649 ec = SecurityError; |
650 return 0; | 650 return 0; |
651 } | 651 } |
652 return m_sessionStorage.get(); | 652 return m_sessionStorage.get(); |
653 } | 653 } |
654 | 654 |
655 Page* page = document->page(); | 655 Page* page = document->page(); |
656 if (!page) | 656 if (!page) |
657 return 0; | 657 return 0; |
658 | 658 |
659 OwnPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); | 659 OwnPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(docume
nt->securityOrigin()); |
660 if (!storageArea->canAccessStorage(m_frame)) { | 660 if (!storageArea->canAccessStorage(m_frame)) { |
661 ec = SECURITY_ERR; | 661 ec = SecurityError; |
662 return 0; | 662 return 0; |
663 } | 663 } |
664 | 664 |
665 m_sessionStorage = Storage::create(m_frame, storageArea.release()); | 665 m_sessionStorage = Storage::create(m_frame, storageArea.release()); |
666 return m_sessionStorage.get(); | 666 return m_sessionStorage.get(); |
667 } | 667 } |
668 | 668 |
669 Storage* DOMWindow::localStorage(ExceptionCode& ec) const | 669 Storage* DOMWindow::localStorage(ExceptionCode& ec) const |
670 { | 670 { |
671 if (!isCurrentlyDisplayedInFrame()) | 671 if (!isCurrentlyDisplayedInFrame()) |
672 return 0; | 672 return 0; |
673 | 673 |
674 Document* document = this->document(); | 674 Document* document = this->document(); |
675 if (!document) | 675 if (!document) |
676 return 0; | 676 return 0; |
677 | 677 |
678 if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin()
)) { | 678 if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin()
)) { |
679 ec = SECURITY_ERR; | 679 ec = SecurityError; |
680 return 0; | 680 return 0; |
681 } | 681 } |
682 | 682 |
683 if (m_localStorage) { | 683 if (m_localStorage) { |
684 if (!m_localStorage->area()->canAccessStorage(m_frame)) { | 684 if (!m_localStorage->area()->canAccessStorage(m_frame)) { |
685 ec = SECURITY_ERR; | 685 ec = SecurityError; |
686 return 0; | 686 return 0; |
687 } | 687 } |
688 return m_localStorage.get(); | 688 return m_localStorage.get(); |
689 } | 689 } |
690 | 690 |
691 Page* page = document->page(); | 691 Page* page = document->page(); |
692 if (!page) | 692 if (!page) |
693 return 0; | 693 return 0; |
694 | 694 |
695 if (!page->settings()->localStorageEnabled()) | 695 if (!page->settings()->localStorageEnabled()) |
696 return 0; | 696 return 0; |
697 | 697 |
698 OwnPtr<StorageArea> storageArea = StorageNamespace::localStorageArea(documen
t->securityOrigin()); | 698 OwnPtr<StorageArea> storageArea = StorageNamespace::localStorageArea(documen
t->securityOrigin()); |
699 if (!storageArea->canAccessStorage(m_frame)) { | 699 if (!storageArea->canAccessStorage(m_frame)) { |
700 ec = SECURITY_ERR; | 700 ec = SecurityError; |
701 return 0; | 701 return 0; |
702 } | 702 } |
703 | 703 |
704 m_localStorage = Storage::create(m_frame, storageArea.release()); | 704 m_localStorage = Storage::create(m_frame, storageArea.release()); |
705 return m_localStorage.get(); | 705 return m_localStorage.get(); |
706 } | 706 } |
707 | 707 |
708 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCo
de& ec) | 708 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
sagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCo
de& ec) |
709 { | 709 { |
710 if (!isCurrentlyDisplayedInFrame()) | 710 if (!isCurrentlyDisplayedInFrame()) |
711 return; | 711 return; |
712 | 712 |
713 Document* sourceDocument = source->document(); | 713 Document* sourceDocument = source->document(); |
714 | 714 |
715 // Compute the target origin. We need to do this synchronously in order | 715 // Compute the target origin. We need to do this synchronously in order |
716 // to generate the SYNTAX_ERR exception correctly. | 716 // to generate the SyntaxError exception correctly. |
717 RefPtr<SecurityOrigin> target; | 717 RefPtr<SecurityOrigin> target; |
718 if (targetOrigin == "/") { | 718 if (targetOrigin == "/") { |
719 if (!sourceDocument) | 719 if (!sourceDocument) |
720 return; | 720 return; |
721 target = sourceDocument->securityOrigin(); | 721 target = sourceDocument->securityOrigin(); |
722 } else if (targetOrigin != "*") { | 722 } else if (targetOrigin != "*") { |
723 target = SecurityOrigin::createFromString(targetOrigin); | 723 target = SecurityOrigin::createFromString(targetOrigin); |
724 // It doesn't make sense target a postMessage at a unique origin | 724 // It doesn't make sense target a postMessage at a unique origin |
725 // because there's no way to represent a unique origin in a string. | 725 // because there's no way to represent a unique origin in a string. |
726 if (target->isUnique()) { | 726 if (target->isUnique()) { |
727 ec = SYNTAX_ERR; | 727 ec = SyntaxError; |
728 return; | 728 return; |
729 } | 729 } |
730 } | 730 } |
731 | 731 |
732 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por
ts, ec); | 732 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por
ts, ec); |
733 if (ec) | 733 if (ec) |
734 return; | 734 return; |
735 | 735 |
736 // Capture the source of the message. We need to do this synchronously | 736 // Capture the source of the message. We need to do this synchronously |
737 // in order to capture the source of the message correctly. | 737 // in order to capture the source of the message correctly. |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 | 1801 |
1802 Frame* child = frame->tree()->scopedChild(index); | 1802 Frame* child = frame->tree()->scopedChild(index); |
1803 if (child) | 1803 if (child) |
1804 return child->document()->domWindow(); | 1804 return child->document()->domWindow(); |
1805 | 1805 |
1806 return 0; | 1806 return 0; |
1807 } | 1807 } |
1808 | 1808 |
1809 | 1809 |
1810 } // namespace WebCore | 1810 } // namespace WebCore |
OLD | NEW |