forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The code is not enabled yet. BUG=317027 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=249967 Review URL: https://codereview.chromium.org/148203011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249995 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
vitalybuka@chromium.org
committed
Feb 9, 2014
1 parent
bdf2d43
commit 07021fc
Showing
8 changed files
with
204 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include_rules = [ | ||
"+components/cloud_devices", | ||
# sync notifier depends on the common jingle notifier classes. | ||
"+jingle/notifier", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/service/cloud_print/cdd_conversion_win.h" | ||
|
||
#include "components/cloud_devices/printer_description.h" | ||
#include "printing/backend/print_backend.h" | ||
#include "printing/backend/win_helper.h" | ||
|
||
namespace cloud_print { | ||
|
||
std::string CapabilitiesToCdd( | ||
const printing::PrinterSemanticCapsAndDefaults& semantic_info) { | ||
using namespace cloud_devices::printer; | ||
cloud_devices::CloudDeviceDescription description; | ||
|
||
ContentTypesCapability content_types; | ||
content_types.AddOption("application/pdf"); | ||
content_types.SaveTo(&description); | ||
|
||
ColorCapability color; | ||
if (semantic_info.color_default || semantic_info.color_changeable) { | ||
color.AddDefaultOption(Color(STANDARD_COLOR), semantic_info.color_default); | ||
} | ||
|
||
if (!semantic_info.color_default || semantic_info.color_changeable) { | ||
color.AddDefaultOption(Color(STANDARD_MONOCHROME), | ||
!semantic_info.color_default); | ||
} | ||
color.SaveTo(&description); | ||
|
||
if (semantic_info.duplex_capable) { | ||
DuplexCapability duplex; | ||
duplex.AddDefaultOption( | ||
NO_DUPLEX, semantic_info.duplex_default == printing::SIMPLEX); | ||
duplex.AddDefaultOption( | ||
LONG_EDGE, semantic_info.duplex_default == printing::LONG_EDGE); | ||
duplex.AddDefaultOption( | ||
SHORT_EDGE, semantic_info.duplex_default == printing::SHORT_EDGE); | ||
duplex.SaveTo(&description); | ||
} | ||
|
||
if (!semantic_info.papers.empty()) { | ||
Media default_media(semantic_info.default_paper.name, | ||
semantic_info.default_paper.size_um.width(), | ||
semantic_info.default_paper.size_um.height()); | ||
default_media.MatchBySize(); | ||
|
||
MediaCapability media; | ||
bool is_default_set = false; | ||
for (size_t i = 0; i < semantic_info.papers.size(); ++i) { | ||
gfx::Size paper_size = semantic_info.papers[i].size_um; | ||
if (paper_size.width() > paper_size.height()) | ||
paper_size.SetSize(paper_size.height(), paper_size.width()); | ||
Media new_media(semantic_info.papers[i].name, paper_size.width(), | ||
paper_size.height()); | ||
new_media.MatchBySize(); | ||
if (new_media.IsValid() && !media.Contains(new_media)) { | ||
if (!default_media.IsValid()) | ||
default_media = new_media; | ||
media.AddDefaultOption(new_media, new_media == default_media); | ||
is_default_set = is_default_set || (new_media == default_media); | ||
} | ||
} | ||
if (!is_default_set && default_media.IsValid()) | ||
media.AddDefaultOption(default_media, true); | ||
|
||
if (media.IsValid()) { | ||
media.SaveTo(&description); | ||
} else { | ||
NOTREACHED(); | ||
} | ||
} | ||
|
||
if (semantic_info.collate_capable) { | ||
CollateCapability collate; | ||
collate.set_default_value(semantic_info.collate_default); | ||
collate.SaveTo(&description); | ||
} | ||
|
||
if (semantic_info.copies_capable) { | ||
CopiesCapability copies; | ||
copies.SaveTo(&description); | ||
} | ||
|
||
if (!semantic_info.dpis.empty()) { | ||
DpiCapability dpi; | ||
Dpi default_dpi(semantic_info.default_dpi.width(), | ||
semantic_info.default_dpi.height()); | ||
bool is_default_set = false; | ||
for (size_t i = 0; i < semantic_info.dpis.size(); ++i) { | ||
Dpi new_dpi(semantic_info.dpis[i].width(), | ||
semantic_info.dpis[i].height()); | ||
if (new_dpi.IsValid() && !dpi.Contains(new_dpi)) { | ||
if (!default_dpi.IsValid()) | ||
default_dpi = new_dpi; | ||
dpi.AddDefaultOption(new_dpi, new_dpi == default_dpi); | ||
is_default_set = is_default_set || (new_dpi == default_dpi); | ||
} | ||
} | ||
if (!is_default_set && default_dpi.IsValid()) | ||
dpi.AddDefaultOption(default_dpi, true); | ||
if (dpi.IsValid()) { | ||
dpi.SaveTo(&description); | ||
} else { | ||
NOTREACHED(); | ||
} | ||
} | ||
return description.ToString(); | ||
} | ||
|
||
} // namespace cloud_print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_SERVICE_CLOUD_PRINT_CDD_CONVERSION_WIN_H_ | ||
#define CHROME_SERVICE_CLOUD_PRINT_CDD_CONVERSION_WIN_H_ | ||
|
||
#include <string> | ||
|
||
namespace printing { | ||
struct PrinterSemanticCapsAndDefaults; | ||
} | ||
|
||
namespace cloud_print { | ||
|
||
std::string CapabilitiesToCdd( | ||
const printing::PrinterSemanticCapsAndDefaults& semantic_info); | ||
|
||
} // namespace cloud_print | ||
|
||
#endif // CHROME_SERVICE_CLOUD_PRINT_CDD_CONVERSION_WIN_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters