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

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

Issue 2630703002: Rename Supplement::host() to Supplement::supplementable() (Closed)
Patch Set: temp Created 3 years, 11 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 // static 51 // static
52 Storage* DOMWindowStorage::localStorage(DOMWindow& window, 52 Storage* DOMWindowStorage::localStorage(DOMWindow& window,
53 ExceptionState& exceptionState) { 53 ExceptionState& exceptionState) {
54 return from(toLocalDOMWindow(window)).localStorage(exceptionState); 54 return from(toLocalDOMWindow(window)).localStorage(exceptionState);
55 } 55 }
56 56
57 Storage* DOMWindowStorage::sessionStorage( 57 Storage* DOMWindowStorage::sessionStorage(
58 ExceptionState& exceptionState) const { 58 ExceptionState& exceptionState) const {
59 if (!host()->frame()) 59 if (!supplementable()->frame())
60 return nullptr; 60 return nullptr;
61 61
62 Document* document = host()->frame()->document(); 62 Document* document = supplementable()->frame()->document();
63 DCHECK(document); 63 DCHECK(document);
64 String accessDeniedMessage = "Access is denied for this document."; 64 String accessDeniedMessage = "Access is denied for this document.";
65 if (!document->getSecurityOrigin()->canAccessLocalStorage()) { 65 if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
66 if (document->isSandboxed(SandboxOrigin)) 66 if (document->isSandboxed(SandboxOrigin))
67 exceptionState.throwSecurityError( 67 exceptionState.throwSecurityError(
68 "The document is sandboxed and lacks the 'allow-same-origin' flag."); 68 "The document is sandboxed and lacks the 'allow-same-origin' flag.");
69 else if (document->url().protocolIs("data")) 69 else if (document->url().protocolIs("data"))
70 exceptionState.throwSecurityError( 70 exceptionState.throwSecurityError(
71 "Storage is disabled inside 'data:' URLs."); 71 "Storage is disabled inside 'data:' URLs.");
72 else 72 else
(...skipping 19 matching lines...) Expand all
92 if (!storageArea->canAccessStorage(document->frame())) { 92 if (!storageArea->canAccessStorage(document->frame())) {
93 exceptionState.throwSecurityError(accessDeniedMessage); 93 exceptionState.throwSecurityError(accessDeniedMessage);
94 return nullptr; 94 return nullptr;
95 } 95 }
96 96
97 m_sessionStorage = Storage::create(document->frame(), storageArea); 97 m_sessionStorage = Storage::create(document->frame(), storageArea);
98 return m_sessionStorage; 98 return m_sessionStorage;
99 } 99 }
100 100
101 Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const { 101 Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
102 if (!host()->frame()) 102 if (!supplementable()->frame())
103 return nullptr; 103 return nullptr;
104 104
105 Document* document = host()->frame()->document(); 105 Document* document = supplementable()->frame()->document();
106 DCHECK(document); 106 DCHECK(document);
107 String accessDeniedMessage = "Access is denied for this document."; 107 String accessDeniedMessage = "Access is denied for this document.";
108 if (!document->getSecurityOrigin()->canAccessLocalStorage()) { 108 if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
109 if (document->isSandboxed(SandboxOrigin)) 109 if (document->isSandboxed(SandboxOrigin))
110 exceptionState.throwSecurityError( 110 exceptionState.throwSecurityError(
111 "The document is sandboxed and lacks the 'allow-same-origin' flag."); 111 "The document is sandboxed and lacks the 'allow-same-origin' flag.");
112 else if (document->url().protocolIs("data")) 112 else if (document->url().protocolIs("data"))
113 exceptionState.throwSecurityError( 113 exceptionState.throwSecurityError(
114 "Storage is disabled inside 'data:' URLs."); 114 "Storage is disabled inside 'data:' URLs.");
115 else 115 else
(...skipping 15 matching lines...) Expand all
131 StorageNamespace::localStorageArea(document->getSecurityOrigin()); 131 StorageNamespace::localStorageArea(document->getSecurityOrigin());
132 if (!storageArea->canAccessStorage(document->frame())) { 132 if (!storageArea->canAccessStorage(document->frame())) {
133 exceptionState.throwSecurityError(accessDeniedMessage); 133 exceptionState.throwSecurityError(accessDeniedMessage);
134 return nullptr; 134 return nullptr;
135 } 135 }
136 m_localStorage = Storage::create(document->frame(), storageArea); 136 m_localStorage = Storage::create(document->frame(), storageArea);
137 return m_localStorage; 137 return m_localStorage;
138 } 138 }
139 139
140 } // namespace blink 140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698