Chromium Code Reviews| Index: third_party/WebKit/Source/modules/presentation/NavigatorPresentation.cpp |
| diff --git a/third_party/WebKit/Source/modules/presentation/NavigatorPresentation.cpp b/third_party/WebKit/Source/modules/presentation/NavigatorPresentation.cpp |
| index a3ce1b4fd4e5c7ba2e08a79826fe221ee224539f..ab33d1479bb8ccabdd3caa3bca35d8f5478ca8fa 100644 |
| --- a/third_party/WebKit/Source/modules/presentation/NavigatorPresentation.cpp |
| +++ b/third_party/WebKit/Source/modules/presentation/NavigatorPresentation.cpp |
| @@ -4,6 +4,9 @@ |
| #include "modules/presentation/NavigatorPresentation.h" |
| +#include "core/dom/Document.h" |
| +#include "core/frame/LocalDOMWindow.h" |
| +#include "core/frame/LocalFrame.h" |
| #include "core/frame/Navigator.h" |
| #include "modules/presentation/Presentation.h" |
| @@ -17,6 +20,23 @@ const char* NavigatorPresentation::supplementName() { |
| } |
| // static |
| +NavigatorPresentation* NavigatorPresentation::ensurePresentationReceiver( |
|
mark a. foltz
2017/04/10 21:59:57
Slight preference to move this to PresentationRece
zhaobin
2017/04/11 00:03:09
Done.
|
| + Document& document) { |
| + if (!document.frame() || !document.frame()->domWindow()) |
| + return 0; |
|
mark a. foltz
2017/04/10 21:59:57
nullptr
zhaobin
2017/04/11 00:03:09
Done.
|
| + Navigator& navigator = *document.frame()->domWindow()->navigator(); |
| + NavigatorPresentation* presentation = &from(navigator); |
| + |
| + if (navigator.frame()) { |
| + // This need to be eagerly created in order to have the receiver associated |
| + // with the client. |
| + presentation->m_presentation = Presentation::create(navigator.frame()); |
| + presentation->m_presentation->receiver(); |
| + } |
| + return presentation; |
| +} |
| + |
| +// static |
| NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) { |
| NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>( |
| Supplement<Navigator>::from(navigator, supplementName())); |