1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINTING_CONTEXT_ANDROID_H_
6 #define PRINTING_PRINTING_CONTEXT_ANDROID_H_
12 #include "base/android/scoped_java_ref.h"
13 #include "printing/printing_context.h"
17 // Android subclass of PrintingContext. The implementation for this header file
18 // resides in Chrome for Android repository. This class communicates with the
19 // Java side through JNI.
20 class PRINTING_EXPORT PrintingContextAndroid
: public PrintingContext
{
22 explicit PrintingContextAndroid(const std::string
& app_locale
);
23 virtual ~PrintingContextAndroid();
25 // Called when the page is successfully written to a PDF using the file
26 // descriptor specified, or when the printing operation failed.
27 static void PdfWritingDone(int fd
, bool success
);
29 // Called from Java, when printing settings from the user are ready or the
30 // printing operation is canceled.
31 void AskUserForSettingsReply(JNIEnv
* env
, jobject obj
, jboolean success
);
33 // PrintingContext implementation.
34 virtual void AskUserForSettings(
35 gfx::NativeView parent_view
,
38 const PrintSettingsCallback
& callback
) OVERRIDE
;
39 virtual Result
UseDefaultSettings() OVERRIDE
;
40 virtual Result
UpdatePrinterSettings(
41 const base::DictionaryValue
& job_settings
,
42 const PageRanges
& ranges
) OVERRIDE
;
43 virtual Result
InitWithSettings(const PrintSettings
& settings
) OVERRIDE
;
44 virtual Result
NewDocument(const string16
& document_name
) OVERRIDE
;
45 virtual Result
NewPage() OVERRIDE
;
46 virtual Result
PageDone() OVERRIDE
;
47 virtual Result
DocumentDone() OVERRIDE
;
48 virtual void Cancel() OVERRIDE
;
49 virtual void ReleaseContext() OVERRIDE
;
50 virtual gfx::NativeDrawingContext
context() const OVERRIDE
;
52 // Registers JNI bindings for RegisterContext.
53 static bool RegisterPrintingContext(JNIEnv
* env
);
56 base::android::ScopedJavaGlobalRef
<jobject
> j_printing_context_
;
58 // The callback from AskUserForSettings to be called when the settings are
59 // ready on the Java side
60 PrintSettingsCallback callback_
;
62 DISALLOW_COPY_AND_ASSIGN(PrintingContextAndroid
);
65 } // namespace printing
67 #endif // PRINTING_PRINTING_CONTEXT_ANDROID_H_