OLD | NEW |
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 "extensions/browser/api/device_permissions_manager.h" | 5 #include "extensions/browser/api/device_permissions_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 void Start() { | 392 void Start() { |
393 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 393 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
394 UsbService* service = device::DeviceClient::Get()->GetUsbService(); | 394 UsbService* service = device::DeviceClient::Get()->GetUsbService(); |
395 if (service) { | 395 if (service) { |
396 observer_.Add(service); | 396 observer_.Add(service); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
400 private: | 400 private: |
401 void OnDeviceRemoved(scoped_refptr<UsbDevice> device) override { | 401 void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device) override { |
402 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 402 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
403 BrowserThread::PostTask( | 403 BrowserThread::PostTask( |
404 BrowserThread::UI, FROM_HERE, | 404 BrowserThread::UI, FROM_HERE, |
405 base::Bind(&DevicePermissionsManager::OnDeviceRemoved, | 405 base::Bind(&DevicePermissionsManager::OnDeviceRemoved, |
406 device_permissions_manager_, device)); | 406 device_permissions_manager_, device)); |
407 } | 407 } |
408 | 408 |
409 base::WeakPtr<DevicePermissionsManager> device_permissions_manager_; | 409 base::WeakPtr<DevicePermissionsManager> device_permissions_manager_; |
410 ScopedObserver<UsbService, UsbService::Observer> observer_; | 410 ScopedObserver<UsbService, UsbService::Observer> observer_; |
411 }; | 411 }; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 624 |
625 BrowserContext* DevicePermissionsManagerFactory::GetBrowserContextToUse( | 625 BrowserContext* DevicePermissionsManagerFactory::GetBrowserContextToUse( |
626 BrowserContext* context) const { | 626 BrowserContext* context) const { |
627 // Return the original (possibly off-the-record) browser context so that a | 627 // Return the original (possibly off-the-record) browser context so that a |
628 // separate instance of the DevicePermissionsManager is used in incognito | 628 // separate instance of the DevicePermissionsManager is used in incognito |
629 // mode. The parent class's implemenation returns NULL. | 629 // mode. The parent class's implemenation returns NULL. |
630 return context; | 630 return context; |
631 } | 631 } |
632 | 632 |
633 } // namespace extensions | 633 } // namespace extensions |
OLD | NEW |