Chromium Code Reviews| 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/presentation/PresentationAvailability.h" | 5 #include "modules/presentation/PresentationAvailability.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
| 10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
| 11 #include "modules/EventTargetModulesNames.h" | 11 #include "modules/EventTargetModulesNames.h" |
| 12 #include "modules/presentation/PresentationController.h" | 12 #include "modules/presentation/PresentationController.h" |
| 13 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
| 14 #include "public/platform/modules/presentation/WebPresentationClient.h" | 14 #include "public/platform/modules/presentation/WebPresentationClient.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 WebPresentationClient* presentationClient(ExecutionContext* executionContext) { | 20 WebPresentationClient* presentationClient(ExecutionContext* executionContext) { |
| 21 ASSERT(executionContext && executionContext->isDocument()); | 21 if (!executionContext) |
|
dcheng
2016/10/05 00:10:27
Is this because we can be asked to provide a prese
haraken
2016/10/05 02:38:24
You're correct.
We didn't hit this branch before
| |
| 22 | 22 return nullptr; |
| 23 DCHECK(executionContext->isDocument()); | |
| 23 Document* document = toDocument(executionContext); | 24 Document* document = toDocument(executionContext); |
| 24 if (!document->frame()) | 25 if (!document->frame()) |
| 25 return nullptr; | 26 return nullptr; |
| 26 PresentationController* controller = | 27 PresentationController* controller = |
| 27 PresentationController::from(*document->frame()); | 28 PresentationController::from(*document->frame()); |
| 28 return controller ? controller->client() : nullptr; | 29 return controller ? controller->client() : nullptr; |
| 29 } | 30 } |
| 30 | 31 |
| 31 } // anonymous namespace | 32 } // anonymous namespace |
| 32 | 33 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 } | 88 } |
| 88 | 89 |
| 89 void PresentationAvailability::resume() { | 90 void PresentationAvailability::resume() { |
| 90 setState(State::Active); | 91 setState(State::Active); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void PresentationAvailability::suspend() { | 94 void PresentationAvailability::suspend() { |
| 94 setState(State::Suspended); | 95 setState(State::Suspended); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void PresentationAvailability::stop() { | 98 void PresentationAvailability::contextDestroyed() { |
| 98 setState(State::Inactive); | 99 setState(State::Inactive); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void PresentationAvailability::pageVisibilityChanged() { | 102 void PresentationAvailability::pageVisibilityChanged() { |
| 102 if (m_state == State::Inactive) | 103 if (m_state == State::Inactive) |
| 103 return; | 104 return; |
| 104 updateListening(); | 105 updateListening(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void PresentationAvailability::setState(State state) { | 108 void PresentationAvailability::setState(State state) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 130 return m_value; | 131 return m_value; |
| 131 } | 132 } |
| 132 | 133 |
| 133 DEFINE_TRACE(PresentationAvailability) { | 134 DEFINE_TRACE(PresentationAvailability) { |
| 134 EventTargetWithInlineData::trace(visitor); | 135 EventTargetWithInlineData::trace(visitor); |
| 135 PageVisibilityObserver::trace(visitor); | 136 PageVisibilityObserver::trace(visitor); |
| 136 ActiveDOMObject::trace(visitor); | 137 ActiveDOMObject::trace(visitor); |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |