OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/permissions/NavigatorPermissions.h" | 5 #include "modules/permissions/NavigatorPermissions.h" |
6 | 6 |
7 #include "core/frame/Navigator.h" | 7 #include "core/frame/Navigator.h" |
8 #include "modules/permissions/Permissions.h" | 8 #include "modules/permissions/Permissions.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 NavigatorPermissions::NavigatorPermissions() | 12 NavigatorPermissions::NavigatorPermissions() |
13 { | 13 { |
14 } | 14 } |
15 | 15 |
16 // static | 16 // static |
17 const char* NavigatorPermissions::supplementName() | 17 const char* NavigatorPermissions::supplementName() |
18 { | 18 { |
19 return "NavigatorPermissions"; | 19 return "NavigatorPermissions"; |
20 } | 20 } |
21 | 21 |
22 // static | 22 // static |
23 NavigatorPermissions& NavigatorPermissions::from(Navigator& navigator) | 23 NavigatorPermissions& NavigatorPermissions::from(Navigator& navigator) |
24 { | 24 { |
25 NavigatorPermissions* supplement = static_cast<NavigatorPermissions*>(HeapSu
pplement<Navigator>::from(navigator, supplementName())); | 25 NavigatorPermissions* supplement = static_cast<NavigatorPermissions*>(Supple
ment<Navigator>::from(navigator, supplementName())); |
26 if (!supplement) { | 26 if (!supplement) { |
27 supplement = new NavigatorPermissions(); | 27 supplement = new NavigatorPermissions(); |
28 provideTo(navigator, supplementName(), supplement); | 28 provideTo(navigator, supplementName(), supplement); |
29 } | 29 } |
30 return *supplement; | 30 return *supplement; |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 Permissions* NavigatorPermissions::permissions(Navigator& navigator) | 34 Permissions* NavigatorPermissions::permissions(Navigator& navigator) |
35 { | 35 { |
36 NavigatorPermissions& self = NavigatorPermissions::from(navigator); | 36 NavigatorPermissions& self = NavigatorPermissions::from(navigator); |
37 if (!self.m_permissions) | 37 if (!self.m_permissions) |
38 self.m_permissions = new Permissions(); | 38 self.m_permissions = new Permissions(); |
39 return self.m_permissions.get(); | 39 return self.m_permissions.get(); |
40 } | 40 } |
41 | 41 |
42 DEFINE_TRACE(NavigatorPermissions) | 42 DEFINE_TRACE(NavigatorPermissions) |
43 { | 43 { |
44 visitor->trace(m_permissions); | 44 visitor->trace(m_permissions); |
45 HeapSupplement<Navigator>::trace(visitor); | 45 Supplement<Navigator>::trace(visitor); |
46 } | 46 } |
47 | 47 |
48 } // namespace blink | 48 } // namespace blink |
OLD | NEW |