| 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/ServiceWorkerWindowClient.h" | 6 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 
| 7 | 7 | 
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 70 { | 70 { | 
| 71     RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
    create(scriptState); | 71     RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
    create(scriptState); | 
| 72     ScriptPromise promise = resolver->promise(); | 72     ScriptPromise promise = resolver->promise(); | 
| 73 | 73 | 
| 74     if (!scriptState->executionContext()->isWindowInteractionAllowed()) { | 74     if (!scriptState->executionContext()->isWindowInteractionAllowed()) { | 
| 75         resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
    o focus a window.")); | 75         resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
    o focus a window.")); | 
| 76         return promise; | 76         return promise; | 
| 77     } | 77     } | 
| 78     scriptState->executionContext()->consumeWindowInteraction(); | 78     scriptState->executionContext()->consumeWindowInteraction(); | 
| 79 | 79 | 
| 80     ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
    (id(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>
    (resolver)); | 80     if (!uuid().isEmpty()) { | 
|  | 81         ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->f
    ocus(uuid(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorker
    Error>(resolver)); | 
|  | 82     } else { | 
|  | 83         // FIXME: Deprecate this when we switch to uuid. | 
|  | 84         ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->f
    ocus(id(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerEr
    ror>(resolver)); | 
|  | 85     } | 
| 81     return promise; | 86     return promise; | 
| 82 } | 87 } | 
| 83 | 88 | 
| 84 DEFINE_TRACE(ServiceWorkerWindowClient) | 89 DEFINE_TRACE(ServiceWorkerWindowClient) | 
| 85 { | 90 { | 
| 86     ServiceWorkerClient::trace(visitor); | 91     ServiceWorkerClient::trace(visitor); | 
| 87 } | 92 } | 
| 88 | 93 | 
| 89 } // namespace blink | 94 } // namespace blink | 
| OLD | NEW | 
|---|