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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/NavigatorServiceWorker.cpp

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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 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 "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/Navigator.h" 10 #include "core/frame/Navigator.h"
(...skipping 17 matching lines...) Expand all
28 Navigator& navigator = *document.frame()->domWindow()->navigator(); 28 Navigator& navigator = *document.frame()->domWindow()->navigator();
29 return &from(navigator); 29 return &from(navigator);
30 } 30 }
31 31
32 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) 32 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator)
33 { 33 {
34 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator); 34 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator);
35 if (!supplement) { 35 if (!supplement) {
36 supplement = new NavigatorServiceWorker(navigator); 36 supplement = new NavigatorServiceWorker(navigator);
37 provideTo(navigator, supplementName(), supplement); 37 provideTo(navigator, supplementName(), supplement);
38 if (navigator.frame() && navigator.frame()->securityContext()->securityO rigin()->canAccessServiceWorkers()) { 38 if (navigator.frame() && navigator.frame()->securityContext()->getSecuri tyOrigin()->canAccessServiceWorkers()) {
39 // Initialize ServiceWorkerContainer too. 39 // Initialize ServiceWorkerContainer too.
40 supplement->serviceWorker(ASSERT_NO_EXCEPTION); 40 supplement->serviceWorker(ASSERT_NO_EXCEPTION);
41 } 41 }
42 } 42 }
43 return *supplement; 43 return *supplement;
44 } 44 }
45 45
46 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat or& navigator) 46 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat or& navigator)
47 { 47 {
48 return static_cast<NavigatorServiceWorker*>(HeapSupplement<Navigator>::from( navigator, supplementName())); 48 return static_cast<NavigatorServiceWorker*>(HeapSupplement<Navigator>::from( navigator, supplementName()));
49 } 49 }
50 50
51 const char* NavigatorServiceWorker::supplementName() 51 const char* NavigatorServiceWorker::supplementName()
52 { 52 {
53 return "NavigatorServiceWorker"; 53 return "NavigatorServiceWorker";
54 } 54 }
55 55
56 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExecutionContext* executionContext, Navigator& navigator, ExceptionState& exceptionState) 56 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExecutionContext* executionContext, Navigator& navigator, ExceptionState& exceptionState)
57 { 57 {
58 ASSERT(!navigator.frame() || executionContext->securityOrigin()->canAccessCh eckSuborigins(navigator.frame()->securityContext()->securityOrigin())); 58 ASSERT(!navigator.frame() || executionContext->getSecurityOrigin()->canAcces sCheckSuborigins(navigator.frame()->securityContext()->getSecurityOrigin()));
59 return NavigatorServiceWorker::from(navigator).serviceWorker(exceptionState) ; 59 return NavigatorServiceWorker::from(navigator).serviceWorker(exceptionState) ;
60 } 60 }
61 61
62 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExceptionState& ex ceptionState) 62 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExceptionState& ex ceptionState)
63 { 63 {
64 if (frame() && !frame()->securityContext()->securityOrigin()->canAccessServi ceWorkers()) { 64 if (frame() && !frame()->securityContext()->getSecurityOrigin()->canAccessSe rviceWorkers()) {
65 if (frame()->securityContext()->isSandboxed(SandboxOrigin)) 65 if (frame()->securityContext()->isSandboxed(SandboxOrigin))
66 exceptionState.throwSecurityError("Service worker is disabled becaus e the context is sandboxed and lacks the 'allow-same-origin' flag."); 66 exceptionState.throwSecurityError("Service worker is disabled becaus e the context is sandboxed and lacks the 'allow-same-origin' flag.");
67 else 67 else
68 exceptionState.throwSecurityError("Access to service workers is deni ed in this document origin."); 68 exceptionState.throwSecurityError("Access to service workers is deni ed in this document origin.");
69 return nullptr; 69 return nullptr;
70 } 70 }
71 if (!m_serviceWorker && frame()) { 71 if (!m_serviceWorker && frame()) {
72 ASSERT(frame()->domWindow()); 72 ASSERT(frame()->domWindow());
73 m_serviceWorker = ServiceWorkerContainer::create(frame()->domWindow()->e xecutionContext()); 73 m_serviceWorker = ServiceWorkerContainer::create(frame()->domWindow()->g etExecutionContext());
74 } 74 }
75 return m_serviceWorker.get(); 75 return m_serviceWorker.get();
76 } 76 }
77 77
78 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame() 78 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame()
79 { 79 {
80 if (m_serviceWorker) { 80 if (m_serviceWorker) {
81 m_serviceWorker->willBeDetachedFromFrame(); 81 m_serviceWorker->willBeDetachedFromFrame();
82 m_serviceWorker = nullptr; 82 m_serviceWorker = nullptr;
83 } 83 }
84 } 84 }
85 85
86 DEFINE_TRACE(NavigatorServiceWorker) 86 DEFINE_TRACE(NavigatorServiceWorker)
87 { 87 {
88 visitor->trace(m_serviceWorker); 88 visitor->trace(m_serviceWorker);
89 HeapSupplement<Navigator>::trace(visitor); 89 HeapSupplement<Navigator>::trace(visitor);
90 DOMWindowProperty::trace(visitor); 90 DOMWindowProperty::trace(visitor);
91 } 91 }
92 92
93 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698