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

Side by Side Diff: printing/print_settings_conversion.cc

Issue 2285933003: Remove more usage of the base::ListValue::Append(Value*) overload. (Closed)
Patch Set: rebase 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 | « google_apis/drive/drive_api_requests.cc ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "printing/print_settings_conversion.h" 5 #include "printing/print_settings_conversion.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <memory>
11 #include <string> 12 #include <string>
13 #include <utility>
12 14
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 17 #include "base/time/time.h"
16 #include "base/values.h" 18 #include "base/values.h"
17 #include "printing/page_size_margins.h" 19 #include "printing/page_size_margins.h"
18 #include "printing/print_job_constants.h" 20 #include "printing/print_job_constants.h"
19 #include "printing/print_settings.h" 21 #include "printing/print_settings.h"
20 #include "printing/units.h" 22 #include "printing/units.h"
21 23
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 job_settings->SetString(kSettingHeaderFooterURL, settings.url()); 211 job_settings->SetString(kSettingHeaderFooterURL, settings.url());
210 job_settings->SetBoolean(kSettingShouldPrintBackgrounds, 212 job_settings->SetBoolean(kSettingShouldPrintBackgrounds,
211 settings.should_print_backgrounds()); 213 settings.should_print_backgrounds());
212 job_settings->SetBoolean(kSettingShouldPrintSelectionOnly, 214 job_settings->SetBoolean(kSettingShouldPrintSelectionOnly,
213 settings.selection_only()); 215 settings.selection_only());
214 job_settings->SetInteger(kSettingMarginsType, settings.margin_type()); 216 job_settings->SetInteger(kSettingMarginsType, settings.margin_type());
215 if (!settings.ranges().empty()) { 217 if (!settings.ranges().empty()) {
216 base::ListValue* page_range_array = new base::ListValue; 218 base::ListValue* page_range_array = new base::ListValue;
217 job_settings->Set(kSettingPageRange, page_range_array); 219 job_settings->Set(kSettingPageRange, page_range_array);
218 for (size_t i = 0; i < settings.ranges().size(); ++i) { 220 for (size_t i = 0; i < settings.ranges().size(); ++i) {
219 base::DictionaryValue* dict = new base::DictionaryValue; 221 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
220 page_range_array->Append(dict);
221 dict->SetInteger(kSettingPageRangeFrom, settings.ranges()[i].from + 1); 222 dict->SetInteger(kSettingPageRangeFrom, settings.ranges()[i].from + 1);
222 dict->SetInteger(kSettingPageRangeTo, settings.ranges()[i].to + 1); 223 dict->SetInteger(kSettingPageRangeTo, settings.ranges()[i].to + 1);
224 page_range_array->Append(std::move(dict));
223 } 225 }
224 } 226 }
225 227
226 job_settings->SetBoolean(kSettingCollate, settings.collate()); 228 job_settings->SetBoolean(kSettingCollate, settings.collate());
227 job_settings->SetInteger(kSettingCopies, settings.copies()); 229 job_settings->SetInteger(kSettingCopies, settings.copies());
228 job_settings->SetInteger(kSettingColor, settings.color()); 230 job_settings->SetInteger(kSettingColor, settings.color());
229 job_settings->SetInteger(kSettingDuplexMode, settings.duplex_mode()); 231 job_settings->SetInteger(kSettingDuplexMode, settings.duplex_mode());
230 job_settings->SetBoolean(kSettingLandscape, settings.landscape()); 232 job_settings->SetBoolean(kSettingLandscape, settings.landscape());
231 job_settings->SetString(kSettingDeviceName, settings.device_name()); 233 job_settings->SetString(kSettingDeviceName, settings.device_name());
232 234
(...skipping 14 matching lines...) Expand all
247 const PageSetup& page_setup = settings.page_setup_device_units(); 249 const PageSetup& page_setup = settings.page_setup_device_units();
248 SetMarginsToJobSettings( 250 SetMarginsToJobSettings(
249 "effective_margins", page_setup.effective_margins(), debug); 251 "effective_margins", page_setup.effective_margins(), debug);
250 SetSizeToJobSettings("physical_size", page_setup.physical_size(), debug); 252 SetSizeToJobSettings("physical_size", page_setup.physical_size(), debug);
251 SetRectToJobSettings("overlay_area", page_setup.overlay_area(), debug); 253 SetRectToJobSettings("overlay_area", page_setup.overlay_area(), debug);
252 SetRectToJobSettings("content_area", page_setup.content_area(), debug); 254 SetRectToJobSettings("content_area", page_setup.content_area(), debug);
253 SetRectToJobSettings("printable_area", page_setup.printable_area(), debug); 255 SetRectToJobSettings("printable_area", page_setup.printable_area(), debug);
254 } 256 }
255 257
256 } // namespace printing 258 } // namespace printing
OLDNEW
« no previous file with comments | « google_apis/drive/drive_api_requests.cc ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698