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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_private_api.cc

Issue 238633009: cleanup: Use EventRouter instead of ExtensionSystem::Get->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error for chromeos build. Created 6 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bluetooth/bluetooth_private_api.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_private_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" 11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
12 #include "chrome/common/extensions/api/bluetooth_private.h" 12 #include "chrome/common/extensions/api/bluetooth_private.h"
13 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
14 #include "device/bluetooth/bluetooth_adapter_factory.h" 14 #include "device/bluetooth/bluetooth_adapter_factory.h"
15 #include "extensions/browser/extension_system.h"
16 15
17 namespace bt_private = extensions::api::bluetooth_private; 16 namespace bt_private = extensions::api::bluetooth_private;
18 17
19 namespace extensions { 18 namespace extensions {
20 19
21 static base::LazyInstance<BrowserContextKeyedAPIFactory<BluetoothPrivateAPI> > 20 static base::LazyInstance<BrowserContextKeyedAPIFactory<BluetoothPrivateAPI> >
22 g_factory = LAZY_INSTANCE_INITIALIZER; 21 g_factory = LAZY_INSTANCE_INITIALIZER;
23 22
24 // static 23 // static
25 BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>* 24 BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>*
26 BluetoothPrivateAPI::GetFactoryInstance() { 25 BluetoothPrivateAPI::GetFactoryInstance() {
27 return g_factory.Pointer(); 26 return g_factory.Pointer();
28 } 27 }
29 28
30 BluetoothPrivateAPI::BluetoothPrivateAPI(content::BrowserContext* context) 29 BluetoothPrivateAPI::BluetoothPrivateAPI(content::BrowserContext* context)
31 : browser_context_(context) { 30 : browser_context_(context) {
32 ExtensionSystem::Get(browser_context_)->event_router()->RegisterObserver( 31 EventRouter::Get(browser_context_)
33 this, bt_private::OnPairing::kEventName); 32 ->RegisterObserver(this, bt_private::OnPairing::kEventName);
34 } 33 }
35 34
36 BluetoothPrivateAPI::~BluetoothPrivateAPI() {} 35 BluetoothPrivateAPI::~BluetoothPrivateAPI() {}
37 36
38 void BluetoothPrivateAPI::Shutdown() { 37 void BluetoothPrivateAPI::Shutdown() {
39 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver( 38 EventRouter::Get(browser_context_)->UnregisterObserver(this);
40 this);
41 } 39 }
42 40
43 void BluetoothPrivateAPI::OnListenerAdded(const EventListenerInfo& details) { 41 void BluetoothPrivateAPI::OnListenerAdded(const EventListenerInfo& details) {
44 // This function can be called multiple times for the same JS listener, for 42 // This function can be called multiple times for the same JS listener, for
45 // example, once for the addListener call and again if it is a lazy listener. 43 // example, once for the addListener call and again if it is a lazy listener.
46 if (!details.browser_context) 44 if (!details.browser_context)
47 return; 45 return;
48 46
49 BluetoothAPI::Get(browser_context_)->event_router()->AddPairingDelegate( 47 BluetoothAPI::Get(browser_context_)->event_router()->AddPairingDelegate(
50 details.extension_id); 48 details.extension_id);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 272 }
275 } 273 }
276 274
277 SendResponse(true); 275 SendResponse(true);
278 return true; 276 return true;
279 } 277 }
280 278
281 } // namespace api 279 } // namespace api
282 280
283 } // namespace extensions 281 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698