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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_event_router.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_event_router.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
26 #include "device/bluetooth/bluetooth_adapter.h" 26 #include "device/bluetooth/bluetooth_adapter.h"
27 #include "device/bluetooth/bluetooth_adapter_factory.h" 27 #include "device/bluetooth/bluetooth_adapter_factory.h"
28 #include "device/bluetooth/bluetooth_device.h" 28 #include "device/bluetooth/bluetooth_device.h"
29 #include "device/bluetooth/bluetooth_discovery_session.h" 29 #include "device/bluetooth/bluetooth_discovery_session.h"
30 #include "device/bluetooth/bluetooth_profile.h" 30 #include "device/bluetooth/bluetooth_profile.h"
31 #include "device/bluetooth/bluetooth_socket.h" 31 #include "device/bluetooth/bluetooth_socket.h"
32 #include "extensions/browser/event_router.h" 32 #include "extensions/browser/event_router.h"
33 #include "extensions/browser/extension_host.h" 33 #include "extensions/browser/extension_host.h"
34 #include "extensions/browser/extension_system.h"
35 34
36 namespace extensions { 35 namespace extensions {
37 36
38 namespace bluetooth = api::bluetooth; 37 namespace bluetooth = api::bluetooth;
39 namespace bt_private = api::bluetooth_private; 38 namespace bt_private = api::bluetooth_private;
40 39
41 // A struct storing a Bluetooth profile and the extension that added it. 40 // A struct storing a Bluetooth profile and the extension that added it.
42 struct BluetoothEventRouter::ExtensionBluetoothProfileRecord { 41 struct BluetoothEventRouter::ExtensionBluetoothProfileRecord {
43 std::string extension_id; 42 std::string extension_id;
44 device::BluetoothProfile* profile; 43 device::BluetoothProfile* profile;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 void BluetoothEventRouter::DispatchAdapterStateEvent() { 328 void BluetoothEventRouter::DispatchAdapterStateEvent() {
330 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 329 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
331 api::bluetooth::AdapterState state; 330 api::bluetooth::AdapterState state;
332 PopulateAdapterState(*adapter_.get(), &state); 331 PopulateAdapterState(*adapter_.get(), &state);
333 332
334 scoped_ptr<base::ListValue> args = 333 scoped_ptr<base::ListValue> args =
335 bluetooth::OnAdapterStateChanged::Create(state); 334 bluetooth::OnAdapterStateChanged::Create(state);
336 scoped_ptr<Event> event(new Event( 335 scoped_ptr<Event> event(new Event(
337 bluetooth::OnAdapterStateChanged::kEventName, 336 bluetooth::OnAdapterStateChanged::kEventName,
338 args.Pass())); 337 args.Pass()));
339 ExtensionSystem::Get(browser_context_)->event_router()->BroadcastEvent( 338 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
340 event.Pass());
341 } 339 }
342 340
343 void BluetoothEventRouter::DispatchDeviceEvent( 341 void BluetoothEventRouter::DispatchDeviceEvent(
344 const std::string& event_name, 342 const std::string& event_name,
345 device::BluetoothDevice* device) { 343 device::BluetoothDevice* device) {
346 bluetooth::Device extension_device; 344 bluetooth::Device extension_device;
347 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); 345 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device);
348 346
349 scoped_ptr<base::ListValue> args = 347 scoped_ptr<base::ListValue> args =
350 bluetooth::OnDeviceAdded::Create(extension_device); 348 bluetooth::OnDeviceAdded::Create(extension_device);
351 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 349 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
352 ExtensionSystem::Get(browser_context_)->event_router()->BroadcastEvent( 350 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
353 event.Pass());
354 } 351 }
355 352
356 void BluetoothEventRouter::CleanUpForExtension( 353 void BluetoothEventRouter::CleanUpForExtension(
357 const std::string& extension_id) { 354 const std::string& extension_id) {
358 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 355 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
359 RemovePairingDelegate(extension_id); 356 RemovePairingDelegate(extension_id);
360 357
361 // Remove all profiles added by the extension. 358 // Remove all profiles added by the extension.
362 BluetoothProfileMap::iterator profile_iter = bluetooth_profile_map_.begin(); 359 BluetoothProfileMap::iterator profile_iter = bluetooth_profile_map_.begin();
363 while (profile_iter != bluetooth_profile_map_.end()) { 360 while (profile_iter != bluetooth_profile_map_.end()) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 423 }
427 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 424 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
428 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 425 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
429 CleanUpForExtension(host->extension_id()); 426 CleanUpForExtension(host->extension_id());
430 break; 427 break;
431 } 428 }
432 } 429 }
433 } 430 }
434 431
435 } // namespace extensions 432 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698