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

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

Issue 268353004: NotificationController::clientFrom() should return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | Source/modules/notifications/NotificationController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/frame/UseCounter.h" 37 #include "core/frame/UseCounter.h"
38 #include "core/page/WindowFocusAllowedIndicator.h" 38 #include "core/page/WindowFocusAllowedIndicator.h"
39 #include "modules/notifications/NotificationClient.h" 39 #include "modules/notifications/NotificationClient.h"
40 #include "modules/notifications/NotificationController.h" 40 #include "modules/notifications/NotificationController.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 Notification* Notification::create(ExecutionContext* context, const String& titl e, const Dictionary& options) 44 Notification* Notification::create(ExecutionContext* context, const String& titl e, const Dictionary& options)
45 { 45 {
46 NotificationClient* client = NotificationController::clientFrom(toDocument(c ontext)->frame()); 46 NotificationClient& client = NotificationController::clientFrom(toDocument(c ontext)->frame());
47 Notification* notification = adoptRefCountedGarbageCollected(new Notificatio n(title, context, client)); 47 Notification* notification = adoptRefCountedGarbageCollected(new Notificatio n(title, context, &client));
48 48
49 String argument; 49 String argument;
50 if (options.get("body", argument)) 50 if (options.get("body", argument))
51 notification->setBody(argument); 51 notification->setBody(argument);
52 if (options.get("tag", argument)) 52 if (options.get("tag", argument))
53 notification->setTag(argument); 53 notification->setTag(argument);
54 if (options.get("lang", argument)) 54 if (options.get("lang", argument))
55 notification->setLang(argument); 55 notification->setLang(argument);
56 if (options.get("dir", argument)) 56 if (options.get("dir", argument))
57 notification->setDir(argument); 57 notification->setDir(argument);
(...skipping 24 matching lines...) Expand all
82 Notification::~Notification() 82 Notification::~Notification()
83 { 83 {
84 } 84 }
85 85
86 void Notification::show() 86 void Notification::show()
87 { 87 {
88 ASSERT(m_state == Idle); 88 ASSERT(m_state == Idle);
89 if (!toDocument(executionContext())->page()) 89 if (!toDocument(executionContext())->page())
90 return; 90 return;
91 91
92 if (NotificationController::from(toDocument(executionContext())->frame())->c lient()->checkPermission(executionContext()) != NotificationClient::PermissionAl lowed) { 92 if (m_client->checkPermission(executionContext()) != NotificationClient::Per missionAllowed) {
93 dispatchErrorEvent(); 93 dispatchErrorEvent();
94 return; 94 return;
95 } 95 }
96 96
97 if (m_client->show(this)) 97 if (m_client->show(this))
98 m_state = Showing; 98 m_state = Showing;
99 } 99 }
100 100
101 void Notification::close() 101 void Notification::close()
102 { 102 {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 ASSERT_NOT_REACHED(); 158 ASSERT_NOT_REACHED();
159 return deniedPermission; 159 return deniedPermission;
160 } 160 }
161 161
162 const String& Notification::permission(ExecutionContext* context) 162 const String& Notification::permission(ExecutionContext* context)
163 { 163 {
164 ASSERT(toDocument(context)->page()); 164 ASSERT(toDocument(context)->page());
165 165
166 UseCounter::count(context, UseCounter::NotificationPermission); 166 UseCounter::count(context, UseCounter::NotificationPermission);
167 return permissionString(NotificationController::from(toDocument(context)->fr ame())->client()->checkPermission(context)); 167 return permissionString(NotificationController::clientFrom(toDocument(contex t)->frame()).checkPermission(context));
168 } 168 }
169 169
170 void Notification::requestPermission(ExecutionContext* context, PassOwnPtr<Notif icationPermissionCallback> callback) 170 void Notification::requestPermission(ExecutionContext* context, PassOwnPtr<Notif icationPermissionCallback> callback)
171 { 171 {
172 ASSERT(toDocument(context)->page()); 172 ASSERT(toDocument(context)->page());
173 NotificationController::from(toDocument(context)->frame())->client()->reques tPermission(context, callback); 173 NotificationController::clientFrom(toDocument(context)->frame()).requestPerm ission(context, callback);
174 } 174 }
175 175
176 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) 176 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
177 { 177 {
178 ASSERT(m_state != Closed); 178 ASSERT(m_state != Closed);
179 179
180 return EventTarget::dispatchEvent(event); 180 return EventTarget::dispatchEvent(event);
181 } 181 }
182 182
183 const AtomicString& Notification::interfaceName() const 183 const AtomicString& Notification::interfaceName() const
(...skipping 12 matching lines...) Expand all
196 m_client = 0; 196 m_client = 0;
197 m_state = Closed; 197 m_state = Closed;
198 } 198 }
199 199
200 bool Notification::hasPendingActivity() const 200 bool Notification::hasPendingActivity() const
201 { 201 {
202 return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive()); 202 return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive());
203 } 203 }
204 204
205 } // namespace WebCore 205 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/notifications/NotificationController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698