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

Side by Side Diff: Source/modules/notifications/DOMWindowNotifications.cpp

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 19 matching lines...) Expand all
30 #if ENABLE(LEGACY_NOTIFICATIONS) 30 #if ENABLE(LEGACY_NOTIFICATIONS)
31 31
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/frame/DOMWindow.h" 33 #include "core/frame/DOMWindow.h"
34 #include "core/page/Page.h" 34 #include "core/page/Page.h"
35 #include "modules/notifications/NotificationCenter.h" 35 #include "modules/notifications/NotificationCenter.h"
36 #include "modules/notifications/NotificationController.h" 36 #include "modules/notifications/NotificationController.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 DOMWindowNotifications::DOMWindowNotifications(DOMWindow* window) 40 DOMWindowNotifications::DOMWindowNotifications(DOMWindow& window)
41 : DOMWindowProperty(window->frame()) 41 : DOMWindowProperty(window.frame())
42 , m_window(window) 42 , m_window(window)
43 { 43 {
44 } 44 }
45 45
46 DOMWindowNotifications::~DOMWindowNotifications() 46 DOMWindowNotifications::~DOMWindowNotifications()
47 { 47 {
48 } 48 }
49 49
50 const char* DOMWindowNotifications::supplementName() 50 const char* DOMWindowNotifications::supplementName()
51 { 51 {
52 return "DOMWindowNotifications"; 52 return "DOMWindowNotifications";
53 } 53 }
54 54
55 DOMWindowNotifications* DOMWindowNotifications::from(DOMWindow* window) 55 DOMWindowNotifications& DOMWindowNotifications::from(DOMWindow& window)
56 { 56 {
57 DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Su pplement<DOMWindow>::from(window, supplementName())); 57 DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Su pplement<DOMWindow>::from(window, supplementName()));
58 if (!supplement) { 58 if (!supplement) {
59 supplement = new DOMWindowNotifications(window); 59 supplement = new DOMWindowNotifications(window);
60 Supplement<DOMWindow>::provideTo(window, supplementName(), adoptPtr(supp lement)); 60 Supplement<DOMWindow>::provideTo(window, supplementName(), adoptPtr(supp lement));
61 } 61 }
62 return supplement; 62 return *supplement;
63 } 63 }
64 64
65 NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow* windo w) 65 NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow& windo w)
66 { 66 {
67 return DOMWindowNotifications::from(window)->webkitNotifications(); 67 return DOMWindowNotifications::from(window).webkitNotifications();
68 } 68 }
69 69
70 void DOMWindowNotifications::willDestroyGlobalObjectInFrame() 70 void DOMWindowNotifications::willDestroyGlobalObjectInFrame()
71 { 71 {
72 m_notificationCenter = 0; 72 m_notificationCenter = 0;
73 DOMWindowProperty::willDestroyGlobalObjectInFrame(); 73 DOMWindowProperty::willDestroyGlobalObjectInFrame();
74 } 74 }
75 75
76 void DOMWindowNotifications::willDetachGlobalObjectFromFrame() 76 void DOMWindowNotifications::willDetachGlobalObjectFromFrame()
77 { 77 {
78 m_notificationCenter = 0; 78 m_notificationCenter = 0;
79 DOMWindowProperty::willDetachGlobalObjectFromFrame(); 79 DOMWindowProperty::willDetachGlobalObjectFromFrame();
80 } 80 }
81 81
82 NotificationCenter* DOMWindowNotifications::webkitNotifications() 82 NotificationCenter* DOMWindowNotifications::webkitNotifications()
83 { 83 {
84 if (!m_window->isCurrentlyDisplayedInFrame()) 84 if (!m_window.isCurrentlyDisplayedInFrame())
85 return 0; 85 return 0;
86 86
87 if (m_notificationCenter) 87 if (m_notificationCenter)
88 return m_notificationCenter.get(); 88 return m_notificationCenter.get();
89 89
90 Document* document = m_window->document(); 90 Document* document = m_window.document();
91 if (!document) 91 if (!document)
92 return 0; 92 return 0;
93 93
94 Page* page = document->page(); 94 Page* page = document->page();
95 if (!page) 95 if (!page)
96 return 0; 96 return 0;
97 97
98 NotificationClient* provider = NotificationController::clientFrom(page); 98 NotificationClient* provider = NotificationController::clientFrom(page);
99 if (provider) 99 if (provider)
100 m_notificationCenter = NotificationCenter::create(document, provider); 100 m_notificationCenter = NotificationCenter::create(document, provider);
101 101
102 return m_notificationCenter.get(); 102 return m_notificationCenter.get();
103 } 103 }
104 104
105 } // namespace WebCore 105 } // namespace WebCore
106 106
107 #endif // ENABLE(LEGACY_NOTIFICATIONS) 107 #endif // ENABLE(LEGACY_NOTIFICATIONS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698