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

Side by Side Diff: ppapi/thunk/ppb_printing_thunk.cc

Issue 10826026: Add a printing resource (as a new style resource) to fetch the default print settings (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/ppb_printing_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/c/dev/pp_print_settings_dev.h"
5 #include "ppapi/c/dev/ppb_printing_dev.h" 6 #include "ppapi/c/dev/ppb_printing_dev.h"
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/thunk/enter.h" 9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_printing_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
7 #include "ppapi/thunk/thunk.h" 12 #include "ppapi/thunk/thunk.h"
8 13
9 namespace ppapi { 14 namespace ppapi {
10 namespace thunk { 15 namespace thunk {
11 16
12 namespace { 17 namespace {
13 18
14 PP_Bool GetDefaultPrintSettings(PP_Instance instance, 19 PP_Bool GetDefaultPrintSettings_0_6(PP_Instance instance,
15 PP_PrintSettings_Dev* print_settings) { 20 PP_PrintSettings_Dev* print_settings) {
16 EnterInstance enter(instance); 21 // TODO(raymes): This is obsolete now. Just return some default settings.
17 if (enter.failed()) 22 // Remove this when all versions of Flash we care about are no longer using
18 return PP_FALSE; 23 // it.
19 return enter.functions()->GetDefaultPrintSettings(instance, print_settings); 24 PP_PrintSettings_Dev default_settings = {
25 // |printable_area|: all of the sheet of paper.
26 { { 0, 0 }, { 612, 792 } },
27 // |content_area|: 0.5" margins all around.
28 { { 36, 36 }, { 540, 720 } },
29 // |paper_size|: 8.5" x 11" (US letter).
30 { 612, 792 },
31 300, // |dpi|.
32 PP_PRINTORIENTATION_NORMAL, // |orientation|.
33 PP_PRINTSCALINGOPTION_NONE, // |print_scaling_option|.
34 PP_FALSE, // |grayscale|.
35 PP_PRINTOUTPUTFORMAT_PDF // |format|.
36 };
37 *print_settings = default_settings;
38 return PP_TRUE;
20 } 39 }
21 40
22 const PPB_Printing_Dev g_ppb_printing_dev_thunk = { 41 PP_Resource Create(PP_Instance instance) {
42 EnterResourceCreation enter(instance);
43 if (enter.failed())
44 return 0;
45 return enter.functions()->CreatePrinting(instance);
46 }
47
48 int32_t GetDefaultPrintSettings(PP_Resource resource,
49 PP_PrintSettings_Dev* print_settings,
50 PP_CompletionCallback callback) {
51 EnterResource<PPB_Printing_API> enter(resource, callback, true);
52 if (enter.failed())
53 return enter.retval();
54 return enter.SetResult(
55 enter.object()->GetDefaultPrintSettings(print_settings,
56 enter.callback()));
57 }
58
59 const PPB_Printing_Dev_0_6 g_ppb_printing_dev_thunk_0_6 = {
60 &GetDefaultPrintSettings_0_6,
61 };
62
63 const PPB_Printing_Dev g_ppb_printing_dev_thunk_0_7 = {
64 &Create,
23 &GetDefaultPrintSettings, 65 &GetDefaultPrintSettings,
24 }; 66 };
25 67
26 } // namespace 68 } // namespace
27 69
28 const PPB_Printing_Dev_0_6* GetPPB_Printing_Dev_0_6_Thunk() { 70 const PPB_Printing_Dev_0_6* GetPPB_Printing_Dev_0_6_Thunk() {
29 return &g_ppb_printing_dev_thunk; 71 return &g_ppb_printing_dev_thunk_0_6;
72 }
73
74 const PPB_Printing_Dev_0_7* GetPPB_Printing_Dev_0_7_Thunk() {
75 return &g_ppb_printing_dev_thunk_0_7;
30 } 76 }
31 77
32 } // namespace thunk 78 } // namespace thunk
33 } // namespace ppapi 79 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_printing_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698