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

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

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky 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 | « chrome/browser/sync_file_system/local/local_file_sync_context.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/usb_chooser_context.h" 5 #include "chrome/browser/usb/usb_chooser_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 for (const auto& map_entry : ephemeral_devices_) { 94 for (const auto& map_entry : ephemeral_devices_) {
95 const GURL& requesting_origin = map_entry.first.first; 95 const GURL& requesting_origin = map_entry.first.first;
96 const GURL& embedding_origin = map_entry.first.second; 96 const GURL& embedding_origin = map_entry.first.second;
97 for (const std::string& guid : map_entry.second) { 97 for (const std::string& guid : map_entry.second) {
98 scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid); 98 scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid);
99 DCHECK(device); 99 DCHECK(device);
100 base::DictionaryValue object; 100 base::DictionaryValue object;
101 object.SetString(kDeviceNameKey, device->product_string()); 101 object.SetString(kDeviceNameKey, device->product_string());
102 object.SetString(kGuidKey, device->guid()); 102 object.SetString(kGuidKey, device->guid());
103 objects.push_back(base::WrapUnique(new ChooserContextBase::Object( 103 objects.push_back(base::MakeUnique<ChooserContextBase::Object>(
104 requesting_origin, embedding_origin, &object, "preference", 104 requesting_origin, embedding_origin, &object, "preference",
105 is_incognito_))); 105 is_incognito_));
106 } 106 }
107 } 107 }
108 108
109 return objects; 109 return objects;
110 } 110 }
111 111
112 void UsbChooserContext::RevokeObjectPermission( 112 void UsbChooserContext::RevokeObjectPermission(
113 const GURL& requesting_origin, 113 const GURL& requesting_origin,
114 const GURL& embedding_origin, 114 const GURL& embedding_origin,
115 const base::DictionaryValue& object) { 115 const base::DictionaryValue& object) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { 186 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) {
187 return object.size() == 4 && object.HasKey(kDeviceNameKey) && 187 return object.size() == 4 && object.HasKey(kDeviceNameKey) &&
188 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && 188 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) &&
189 object.HasKey(kSerialNumberKey); 189 object.HasKey(kSerialNumberKey);
190 } 190 }
191 191
192 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 192 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
193 for (auto& map_entry : ephemeral_devices_) 193 for (auto& map_entry : ephemeral_devices_)
194 map_entry.second.erase(device->guid()); 194 map_entry.second.erase(device->guid());
195 } 195 }
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/local/local_file_sync_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698