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

Side by Side Diff: third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/storage/DOMWindowStorage.h" 5 #include "modules/storage/DOMWindowStorage.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/LocalDOMWindow.h" 9 #include "core/frame/LocalDOMWindow.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 Storage* DOMWindowStorage::sessionStorage(ExceptionState& exceptionState) const 66 Storage* DOMWindowStorage::sessionStorage(ExceptionState& exceptionState) const
67 { 67 {
68 if (!m_window->isCurrentlyDisplayedInFrame()) 68 if (!m_window->isCurrentlyDisplayedInFrame())
69 return nullptr; 69 return nullptr;
70 70
71 Document* document = m_window->document(); 71 Document* document = m_window->document();
72 if (!document) 72 if (!document)
73 return nullptr; 73 return nullptr;
74 74
75 String accessDeniedMessage = "Access is denied for this document."; 75 String accessDeniedMessage = "Access is denied for this document.";
76 if (!document->securityOrigin()->canAccessLocalStorage()) { 76 if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
77 if (document->isSandboxed(SandboxOrigin)) 77 if (document->isSandboxed(SandboxOrigin))
78 exceptionState.throwSecurityError("The document is sandboxed and lac ks the 'allow-same-origin' flag."); 78 exceptionState.throwSecurityError("The document is sandboxed and lac ks the 'allow-same-origin' flag.");
79 else if (document->url().protocolIs("data")) 79 else if (document->url().protocolIs("data"))
80 exceptionState.throwSecurityError("Storage is disabled inside 'data: ' URLs."); 80 exceptionState.throwSecurityError("Storage is disabled inside 'data: ' URLs.");
81 else 81 else
82 exceptionState.throwSecurityError(accessDeniedMessage); 82 exceptionState.throwSecurityError(accessDeniedMessage);
83 return nullptr; 83 return nullptr;
84 } 84 }
85 85
86 if (m_sessionStorage) { 86 if (m_sessionStorage) {
87 if (!m_sessionStorage->area()->canAccessStorage(m_window->frame())) { 87 if (!m_sessionStorage->area()->canAccessStorage(m_window->frame())) {
88 exceptionState.throwSecurityError(accessDeniedMessage); 88 exceptionState.throwSecurityError(accessDeniedMessage);
89 return nullptr; 89 return nullptr;
90 } 90 }
91 return m_sessionStorage; 91 return m_sessionStorage;
92 } 92 }
93 93
94 Page* page = document->page(); 94 Page* page = document->page();
95 if (!page) 95 if (!page)
96 return nullptr; 96 return nullptr;
97 97
98 StorageArea* storageArea = StorageNamespaceController::from(page)->sessionSt orage()->storageArea(document->securityOrigin()); 98 StorageArea* storageArea = StorageNamespaceController::from(page)->sessionSt orage()->storageArea(document->getSecurityOrigin());
99 if (!storageArea->canAccessStorage(m_window->frame())) { 99 if (!storageArea->canAccessStorage(m_window->frame())) {
100 exceptionState.throwSecurityError(accessDeniedMessage); 100 exceptionState.throwSecurityError(accessDeniedMessage);
101 return nullptr; 101 return nullptr;
102 } 102 }
103 103
104 m_sessionStorage = Storage::create(m_window->frame(), storageArea); 104 m_sessionStorage = Storage::create(m_window->frame(), storageArea);
105 return m_sessionStorage; 105 return m_sessionStorage;
106 } 106 }
107 107
108 Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const 108 Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const
109 { 109 {
110 if (!m_window->isCurrentlyDisplayedInFrame()) 110 if (!m_window->isCurrentlyDisplayedInFrame())
111 return nullptr; 111 return nullptr;
112 Document* document = m_window->document(); 112 Document* document = m_window->document();
113 if (!document) 113 if (!document)
114 return nullptr; 114 return nullptr;
115 String accessDeniedMessage = "Access is denied for this document."; 115 String accessDeniedMessage = "Access is denied for this document.";
116 if (!document->securityOrigin()->canAccessLocalStorage()) { 116 if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
117 if (document->isSandboxed(SandboxOrigin)) 117 if (document->isSandboxed(SandboxOrigin))
118 exceptionState.throwSecurityError("The document is sandboxed and lac ks the 'allow-same-origin' flag."); 118 exceptionState.throwSecurityError("The document is sandboxed and lac ks the 'allow-same-origin' flag.");
119 else if (document->url().protocolIs("data")) 119 else if (document->url().protocolIs("data"))
120 exceptionState.throwSecurityError("Storage is disabled inside 'data: ' URLs."); 120 exceptionState.throwSecurityError("Storage is disabled inside 'data: ' URLs.");
121 else 121 else
122 exceptionState.throwSecurityError(accessDeniedMessage); 122 exceptionState.throwSecurityError(accessDeniedMessage);
123 return nullptr; 123 return nullptr;
124 } 124 }
125 if (m_localStorage) { 125 if (m_localStorage) {
126 if (!m_localStorage->area()->canAccessStorage(m_window->frame())) { 126 if (!m_localStorage->area()->canAccessStorage(m_window->frame())) {
127 exceptionState.throwSecurityError(accessDeniedMessage); 127 exceptionState.throwSecurityError(accessDeniedMessage);
128 return nullptr; 128 return nullptr;
129 } 129 }
130 return m_localStorage; 130 return m_localStorage;
131 } 131 }
132 // FIXME: Seems this check should be much higher? 132 // FIXME: Seems this check should be much higher?
133 FrameHost* host = document->frameHost(); 133 FrameHost* host = document->frameHost();
134 if (!host || !host->settings().localStorageEnabled()) 134 if (!host || !host->settings().localStorageEnabled())
135 return nullptr; 135 return nullptr;
136 StorageArea* storageArea = StorageNamespace::localStorageArea(document->secu rityOrigin()); 136 StorageArea* storageArea = StorageNamespace::localStorageArea(document->getS ecurityOrigin());
137 if (!storageArea->canAccessStorage(m_window->frame())) { 137 if (!storageArea->canAccessStorage(m_window->frame())) {
138 exceptionState.throwSecurityError(accessDeniedMessage); 138 exceptionState.throwSecurityError(accessDeniedMessage);
139 return nullptr; 139 return nullptr;
140 } 140 }
141 m_localStorage = Storage::create(m_window->frame(), storageArea); 141 m_localStorage = Storage::create(m_window->frame(), storageArea);
142 return m_localStorage; 142 return m_localStorage;
143 } 143 }
144 144
145 } // namespace blink 145 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698