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

Side by Side Diff: chrome/browser/extensions/chrome_notification_observer.cc

Issue 2141703003: [Extensions] Clean up renderer channel-related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_feature_no_filter
Patch Set: Test fix Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/chrome_notification_observer.h"
6
7 #include "content/public/browser/notification_service.h"
8 #include "content/public/browser/notification_types.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "extensions/common/extension_messages.h"
11 #include "extensions/common/features/feature_channel.h"
12
13 namespace extensions {
14
15 ChromeNotificationObserver::ChromeNotificationObserver() {
16 registrar_.Add(this,
17 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
18 content::NotificationService::AllBrowserContextsAndSources());
19 }
20
21 ChromeNotificationObserver::~ChromeNotificationObserver() {}
22
23 void ChromeNotificationObserver::OnRendererProcessCreated(
24 content::RenderProcessHost* process) {
25 // 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 process->Send(
28 new ExtensionMsg_SetChannel(static_cast<int>(GetCurrentChannel())));
29 }
30
31 void ChromeNotificationObserver::Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) {
34 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CREATED, type);
35
36 OnRendererProcessCreated(
37 content::Source<content::RenderProcessHost>(source).ptr());
38 }
39
40 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698