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

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 Derek 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::from(Document& document) {
24 if (!document.frame() || !document.frame()->domWindow())
25 return 0;
26 Navigator& navigator = *document.frame()->domWindow()->navigator();
27 return &from(navigator);
28 }
29
30 // static
20 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) { 31 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) {
21 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>( 32 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(
22 Supplement<Navigator>::from(navigator, supplementName())); 33 Supplement<Navigator>::from(navigator, supplementName()));
23 if (!supplement) { 34 if (!supplement) {
24 supplement = new NavigatorPresentation(); 35 supplement = new NavigatorPresentation();
36 if (navigator.frame())
37 supplement->m_presentation = Presentation::create(navigator.frame());
mlamouri (slow - plz ping) 2017/04/10 12:50:28 This seems to duplicate the logic in `NavigatorPre
zhaobin 2017/04/10 21:05:58 Done.
38
25 provideTo(navigator, supplementName(), supplement); 39 provideTo(navigator, supplementName(), supplement);
26 } 40 }
27 return *supplement; 41 return *supplement;
28 } 42 }
29 43
30 // static 44 // static
31 Presentation* NavigatorPresentation::presentation(Navigator& navigator) { 45 Presentation* NavigatorPresentation::presentation(Navigator& navigator) {
32 NavigatorPresentation& self = NavigatorPresentation::from(navigator); 46 NavigatorPresentation& self = NavigatorPresentation::from(navigator);
33 if (!self.m_presentation) { 47 if (!self.m_presentation) {
34 if (!navigator.frame()) 48 if (!navigator.frame())
35 return nullptr; 49 return nullptr;
36 self.m_presentation = Presentation::create(navigator.frame()); 50 self.m_presentation = Presentation::create(navigator.frame());
37 } 51 }
38 return self.m_presentation; 52 return self.m_presentation;
39 } 53 }
40 54
41 DEFINE_TRACE(NavigatorPresentation) { 55 DEFINE_TRACE(NavigatorPresentation) {
42 visitor->trace(m_presentation); 56 visitor->trace(m_presentation);
43 Supplement<Navigator>::trace(visitor); 57 Supplement<Navigator>::trace(visitor);
44 } 58 }
45 59
46 } // namespace blink 60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698