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

Side by Side Diff: third_party/WebKit/Source/modules/quota/StorageManager.cpp

Issue 1373773003: Implement 'window.isSecureContext'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: document. Created 5 years, 2 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 "config.h" 5 #include "config.h"
6 #include "modules/quota/StorageManager.h" 6 #include "modules/quota/StorageManager.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 } // namespace 73 } // namespace
74 74
75 ScriptPromise StorageManager::requestPersistent(ScriptState* scriptState) 75 ScriptPromise StorageManager::requestPersistent(ScriptState* scriptState)
76 { 76 {
77 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 77 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
78 ScriptPromise promise = resolver->promise(); 78 ScriptPromise promise = resolver->promise();
79 ExecutionContext* executionContext = scriptState->executionContext(); 79 ExecutionContext* executionContext = scriptState->executionContext();
80 SecurityOrigin* securityOrigin = executionContext->securityOrigin(); 80 SecurityOrigin* securityOrigin = executionContext->securityOrigin();
81 // TODO(dgrogan): Is the isUnique() check covered by the later 81 // TODO(dgrogan): Is the isUnique() check covered by the later
82 // isPrivilegedContext() check? If so, maybe remove it. Write a test if it 82 // isSecureContext() check? If so, maybe remove it. Write a test if it
83 // stays. 83 // stays.
84 if (securityOrigin->isUnique()) { 84 if (securityOrigin->isUnique()) {
85 resolver->reject(DOMException::create(NotSupportedError)); 85 resolver->reject(DOMException::create(NotSupportedError));
86 return promise; 86 return promise;
87 } 87 }
88 String errorMessage; 88 String errorMessage;
89 if (!executionContext->isPrivilegedContext(errorMessage)) { 89 if (!executionContext->isSecureContext(errorMessage)) {
90 resolver->reject(DOMException::create(SecurityError, errorMessage)); 90 resolver->reject(DOMException::create(SecurityError, errorMessage));
91 return promise; 91 return promise;
92 } 92 }
93 ASSERT(executionContext->isDocument()); 93 ASSERT(executionContext->isDocument());
94 WebPermissionClient* permissionClient = Permissions::getClient(executionCont ext); 94 WebPermissionClient* permissionClient = Permissions::getClient(executionCont ext);
95 if (!permissionClient) { 95 if (!permissionClient) {
96 resolver->reject(DOMException::create(InvalidStateError, "In its current state, the global scope can't request permissions.")); 96 resolver->reject(DOMException::create(InvalidStateError, "In its current state, the global scope can't request permissions."));
97 return promise; 97 return promise;
98 } 98 }
99 permissionClient->requestPermission(WebPermissionTypeDurableStorage, KURL(KU RL(), scriptState->executionContext()->securityOrigin()->toString()), new Durabl eStorageRequestCallbacks(resolver)); 99 permissionClient->requestPermission(WebPermissionTypeDurableStorage, KURL(KU RL(), scriptState->executionContext()->securityOrigin()->toString()), new Durabl eStorageRequestCallbacks(resolver));
(...skipping 12 matching lines...) Expand all
112 } 112 }
113 permissionClient->queryPermission(WebPermissionTypeDurableStorage, KURL(KURL (), scriptState->executionContext()->securityOrigin()->toString()), new DurableS torageQueryCallbacks(resolver)); 113 permissionClient->queryPermission(WebPermissionTypeDurableStorage, KURL(KURL (), scriptState->executionContext()->securityOrigin()->toString()), new DurableS torageQueryCallbacks(resolver));
114 return promise; 114 return promise;
115 } 115 }
116 116
117 DEFINE_TRACE(StorageManager) 117 DEFINE_TRACE(StorageManager)
118 { 118 {
119 } 119 }
120 120
121 } // namespace blink 121 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698