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

Side by Side Diff: chrome/common/cloud_print/cloud_print_cdd_conversion.cc

Issue 325313003: Add vendor id and custom display name to media selection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address cl comments. Created 6 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 | Annotate | Revision Log
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 "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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 standard_color.vendor_id = base::IntToString(semantic_info.color_model); 47 standard_color.vendor_id = base::IntToString(semantic_info.color_model);
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 defined(OS_WIN)
58 if (!semantic_info.papers.empty()) { 57 if (!semantic_info.papers.empty()) {
59 Media default_media(semantic_info.default_paper.name, 58 Media default_media(semantic_info.default_paper.name,
59 "",
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, paper_size.width(), 70 Media new_media(semantic_info.papers[i].name,
71 "",
72 paper_size.width(),
71 paper_size.height()); 73 paper_size.height());
72 new_media.MatchBySize(); 74 new_media.MatchBySize();
73 if (new_media.IsValid() && !media.Contains(new_media)) { 75 if (new_media.IsValid() && !media.Contains(new_media)) {
74 if (!default_media.IsValid()) 76 if (!default_media.IsValid())
75 default_media = new_media; 77 default_media = new_media;
76 media.AddDefaultOption(new_media, new_media == default_media); 78 media.AddDefaultOption(new_media, new_media == default_media);
77 is_default_set = is_default_set || (new_media == default_media); 79 is_default_set = is_default_set || (new_media == default_media);
78 } 80 }
79 } 81 }
80 if (!is_default_set && default_media.IsValid()) 82 if (!is_default_set && default_media.IsValid())
(...skipping 22 matching lines...) Expand all
103 } 105 }
104 } 106 }
105 if (!is_default_set && default_dpi.IsValid()) 107 if (!is_default_set && default_dpi.IsValid())
106 dpi.AddDefaultOption(default_dpi, true); 108 dpi.AddDefaultOption(default_dpi, true);
107 if (dpi.IsValid()) { 109 if (dpi.IsValid()) {
108 dpi.SaveTo(&description); 110 dpi.SaveTo(&description);
109 } else { 111 } else {
110 NOTREACHED(); 112 NOTREACHED();
111 } 113 }
112 } 114 }
113 #endif
114 115
115 OrientationCapability orientation; 116 OrientationCapability orientation;
116 orientation.AddDefaultOption(PORTRAIT, true); 117 orientation.AddDefaultOption(PORTRAIT, true);
117 orientation.AddOption(LANDSCAPE); 118 orientation.AddOption(LANDSCAPE);
118 orientation.AddOption(AUTO_ORIENTATION); 119 orientation.AddOption(AUTO_ORIENTATION);
119 orientation.SaveTo(&description); 120 orientation.SaveTo(&description);
120 121
121 return scoped_ptr<base::DictionaryValue>(description.root().DeepCopy()); 122 return scoped_ptr<base::DictionaryValue>(description.root().DeepCopy());
122 } 123 }
123 124
124 } // namespace cloud_print 125 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.cc ('k') | components/cloud_devices/common/printer_description.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698