OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/media_devices_selection_handler.h" | 5 #include "chrome/browser/ui/webui/options/media_devices_selection_handler.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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 case VIDEO: | 105 case VIDEO: |
103 default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice); | 106 default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice); |
104 device_type = kVideo; | 107 device_type = kVideo; |
105 break; | 108 break; |
106 } | 109 } |
107 | 110 |
108 // Build the list of devices to send to JS. | 111 // Build the list of devices to send to JS. |
109 std::string default_id; | 112 std::string default_id; |
110 base::ListValue device_list; | 113 base::ListValue device_list; |
111 for (size_t i = 0; i < devices.size(); ++i) { | 114 for (size_t i = 0; i < devices.size(); ++i) { |
112 base::DictionaryValue* entry = new base::DictionaryValue(); | 115 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
113 entry->SetString("name", devices[i].name); | 116 entry->SetString("name", devices[i].name); |
114 entry->SetString("id", devices[i].id); | 117 entry->SetString("id", devices[i].id); |
115 device_list.Append(entry); | 118 device_list.Append(std::move(entry)); |
116 if (devices[i].id == default_device) | 119 if (devices[i].id == default_device) |
117 default_id = default_device; | 120 default_id = default_device; |
118 } | 121 } |
119 | 122 |
120 // Use the first device as the default device if the preferred default device | 123 // Use the first device as the default device if the preferred default device |
121 // does not exist in the OS. | 124 // does not exist in the OS. |
122 if (!devices.empty() && default_id.empty()) | 125 if (!devices.empty() && default_id.empty()) |
123 default_id = devices[0].id; | 126 default_id = devices[0].id; |
124 | 127 |
125 base::StringValue default_value(default_id); | 128 base::StringValue default_value(default_id); |
(...skipping 13 matching lines...) Expand all Loading... |
139 case VIDEO: | 142 case VIDEO: |
140 devices = MediaCaptureDevicesDispatcher::GetInstance()-> | 143 devices = MediaCaptureDevicesDispatcher::GetInstance()-> |
141 GetVideoCaptureDevices(); | 144 GetVideoCaptureDevices(); |
142 break; | 145 break; |
143 } | 146 } |
144 | 147 |
145 UpdateDevicesMenu(type, devices); | 148 UpdateDevicesMenu(type, devices); |
146 } | 149 } |
147 | 150 |
148 } // namespace options | 151 } // namespace options |
OLD | NEW |