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

Unified Diff: ppapi/cpp/dev/printing_dev.cc

Issue 10826072: Implement browser side of PPB_Printing resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/host/dispatch_host_message.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/printing_dev.cc
diff --git a/ppapi/cpp/dev/printing_dev.cc b/ppapi/cpp/dev/printing_dev.cc
index 8c307251fbac70261bd2fa8089976449852f8966..00bb15b76dd82e265e3c89c758ce39b9def58beb 100644
--- a/ppapi/cpp/dev/printing_dev.cc
+++ b/ppapi/cpp/dev/printing_dev.cc
@@ -16,6 +16,10 @@ namespace {
static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
+template <> const char* interface_name<PPB_Printing_Dev_0_7>() {
+ return PPB_PRINTING_DEV_INTERFACE_0_7;
+}
+
template <> const char* interface_name<PPB_Printing_Dev_0_6>() {
return PPB_PRINTING_DEV_INTERFACE_0_6;
}
@@ -76,9 +80,14 @@ const PPP_Printing_Dev ppp_printing = {
} // namespace
Printing_Dev::Printing_Dev(Instance* instance)
- : associated_instance_(instance) {
+ : associated_instance_(instance) {
Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing);
- instance->AddPerInstanceObject(kPPPPrintingInterface, this);
+ instance->AddPerInstanceObject(
+ kPPPPrintingInterface, this);
+ if (has_interface<PPB_Printing_Dev_0_7>()) {
+ PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_7>()->Create(
+ associated_instance_.pp_instance()));
+ }
}
Printing_Dev::~Printing_Dev() {
@@ -88,16 +97,23 @@ Printing_Dev::~Printing_Dev() {
// static
bool Printing_Dev::IsAvailable() {
- return has_interface<PPB_Printing_Dev_0_6>();
+ return has_interface<PPB_Printing_Dev_0_7>() ||
+ has_interface<PPB_Printing_Dev_0_6>();
+
}
-bool Printing_Dev::GetDefaultPrintSettings(
- PP_PrintSettings_Dev* print_settings) const {
- if (!has_interface<PPB_Printing_Dev_0_6>())
- return false;
- return PP_ToBool(
- get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings(
- associated_instance_.pp_instance(), print_settings));
+void Printing_Dev::GetDefaultPrintSettings(
+ const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const {
+ if (has_interface<PPB_Printing_Dev_0_7>()) {
+ get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings(
+ pp_resource(), callback.output(), callback.pp_completion_callback());
+ } else if (has_interface<PPB_Printing_Dev_0_6>()) {
+ bool success = PP_ToBool(get_interface<PPB_Printing_Dev_0_6>()->
+ GetDefaultPrintSettings(associated_instance_.pp_instance(),
+ callback.output()));
+ Module::Get()->core()->CallOnMainThread(0, callback,
+ success ? PP_OK : PP_ERROR_FAILED);
+ }
}
} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/host/dispatch_host_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698