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

Side by Side Diff: extensions/browser/api/device_permissions_prompt.cc

Issue 2266153002: Modify UsbDeviceFilter::MatchesAny to return true for empty filters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed code for unit test Created 4 years, 3 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_device_filter_unittest.cc ('k') | extensions/browser/api/usb/usb_api.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_prompt.h" 5 #include "extensions/browser/api/device_permissions_prompt.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/message_formatter.h" 10 #include "base/i18n/message_formatter.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 } 120 }
121 } 121 }
122 DCHECK(multiple() || devices.size() <= 1); 122 DCHECK(multiple() || devices.size() <= 1);
123 callback_.Run(devices); 123 callback_.Run(devices);
124 callback_.Reset(); 124 callback_.Reset();
125 } 125 }
126 126
127 // device::UsbService::Observer implementation: 127 // device::UsbService::Observer implementation:
128 void OnDeviceAdded(scoped_refptr<UsbDevice> device) override { 128 void OnDeviceAdded(scoped_refptr<UsbDevice> device) override {
129 if (!(filters_.empty() || UsbDeviceFilter::MatchesAny(device, filters_))) { 129 if (!UsbDeviceFilter::MatchesAny(device, filters_))
130 return; 130 return;
131 }
132 131
133 std::unique_ptr<DeviceInfo> device_info(new UsbDeviceInfo(device)); 132 std::unique_ptr<DeviceInfo> device_info(new UsbDeviceInfo(device));
134 device->CheckUsbAccess( 133 device->CheckUsbAccess(
135 base::Bind(&UsbDevicePermissionsPrompt::AddCheckedDevice, this, 134 base::Bind(&UsbDevicePermissionsPrompt::AddCheckedDevice, this,
136 base::Passed(&device_info))); 135 base::Passed(&device_info)));
137 } 136 }
138 137
139 void OnDeviceRemoved(scoped_refptr<UsbDevice> device) override { 138 void OnDeviceRemoved(scoped_refptr<UsbDevice> device) override {
140 for (auto it = devices_.begin(); it != devices_.end(); ++it) { 139 for (auto it = devices_.begin(); it != devices_.end(); ++it) {
141 const UsbDeviceInfo* entry = 140 const UsbDeviceInfo* entry =
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // static 394 // static
396 scoped_refptr<DevicePermissionsPrompt::Prompt> 395 scoped_refptr<DevicePermissionsPrompt::Prompt>
397 DevicePermissionsPrompt::CreateUsbPromptForTest(const Extension* extension, 396 DevicePermissionsPrompt::CreateUsbPromptForTest(const Extension* extension,
398 bool multiple) { 397 bool multiple) {
399 return make_scoped_refptr(new UsbDevicePermissionsPrompt( 398 return make_scoped_refptr(new UsbDevicePermissionsPrompt(
400 extension, nullptr, multiple, std::vector<UsbDeviceFilter>(), 399 extension, nullptr, multiple, std::vector<UsbDeviceFilter>(),
401 base::Bind(&NoopUsbCallback))); 400 base::Bind(&NoopUsbCallback)));
402 } 401 }
403 402
404 } // namespace extensions 403 } // namespace extensions
OLDNEW
« no previous file with comments | « device/usb/usb_device_filter_unittest.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698