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

Side by Side Diff: chrome/browser/usb/web_usb_permission_provider.cc

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/usb/web_usb_permission_provider.h" 5 #include "chrome/browser/usb/web_usb_permission_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 16 matching lines...) Expand all
27 bool FindOriginInDescriptorSet(const device::WebUsbAllowedOrigins* set, 27 bool FindOriginInDescriptorSet(const device::WebUsbAllowedOrigins* set,
28 const GURL& origin, 28 const GURL& origin,
29 const uint8_t* configuration_value, 29 const uint8_t* configuration_value,
30 const uint8_t* first_interface) { 30 const uint8_t* first_interface) {
31 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 31 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kDisableWebUsbSecurity)) 32 switches::kDisableWebUsbSecurity))
33 return true; 33 return true;
34 34
35 if (!set) 35 if (!set)
36 return false; 36 return false;
37 if (ContainsValue(set->origins, origin)) 37 if (base::ContainsValue(set->origins, origin))
38 return true; 38 return true;
39 for (const auto& configuration : set->configurations) { 39 for (const auto& configuration : set->configurations) {
40 if (configuration_value && 40 if (configuration_value &&
41 *configuration_value != configuration.configuration_value) 41 *configuration_value != configuration.configuration_value)
42 continue; 42 continue;
43 if (ContainsValue(configuration.origins, origin)) 43 if (base::ContainsValue(configuration.origins, origin))
44 return true; 44 return true;
45 for (const auto& function : configuration.functions) { 45 for (const auto& function : configuration.functions) {
46 if (first_interface && *first_interface != function.first_interface) 46 if (first_interface && *first_interface != function.first_interface)
47 continue; 47 continue;
48 if (ContainsValue(function.origins, origin)) 48 if (base::ContainsValue(function.origins, origin))
49 return true; 49 return true;
50 } 50 }
51 } 51 }
52 return false; 52 return false;
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 WebUSBPermissionProvider::WebUSBPermissionProvider( 57 WebUSBPermissionProvider::WebUSBPermissionProvider(
58 content::RenderFrameHost* render_frame_host) 58 content::RenderFrameHost* render_frame_host)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 tab_helper->IncrementConnectionCount(render_frame_host_); 127 tab_helper->IncrementConnectionCount(render_frame_host_);
128 } 128 }
129 129
130 void WebUSBPermissionProvider::DecrementConnectionCount() { 130 void WebUSBPermissionProvider::DecrementConnectionCount() {
131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
132 WebContents* web_contents = 132 WebContents* web_contents =
133 WebContents::FromRenderFrameHost(render_frame_host_); 133 WebContents::FromRenderFrameHost(render_frame_host_);
134 UsbTabHelper* tab_helper = UsbTabHelper::FromWebContents(web_contents); 134 UsbTabHelper* tab_helper = UsbTabHelper::FromWebContents(web_contents);
135 tab_helper->DecrementConnectionCount(render_frame_host_); 135 tab_helper->DecrementConnectionCount(render_frame_host_);
136 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/usb_chooser_context.cc ('k') | chrome/common/component_flash_hint_file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698