| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/screen_orientation/ScreenOrientation.h" | 6 #include "modules/screen_orientation/ScreenOrientation.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 ScriptPromise ScreenOrientation::lock(ScriptState* state, const AtomicString& lo
ckString) | 153 ScriptPromise ScreenOrientation::lock(ScriptState* state, const AtomicString& lo
ckString) |
| 154 { | 154 { |
| 155 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); | 155 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); |
| 156 ScriptPromise promise = resolver->promise(); | 156 ScriptPromise promise = resolver->promise(); |
| 157 | 157 |
| 158 Document* document = m_frame ? m_frame->document() : 0; | 158 Document* document = m_frame ? m_frame->document() : 0; |
| 159 | 159 |
| 160 if (!document || !controller()) { | 160 if (!document || !controller()) { |
| 161 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Invali
dStateError, "The object is no longer associated to a document."); | 161 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); |
| 162 resolver->reject(exception); | 162 resolver->reject(exception); |
| 163 return promise; | 163 return promise; |
| 164 } | 164 } |
| 165 | 165 |
| 166 if (document->isSandboxed(SandboxOrientationLock)) { | 166 if (document->isSandboxed(SandboxOrientationLock)) { |
| 167 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Securi
tyError, "The document is sandboxed and lacks the 'allow-orientation-lock' flag.
"); | 167 DOMException* exception = DOMException::create(SecurityError, "The docum
ent is sandboxed and lacks the 'allow-orientation-lock' flag."); |
| 168 resolver->reject(exception); | 168 resolver->reject(exception); |
| 169 return promise; | 169 return promise; |
| 170 } | 170 } |
| 171 | 171 |
| 172 controller()->lock(stringToOrientationLock(lockString), new LockOrientationC
allback(resolver)); | 172 controller()->lock(stringToOrientationLock(lockString), new LockOrientationC
allback(resolver)); |
| 173 return promise; | 173 return promise; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void ScreenOrientation::unlock() | 176 void ScreenOrientation::unlock() |
| 177 { | 177 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 189 return ScreenOrientationController::from(*m_frame); | 189 return ScreenOrientationController::from(*m_frame); |
| 190 } | 190 } |
| 191 | 191 |
| 192 DEFINE_TRACE(ScreenOrientation) | 192 DEFINE_TRACE(ScreenOrientation) |
| 193 { | 193 { |
| 194 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac
e(visitor); | 194 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac
e(visitor); |
| 195 DOMWindowProperty::trace(visitor); | 195 DOMWindowProperty::trace(visitor); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |