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

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

Issue 2801823003: [Presentation API] Change connection to 'connected' if start a presentation with "https://www.googl… (Closed)
Patch Set: resolve code review comments from mlamouri Created 3 years, 8 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/presentation/NavigatorPresentation.h" 5 #include "modules/presentation/NavigatorPresentation.h"
6 6
7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h"
7 #include "core/frame/Navigator.h" 10 #include "core/frame/Navigator.h"
8 #include "modules/presentation/Presentation.h" 11 #include "modules/presentation/Presentation.h"
9 12
10 namespace blink { 13 namespace blink {
11 14
12 NavigatorPresentation::NavigatorPresentation() {} 15 NavigatorPresentation::NavigatorPresentation() {}
13 16
14 // static 17 // static
15 const char* NavigatorPresentation::supplementName() { 18 const char* NavigatorPresentation::supplementName() {
16 return "NavigatorPresentation"; 19 return "NavigatorPresentation";
17 } 20 }
18 21
19 // static 22 // static
23 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.
24 Document& document) {
25 if (!document.frame() || !document.frame()->domWindow())
26 return 0;
mark a. foltz 2017/04/10 21:59:57 nullptr
zhaobin 2017/04/11 00:03:09 Done.
27 Navigator& navigator = *document.frame()->domWindow()->navigator();
28 NavigatorPresentation* presentation = &from(navigator);
29
30 if (navigator.frame()) {
31 // This need to be eagerly created in order to have the receiver associated
32 // with the client.
33 presentation->m_presentation = Presentation::create(navigator.frame());
34 presentation->m_presentation->receiver();
35 }
36 return presentation;
37 }
38
39 // static
20 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) { 40 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) {
21 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>( 41 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(
22 Supplement<Navigator>::from(navigator, supplementName())); 42 Supplement<Navigator>::from(navigator, supplementName()));
23 if (!supplement) { 43 if (!supplement) {
24 supplement = new NavigatorPresentation(); 44 supplement = new NavigatorPresentation();
25 provideTo(navigator, supplementName(), supplement); 45 provideTo(navigator, supplementName(), supplement);
26 } 46 }
27 return *supplement; 47 return *supplement;
28 } 48 }
29 49
30 // static 50 // static
31 Presentation* NavigatorPresentation::presentation(Navigator& navigator) { 51 Presentation* NavigatorPresentation::presentation(Navigator& navigator) {
32 NavigatorPresentation& self = NavigatorPresentation::from(navigator); 52 NavigatorPresentation& self = NavigatorPresentation::from(navigator);
33 if (!self.m_presentation) { 53 if (!self.m_presentation) {
34 if (!navigator.frame()) 54 if (!navigator.frame())
35 return nullptr; 55 return nullptr;
36 self.m_presentation = Presentation::create(navigator.frame()); 56 self.m_presentation = Presentation::create(navigator.frame());
37 } 57 }
38 return self.m_presentation; 58 return self.m_presentation;
39 } 59 }
40 60
41 DEFINE_TRACE(NavigatorPresentation) { 61 DEFINE_TRACE(NavigatorPresentation) {
42 visitor->trace(m_presentation); 62 visitor->trace(m_presentation);
43 Supplement<Navigator>::trace(visitor); 63 Supplement<Navigator>::trace(visitor);
44 } 64 }
45 65
46 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698