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: extensions/browser/api/device_permissions_manager.cc

Issue 891853002: Add a UsbService::Observer function for cleanup actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « device/usb/usb_service.cc ('k') | extensions/browser/api/usb/usb_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « device/usb/usb_service.cc ('k') | extensions/browser/api/usb/usb_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698