| 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 "modules/serviceworkers/NavigatorServiceWorker.h" | 5 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExecutionContext.h" | |
| 10 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 11 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 12 #include "core/frame/Navigator.h" | 11 #include "core/frame/Navigator.h" |
| 13 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 12 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 | 15 |
| 17 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) {} | 16 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) {} |
| 18 | 17 |
| 19 NavigatorServiceWorker* NavigatorServiceWorker::From(Document& document) { | 18 NavigatorServiceWorker* NavigatorServiceWorker::From(Document& document) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 } | 47 } |
| 49 | 48 |
| 50 const char* NavigatorServiceWorker::SupplementName() { | 49 const char* NavigatorServiceWorker::SupplementName() { |
| 51 return "NavigatorServiceWorker"; | 50 return "NavigatorServiceWorker"; |
| 52 } | 51 } |
| 53 | 52 |
| 54 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( | 53 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( |
| 55 ScriptState* script_state, | 54 ScriptState* script_state, |
| 56 Navigator& navigator, | 55 Navigator& navigator, |
| 57 ExceptionState& exception_state) { | 56 ExceptionState& exception_state) { |
| 58 ExecutionContext* execution_context = ExecutionContext::From(script_state); | 57 ExecutionContext* execution_context = script_state->GetExecutionContext(); |
| 59 DCHECK(!navigator.GetFrame() || | 58 DCHECK(!navigator.GetFrame() || |
| 60 execution_context->GetSecurityOrigin()->CanAccess( | 59 execution_context->GetSecurityOrigin()->CanAccess( |
| 61 navigator.GetFrame()->GetSecurityContext()->GetSecurityOrigin())); | 60 navigator.GetFrame()->GetSecurityContext()->GetSecurityOrigin())); |
| 62 return NavigatorServiceWorker::From(navigator).serviceWorker( | 61 return NavigatorServiceWorker::From(navigator).serviceWorker( |
| 63 navigator.GetFrame(), exception_state); | 62 navigator.GetFrame(), exception_state); |
| 64 } | 63 } |
| 65 | 64 |
| 66 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( | 65 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( |
| 67 ScriptState* script_state, | 66 ScriptState* script_state, |
| 68 Navigator& navigator, | 67 Navigator& navigator, |
| 69 String& error_message) { | 68 String& error_message) { |
| 70 ExecutionContext* execution_context = ExecutionContext::From(script_state); | 69 ExecutionContext* execution_context = script_state->GetExecutionContext(); |
| 71 DCHECK(!navigator.GetFrame() || | 70 DCHECK(!navigator.GetFrame() || |
| 72 execution_context->GetSecurityOrigin()->CanAccess( | 71 execution_context->GetSecurityOrigin()->CanAccess( |
| 73 navigator.GetFrame()->GetSecurityContext()->GetSecurityOrigin())); | 72 navigator.GetFrame()->GetSecurityContext()->GetSecurityOrigin())); |
| 74 return NavigatorServiceWorker::From(navigator).serviceWorker( | 73 return NavigatorServiceWorker::From(navigator).serviceWorker( |
| 75 navigator.GetFrame(), error_message); | 74 navigator.GetFrame(), error_message); |
| 76 } | 75 } |
| 77 | 76 |
| 78 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( | 77 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker( |
| 79 LocalFrame* frame, | 78 LocalFrame* frame, |
| 80 ExceptionState& exception_state) { | 79 ExceptionState& exception_state) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void NavigatorServiceWorker::ClearServiceWorker() { | 121 void NavigatorServiceWorker::ClearServiceWorker() { |
| 123 service_worker_ = nullptr; | 122 service_worker_ = nullptr; |
| 124 } | 123 } |
| 125 | 124 |
| 126 DEFINE_TRACE(NavigatorServiceWorker) { | 125 DEFINE_TRACE(NavigatorServiceWorker) { |
| 127 visitor->Trace(service_worker_); | 126 visitor->Trace(service_worker_); |
| 128 Supplement<Navigator>::Trace(visitor); | 127 Supplement<Navigator>::Trace(visitor); |
| 129 } | 128 } |
| 130 | 129 |
| 131 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |