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

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

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void SaveDevicePermissionEntry(BrowserContext* context, 93 void SaveDevicePermissionEntry(BrowserContext* context,
94 const std::string& extension_id, 94 const std::string& extension_id,
95 scoped_refptr<DevicePermissionEntry> entry) { 95 scoped_refptr<DevicePermissionEntry> entry) {
96 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); 96 ExtensionPrefs* prefs = ExtensionPrefs::Get(context);
97 ExtensionPrefs::ScopedListUpdate update(prefs, extension_id, kDevices); 97 ExtensionPrefs::ScopedListUpdate update(prefs, extension_id, kDevices);
98 base::ListValue* devices = update.Get(); 98 base::ListValue* devices = update.Get();
99 if (!devices) { 99 if (!devices) {
100 devices = update.Create(); 100 devices = update.Create();
101 } 101 }
102 102
103 scoped_ptr<base::Value> device_entry(entry->ToValue()); 103 std::unique_ptr<base::Value> device_entry(entry->ToValue());
104 DCHECK(devices->Find(*device_entry.get()) == devices->end()); 104 DCHECK(devices->Find(*device_entry.get()) == devices->end());
105 devices->Append(device_entry.release()); 105 devices->Append(device_entry.release());
106 } 106 }
107 107
108 bool MatchesDevicePermissionEntry(const base::DictionaryValue* value, 108 bool MatchesDevicePermissionEntry(const base::DictionaryValue* value,
109 scoped_refptr<DevicePermissionEntry> entry) { 109 scoped_refptr<DevicePermissionEntry> entry) {
110 std::string type; 110 std::string type;
111 if (!value->GetStringWithoutPathExpansion(kDeviceType, &type) || 111 if (!value->GetStringWithoutPathExpansion(kDeviceType, &type) ||
112 type != TypeToString(entry->type())) { 112 type != TypeToString(entry->type())) {
113 return false; 113 return false;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 last_used_(last_used) { 304 last_used_(last_used) {
305 } 305 }
306 306
307 DevicePermissionEntry::~DevicePermissionEntry() { 307 DevicePermissionEntry::~DevicePermissionEntry() {
308 } 308 }
309 309
310 bool DevicePermissionEntry::IsPersistent() const { 310 bool DevicePermissionEntry::IsPersistent() const {
311 return !serial_number_.empty(); 311 return !serial_number_.empty();
312 } 312 }
313 313
314 scoped_ptr<base::Value> DevicePermissionEntry::ToValue() const { 314 std::unique_ptr<base::Value> DevicePermissionEntry::ToValue() const {
315 if (!IsPersistent()) { 315 if (!IsPersistent()) {
316 return nullptr; 316 return nullptr;
317 } 317 }
318 318
319 DCHECK(!serial_number_.empty()); 319 DCHECK(!serial_number_.empty());
320 scoped_ptr<base::DictionaryValue> entry_dict( 320 std::unique_ptr<base::DictionaryValue> entry_dict(
321 DictionaryBuilder() 321 DictionaryBuilder()
322 .Set(kDeviceType, TypeToString(type_)) 322 .Set(kDeviceType, TypeToString(type_))
323 .Set(kDeviceVendorId, vendor_id_) 323 .Set(kDeviceVendorId, vendor_id_)
324 .Set(kDeviceProductId, product_id_) 324 .Set(kDeviceProductId, product_id_)
325 .Set(kDeviceSerialNumber, serial_number_) 325 .Set(kDeviceSerialNumber, serial_number_)
326 .Build()); 326 .Build());
327 327
328 if (!manufacturer_string_.empty()) { 328 if (!manufacturer_string_.empty()) {
329 entry_dict->SetStringWithoutPathExpansion(kDeviceManufacturerString, 329 entry_dict->SetStringWithoutPathExpansion(kDeviceManufacturerString,
330 manufacturer_string_); 330 manufacturer_string_);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 BrowserContext* DevicePermissionsManagerFactory::GetBrowserContextToUse( 725 BrowserContext* DevicePermissionsManagerFactory::GetBrowserContextToUse(
726 BrowserContext* context) const { 726 BrowserContext* context) const {
727 // Return the original (possibly off-the-record) browser context so that a 727 // Return the original (possibly off-the-record) browser context so that a
728 // separate instance of the DevicePermissionsManager is used in incognito 728 // separate instance of the DevicePermissionsManager is used in incognito
729 // mode. The parent class's implemenation returns NULL. 729 // mode. The parent class's implemenation returns NULL.
730 return context; 730 return context;
731 } 731 }
732 732
733 } // namespace extensions 733 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/device_permissions_manager.h ('k') | extensions/browser/api/device_permissions_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698