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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc

Issue 174513003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 // 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/api/webrtc_audio_private/webrtc_audio_privat e_api.h" 5 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
(...skipping 14 matching lines...) Expand all
25 using media::AudioDeviceNames; 25 using media::AudioDeviceNames;
26 using media::AudioManager; 26 using media::AudioManager;
27 27
28 namespace wap = api::webrtc_audio_private; 28 namespace wap = api::webrtc_audio_private;
29 29
30 static base::LazyInstance< 30 static base::LazyInstance<
31 ProfileKeyedAPIFactory<WebrtcAudioPrivateEventService> > g_factory = 31 ProfileKeyedAPIFactory<WebrtcAudioPrivateEventService> > g_factory =
32 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
33 33
34 WebrtcAudioPrivateEventService::WebrtcAudioPrivateEventService( 34 WebrtcAudioPrivateEventService::WebrtcAudioPrivateEventService(
35 Profile* profile) : profile_(profile) { 35 content::BrowserContext* context)
36 : browser_context_(context) {
36 // In unit tests, the SystemMonitor may not be created. 37 // In unit tests, the SystemMonitor may not be created.
37 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); 38 base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
38 if (system_monitor) 39 if (system_monitor)
39 system_monitor->AddDevicesChangedObserver(this); 40 system_monitor->AddDevicesChangedObserver(this);
40 } 41 }
41 42
42 WebrtcAudioPrivateEventService::~WebrtcAudioPrivateEventService() { 43 WebrtcAudioPrivateEventService::~WebrtcAudioPrivateEventService() {
43 } 44 }
44 45
45 void WebrtcAudioPrivateEventService::Shutdown() { 46 void WebrtcAudioPrivateEventService::Shutdown() {
(...skipping 24 matching lines...) Expand all
70 71
71 default: 72 default:
72 // No action needed. 73 // No action needed.
73 break; 74 break;
74 } 75 }
75 } 76 }
76 77
77 void WebrtcAudioPrivateEventService::SignalEvent() { 78 void WebrtcAudioPrivateEventService::SignalEvent() {
78 using api::webrtc_audio_private::OnSinksChanged::kEventName; 79 using api::webrtc_audio_private::OnSinksChanged::kEventName;
79 80
80 EventRouter* router = 81 EventRouter* router = ExtensionSystem::Get(browser_context_)->event_router();
81 ExtensionSystem::Get(profile_)->event_router();
82 if (!router || !router->HasEventListener(kEventName)) 82 if (!router || !router->HasEventListener(kEventName))
83 return; 83 return;
84 ExtensionService* extension_service = 84 ExtensionService* extension_service =
85 ExtensionSystem::Get(profile_)->extension_service(); 85 ExtensionSystem::Get(browser_context_)->extension_service();
86 const ExtensionSet* extensions = extension_service->extensions(); 86 const ExtensionSet* extensions = extension_service->extensions();
87 for (ExtensionSet::const_iterator it = extensions->begin(); 87 for (ExtensionSet::const_iterator it = extensions->begin();
88 it != extensions->end(); ++it) { 88 it != extensions->end(); ++it) {
89 const std::string& extension_id = (*it)->id(); 89 const std::string& extension_id = (*it)->id();
90 if (router->ExtensionHasEventListener(extension_id, kEventName) && 90 if (router->ExtensionHasEventListener(extension_id, kEventName) &&
91 (*it)->HasAPIPermission("webrtcAudioPrivate")) { 91 (*it)->HasAPIPermission("webrtcAudioPrivate")) {
92 scoped_ptr<Event> event( 92 scoped_ptr<Event> event(
93 new Event(kEventName, make_scoped_ptr(new base::ListValue()).Pass())); 93 new Event(kEventName, make_scoped_ptr(new base::ListValue()).Pass()));
94 router->DispatchEventToExtension(extension_id, event.Pass()); 94 router->DispatchEventToExtension(extension_id, event.Pass());
95 } 95 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 results_.reset(wap::GetAssociatedSink::Results::Create("").release()); 473 results_.reset(wap::GetAssociatedSink::Results::Create("").release());
474 } else { 474 } else {
475 results_.reset( 475 results_.reset(
476 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); 476 wap::GetAssociatedSink::Results::Create(associated_sink_id).release());
477 } 477 }
478 478
479 SendResponse(true); 479 SendResponse(true);
480 } 480 }
481 481
482 } // namespace extensions 482 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698