| 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/serviceworkers/ServiceWorkerClient.h" | 6 #include "modules/serviceworkers/ServiceWorkerClient.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (exceptionState.hadException()) | 63 if (exceptionState.hadException()) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 WebString messageString = message->toWireString(); | 66 WebString messageString = message->toWireString(); |
| 67 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); | 67 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); |
| 68 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_id, mes
sageString, webChannels.release()); | 68 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_id, mes
sageString, webChannels.release()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ScriptPromise ServiceWorkerClient::focus(ScriptState* scriptState) | 71 ScriptPromise ServiceWorkerClient::focus(ScriptState* scriptState) |
| 72 { | 72 { |
| 73 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 73 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 74 ScriptPromise promise = resolver->promise(); | 74 ScriptPromise promise = resolver->promise(); |
| 75 | 75 |
| 76 // FIXME: there should be a check for whether the caller is allowed to focus | 76 // FIXME: there should be a check for whether the caller is allowed to focus |
| 77 // the client. The promise should succeed with |false| if the call is not | 77 // the client. The promise should succeed with |false| if the call is not |
| 78 // allowed. https://crbug.com/437149 | 78 // allowed. https://crbug.com/437149 |
| 79 | 79 |
| 80 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(m_id, new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver)); | 80 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(m_id, new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver)); |
| 81 return promise; | 81 return promise; |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |