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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/Presentation.cpp

Issue 2552343009: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed)
Patch Set: resolve code review comments from Mark Created 4 years 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/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 "core/frame/Settings.h"
10 #include "modules/presentation/PresentationController.h" 10 #include "modules/presentation/PresentationController.h"
11 #include "modules/presentation/PresentationReceiver.h" 11 #include "modules/presentation/PresentationReceiver.h"
12 #include "modules/presentation/PresentationRequest.h" 12 #include "modules/presentation/PresentationRequest.h"
13 #include "platform/weborigin/KURL.h"
14 #include "wtf/Vector.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 Presentation::Presentation(LocalFrame* frame) : DOMWindowProperty(frame) {} 18 Presentation::Presentation(LocalFrame* frame) : DOMWindowProperty(frame) {}
17 19
18 // static 20 // static
19 Presentation* Presentation::create(LocalFrame* frame) { 21 Presentation* Presentation::create(LocalFrame* frame) {
20 ASSERT(frame); 22 ASSERT(frame);
21 23
22 Presentation* presentation = new Presentation(frame); 24 Presentation* presentation = new Presentation(frame);
23 PresentationController* controller = PresentationController::from(*frame); 25 PresentationController* controller = PresentationController::from(*frame);
24 ASSERT(controller); 26 ASSERT(controller);
25 controller->setPresentation(presentation); 27 controller->setPresentation(presentation);
26 return presentation; 28 return presentation;
27 } 29 }
28 30
29 DEFINE_TRACE(Presentation) { 31 DEFINE_TRACE(Presentation) {
30 visitor->trace(m_defaultRequest); 32 visitor->trace(m_defaultRequest);
31 visitor->trace(m_receiver); 33 visitor->trace(m_receiver);
32 DOMWindowProperty::trace(visitor); 34 DOMWindowProperty::trace(visitor);
33 } 35 }
34 36
35 PresentationRequest* Presentation::defaultRequest() const { 37 PresentationRequest* Presentation::defaultRequest() const {
36 return m_defaultRequest; 38 return m_defaultRequest;
37 } 39 }
38 40
39 void Presentation::setDefaultRequest(PresentationRequest* request) { 41 void Presentation::setDefaultRequest(PresentationRequest* request) {
42 if (!request)
43 return;
mlamouri (slow - plz ping) 2016/12/10 12:06:18 Wouldn't this prevent `navigator.presentation.defa
zhaobin 2016/12/12 19:53:45 Done.
zhaobin 2016/12/12 19:53:45 yes, it will break defaultRequest = null. Reverted
44
40 m_defaultRequest = request; 45 m_defaultRequest = request;
41 46
42 if (!frame()) 47 if (!frame())
43 return; 48 return;
44 49
45 PresentationController* controller = PresentationController::from(*frame()); 50 PresentationController* controller = PresentationController::from(*frame());
46 if (!controller) 51 if (!controller)
47 return; 52 return;
48 controller->setDefaultRequestUrl(request ? request->url() : KURL()); 53 controller->setDefaultRequestUrl(request->urls());
49 } 54 }
50 55
51 PresentationReceiver* Presentation::receiver() { 56 PresentationReceiver* Presentation::receiver() {
52 if (!frame() || !frame()->settings()) 57 if (!frame() || !frame()->settings())
53 return nullptr; 58 return nullptr;
54 59
55 if (!frame()->settings()->presentationReceiver()) 60 if (!frame()->settings()->presentationReceiver())
56 return nullptr; 61 return nullptr;
57 62
58 if (!m_receiver) { 63 if (!m_receiver) {
59 PresentationController* controller = PresentationController::from(*frame()); 64 PresentationController* controller = PresentationController::from(*frame());
60 auto* client = controller ? controller->client() : nullptr; 65 auto* client = controller ? controller->client() : nullptr;
61 m_receiver = new PresentationReceiver(frame(), client); 66 m_receiver = new PresentationReceiver(frame(), client);
62 } 67 }
63 68
64 return m_receiver; 69 return m_receiver;
65 } 70 }
66 71
67 } // namespace blink 72 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/BUILD.gn ('k') | third_party/WebKit/Source/modules/presentation/PresentationAvailability.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698