| 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/Presentation.h" | 5 #include "modules/presentation/Presentation.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" |
| 9 #include "modules/presentation/PresentationController.h" | 10 #include "modules/presentation/PresentationController.h" |
| 10 #include "modules/presentation/PresentationReceiver.h" | 11 #include "modules/presentation/PresentationReceiver.h" |
| 11 #include "modules/presentation/PresentationRequest.h" | 12 #include "modules/presentation/PresentationRequest.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 Presentation::Presentation(LocalFrame* frame) : DOMWindowProperty(frame) {} | 16 Presentation::Presentation(LocalFrame* frame) : DOMWindowProperty(frame) {} |
| 16 | 17 |
| 17 // static | 18 // static |
| 18 Presentation* Presentation::create(LocalFrame* frame) { | 19 Presentation* Presentation::create(LocalFrame* frame) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 if (!frame()) | 42 if (!frame()) |
| 42 return; | 43 return; |
| 43 | 44 |
| 44 PresentationController* controller = PresentationController::from(*frame()); | 45 PresentationController* controller = PresentationController::from(*frame()); |
| 45 if (!controller) | 46 if (!controller) |
| 46 return; | 47 return; |
| 47 controller->setDefaultRequestUrl(request ? request->url() : KURL()); | 48 controller->setDefaultRequestUrl(request ? request->url() : KURL()); |
| 48 } | 49 } |
| 49 | 50 |
| 50 PresentationReceiver* Presentation::receiver() { | 51 PresentationReceiver* Presentation::receiver() { |
| 51 if (!frame()) | 52 if (!frame() || !frame()->settings()) |
| 52 return nullptr; | 53 return nullptr; |
| 53 // TODO(crbug.com/647296): only return something if the Blink instance is | 54 |
| 54 // running in presentation receiver mode. The flag PresentationReceiver could | 55 if (!frame()->settings()->presentationReceiver()) |
| 55 // be used for that. | 56 return nullptr; |
| 57 |
| 56 if (!m_receiver) { | 58 if (!m_receiver) { |
| 57 PresentationController* controller = PresentationController::from(*frame()); | 59 PresentationController* controller = PresentationController::from(*frame()); |
| 58 auto* client = controller ? controller->client() : nullptr; | 60 auto* client = controller ? controller->client() : nullptr; |
| 59 m_receiver = new PresentationReceiver(frame(), client); | 61 m_receiver = new PresentationReceiver(frame(), client); |
| 60 } | 62 } |
| 63 |
| 61 return m_receiver; | 64 return m_receiver; |
| 62 } | 65 } |
| 63 | 66 |
| 64 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |