| OLD | NEW |
| 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 "chrome/common/cloud_print/cloud_print_cdd_conversion.h" | 5 #include "chrome/common/cloud_print/cloud_print_cdd_conversion.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "components/cloud_devices/common/printer_description.h" | 8 #include "components/cloud_devices/common/printer_description.h" |
| 9 #include "printing/backend/print_backend.h" | 9 #include "printing/backend/print_backend.h" |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 color.AddDefaultOption(standard_color, semantic_info.color_default); | 48 color.AddDefaultOption(standard_color, semantic_info.color_default); |
| 49 } | 49 } |
| 50 if (!semantic_info.color_default || semantic_info.color_changeable) { | 50 if (!semantic_info.color_default || semantic_info.color_changeable) { |
| 51 Color standard_monochrome(STANDARD_MONOCHROME); | 51 Color standard_monochrome(STANDARD_MONOCHROME); |
| 52 standard_monochrome.vendor_id = base::IntToString(semantic_info.bw_model); | 52 standard_monochrome.vendor_id = base::IntToString(semantic_info.bw_model); |
| 53 color.AddDefaultOption(standard_monochrome, !semantic_info.color_default); | 53 color.AddDefaultOption(standard_monochrome, !semantic_info.color_default); |
| 54 } | 54 } |
| 55 color.SaveTo(&description); | 55 color.SaveTo(&description); |
| 56 | 56 |
| 57 if (!semantic_info.papers.empty()) { | 57 if (!semantic_info.papers.empty()) { |
| 58 Media default_media(semantic_info.default_paper.name, | 58 Media default_media(semantic_info.default_paper.display_name, |
| 59 "", | 59 semantic_info.default_paper.vendor_id, |
| 60 semantic_info.default_paper.size_um.width(), | 60 semantic_info.default_paper.size_um.width(), |
| 61 semantic_info.default_paper.size_um.height()); | 61 semantic_info.default_paper.size_um.height()); |
| 62 default_media.MatchBySize(); | 62 default_media.MatchBySize(); |
| 63 | 63 |
| 64 MediaCapability media; | 64 MediaCapability media; |
| 65 bool is_default_set = false; | 65 bool is_default_set = false; |
| 66 for (size_t i = 0; i < semantic_info.papers.size(); ++i) { | 66 for (size_t i = 0; i < semantic_info.papers.size(); ++i) { |
| 67 gfx::Size paper_size = semantic_info.papers[i].size_um; | 67 gfx::Size paper_size = semantic_info.papers[i].size_um; |
| 68 if (paper_size.width() > paper_size.height()) | 68 if (paper_size.width() > paper_size.height()) |
| 69 paper_size.SetSize(paper_size.height(), paper_size.width()); | 69 paper_size.SetSize(paper_size.height(), paper_size.width()); |
| 70 Media new_media(semantic_info.papers[i].name, | 70 Media new_media(semantic_info.papers[i].display_name, |
| 71 "", | 71 semantic_info.papers[i].vendor_id, |
| 72 paper_size.width(), | 72 paper_size.width(), |
| 73 paper_size.height()); | 73 paper_size.height()); |
| 74 new_media.MatchBySize(); | 74 new_media.MatchBySize(); |
| 75 if (new_media.IsValid() && !media.Contains(new_media)) { | 75 if (new_media.IsValid() && !media.Contains(new_media)) { |
| 76 if (!default_media.IsValid()) | 76 if (!default_media.IsValid()) |
| 77 default_media = new_media; | 77 default_media = new_media; |
| 78 media.AddDefaultOption(new_media, new_media == default_media); | 78 media.AddDefaultOption(new_media, new_media == default_media); |
| 79 is_default_set = is_default_set || (new_media == default_media); | 79 is_default_set = is_default_set || (new_media == default_media); |
| 80 } | 80 } |
| 81 } | 81 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 OrientationCapability orientation; | 116 OrientationCapability orientation; |
| 117 orientation.AddDefaultOption(PORTRAIT, true); | 117 orientation.AddDefaultOption(PORTRAIT, true); |
| 118 orientation.AddOption(LANDSCAPE); | 118 orientation.AddOption(LANDSCAPE); |
| 119 orientation.AddOption(AUTO_ORIENTATION); | 119 orientation.AddOption(AUTO_ORIENTATION); |
| 120 orientation.SaveTo(&description); | 120 orientation.SaveTo(&description); |
| 121 | 121 |
| 122 return scoped_ptr<base::DictionaryValue>(description.root().DeepCopy()); | 122 return scoped_ptr<base::DictionaryValue>(description.root().DeepCopy()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace cloud_print | 125 } // namespace cloud_print |
| OLD | NEW |