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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/settings/settings_media_devices_selection_hand ler.h" 5 #include "chrome/browser/ui/webui/settings/settings_media_devices_selection_hand ler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10 #include <utility>
11
9 #include "base/bind.h" 12 #include "base/bind.h"
10 #include "base/macros.h" 13 #include "base/macros.h"
11 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
13 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
14 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
15 18
16 namespace { 19 namespace {
17 20
18 const char kAudio[] = "mic"; 21 const char kAudio[] = "mic";
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 case VIDEO: 113 case VIDEO:
111 default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice); 114 default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice);
112 device_type = kVideo; 115 device_type = kVideo;
113 break; 116 break;
114 } 117 }
115 118
116 // Build the list of devices to send to JS. 119 // Build the list of devices to send to JS.
117 std::string default_id; 120 std::string default_id;
118 base::ListValue device_list; 121 base::ListValue device_list;
119 for (size_t i = 0; i < devices.size(); ++i) { 122 for (size_t i = 0; i < devices.size(); ++i) {
120 base::DictionaryValue* entry = new base::DictionaryValue(); 123 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
121 entry->SetString("name", devices[i].name); 124 entry->SetString("name", devices[i].name);
122 entry->SetString("id", devices[i].id); 125 entry->SetString("id", devices[i].id);
123 device_list.Append(entry); 126 device_list.Append(std::move(entry));
124 if (devices[i].id == default_device) 127 if (devices[i].id == default_device)
125 default_id = default_device; 128 default_id = default_device;
126 } 129 }
127 130
128 // Use the first device as the default device if the preferred default device 131 // Use the first device as the default device if the preferred default device
129 // does not exist in the OS. 132 // does not exist in the OS.
130 if (!devices.empty() && default_id.empty()) 133 if (!devices.empty() && default_id.empty())
131 default_id = devices[0].id; 134 default_id = devices[0].id;
132 135
133 base::StringValue default_value(default_id); 136 base::StringValue default_value(default_id);
(...skipping 15 matching lines...) Expand all
149 case VIDEO: 152 case VIDEO:
150 devices = MediaCaptureDevicesDispatcher::GetInstance()-> 153 devices = MediaCaptureDevicesDispatcher::GetInstance()->
151 GetVideoCaptureDevices(); 154 GetVideoCaptureDevices();
152 break; 155 break;
153 } 156 }
154 157
155 UpdateDevicesMenu(type, devices); 158 UpdateDevicesMenu(type, devices);
156 } 159 }
157 160
158 } // namespace settings 161 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698