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

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

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::unique_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(std::move(device_entry));
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;
114 } 114 }
115 int vendor_id; 115 int vendor_id;
(...skipping 608 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

Powered by Google App Engine
This is Rietveld 408576698