OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/chrome_notification_observer.h" | 5 #include "chrome/browser/extensions/chrome_notification_observer.h" |
6 | 6 |
7 #include "chrome/common/extensions/features/feature_channel.h" | 7 #include "chrome/common/extensions/features/feature_channel.h" |
8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
11 #include "extensions/common/extension_messages.h" | 11 #include "extensions/common/extension_messages.h" |
| 12 #include "extensions/common/features/feature_util.h" |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 | 15 |
15 ChromeNotificationObserver::ChromeNotificationObserver() { | 16 ChromeNotificationObserver::ChromeNotificationObserver() { |
16 registrar_.Add(this, | 17 registrar_.Add(this, |
17 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 18 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
18 content::NotificationService::AllBrowserContextsAndSources()); | 19 content::NotificationService::AllBrowserContextsAndSources()); |
19 } | 20 } |
20 | 21 |
21 ChromeNotificationObserver::~ChromeNotificationObserver() {} | 22 ChromeNotificationObserver::~ChromeNotificationObserver() {} |
22 | 23 |
23 void ChromeNotificationObserver::OnRendererProcessCreated( | 24 void ChromeNotificationObserver::OnRendererProcessCreated( |
24 content::RenderProcessHost* process) { | 25 content::RenderProcessHost* process) { |
25 // Extensions need to know the channel for API restrictions. Send the channel | 26 // Extensions need to know the channel for API restrictions. Send the channel |
26 // to all renderers, as the non-extension renderers may have content scripts. | 27 // to all renderers, as the non-extension renderers may have content scripts. |
27 process->Send( | 28 process->Send( |
28 new ExtensionMsg_SetChannel(static_cast<int>(GetCurrentChannel()))); | 29 new ExtensionMsg_SetChannel(static_cast<int>(GetCurrentChannel()))); |
| 30 process->Send( |
| 31 new ExtensionMsg_SetExtensionAPIEnabledInExtensionServiceWorkers( |
| 32 feature_util::ExtensionAPIEnabledInExtensionServiceWorkers())); |
29 } | 33 } |
30 | 34 |
31 void ChromeNotificationObserver::Observe(int type, | 35 void ChromeNotificationObserver::Observe(int type, |
32 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
33 const content::NotificationDetails& details) { | 37 const content::NotificationDetails& details) { |
34 switch (type) { | 38 switch (type) { |
35 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { | 39 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
36 content::RenderProcessHost* process = | 40 content::RenderProcessHost* process = |
37 content::Source<content::RenderProcessHost>(source).ptr(); | 41 content::Source<content::RenderProcessHost>(source).ptr(); |
38 OnRendererProcessCreated(process); | 42 OnRendererProcessCreated(process); |
39 break; | 43 break; |
40 } | 44 } |
41 | 45 |
42 default: | 46 default: |
43 NOTREACHED(); | 47 NOTREACHED(); |
44 } | 48 } |
45 } | 49 } |
46 | 50 |
47 } // namespace extensions | 51 } // namespace extensions |
OLD | NEW |