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

Side by Side Diff: ppapi/cpp/dev/printing_dev.cc

Issue 10795051: Implement asynchronous interface/plumbing for GetDefaultPrintSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/cpp/dev/printing_dev.h" 5 #include "ppapi/cpp/dev/printing_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_printing_dev.h" 7 #include "ppapi/c/dev/ppb_printing_dev.h"
8 #include "ppapi/cpp/completion_callback.h"
8 #include "ppapi/cpp/instance.h" 9 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/instance_handle.h" 10 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
11 #include "ppapi/cpp/module_impl.h" 12 #include "ppapi/cpp/module_impl.h"
12 13
13 namespace pp { 14 namespace pp {
14 15
15 namespace { 16 namespace {
16 17
17 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; 18 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
18 19
20 template <> const char* interface_name<PPB_Printing_Dev_0_7>() {
21 return PPB_PRINTING_DEV_INTERFACE_0_7;
22 }
23
19 template <> const char* interface_name<PPB_Printing_Dev_0_6>() { 24 template <> const char* interface_name<PPB_Printing_Dev_0_6>() {
20 return PPB_PRINTING_DEV_INTERFACE_0_6; 25 return PPB_PRINTING_DEV_INTERFACE_0_6;
21 } 26 }
22 27
23 uint32_t QuerySupportedFormats(PP_Instance instance) { 28 uint32_t QuerySupportedFormats(PP_Instance instance) {
24 void* object = 29 void* object =
25 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); 30 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
26 if (!object) 31 if (!object)
27 return 0; 32 return 0;
28 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); 33 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 instance->AddPerInstanceObject(kPPPPrintingInterface, this); 86 instance->AddPerInstanceObject(kPPPPrintingInterface, this);
82 } 87 }
83 88
84 Printing_Dev::~Printing_Dev() { 89 Printing_Dev::~Printing_Dev() {
85 Instance::RemovePerInstanceObject(associated_instance_, 90 Instance::RemovePerInstanceObject(associated_instance_,
86 kPPPPrintingInterface, this); 91 kPPPPrintingInterface, this);
87 } 92 }
88 93
89 // static 94 // static
90 bool Printing_Dev::IsAvailable() { 95 bool Printing_Dev::IsAvailable() {
91 return has_interface<PPB_Printing_Dev_0_6>(); 96 return has_interface<PPB_Printing_Dev_0_7>() ||
97 has_interface<PPB_Printing_Dev_0_6>();
92 } 98 }
93 99
94 bool Printing_Dev::GetDefaultPrintSettings( 100 bool Printing_Dev::GetDefaultPrintSettings(
95 PP_PrintSettings_Dev* print_settings) const { 101 PP_PrintSettings_Dev* print_settings) const {
96 if (!has_interface<PPB_Printing_Dev_0_6>()) 102 if (!has_interface<PPB_Printing_Dev_0_6>())
97 return false; 103 return false;
98 return PP_ToBool( 104 return PP_ToBool(
99 get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings( 105 get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings(
100 associated_instance_.pp_instance(), print_settings)); 106 associated_instance_.pp_instance(), print_settings));
101 } 107 }
102 108
109 int32_t Printing_Dev::GetDefaultPrintSettings(
110 PP_PrintSettings_Dev* print_settings,
111 const CompletionCallback& callback) const {
112 if (!has_interface<PPB_Printing_Dev_0_7>())
113 return PP_ERROR_NOTSUPPORTED;
114 return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings(
115 associated_instance_.pp_instance(), print_settings,
116 callback.pp_completion_callback());
dmichael (off chromium) 2012/07/23 18:20:09 You might want to check with Trung about this. If
raymes 2012/07/24 00:37:08 Good call. I updated the CL with your suggestion a
117 }
118
103 } // namespace pp 119 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698