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

Unified Diff: printing/android/java/src/org/chromium/printing/PrintingContext.java

Issue 63483007: Refactor Android printing code to make it more testable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved isPrintingController into PrintingControllerImpl, cleaned tiny bits Created 7 years, 1 month 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
Index: printing/android/java/src/org/chromium/printing/PrintingContext.java
diff --git a/printing/android/java/src/org/chromium/printing/PrintingContext.java b/printing/android/java/src/org/chromium/printing/PrintingContext.java
index e63c97899ea3397e30a5df59fedcf3f0943e6b78..61f5eaf93b55012e6dd2ed43700c26cb36e340d0 100644
--- a/printing/android/java/src/org/chromium/printing/PrintingContext.java
+++ b/printing/android/java/src/org/chromium/printing/PrintingContext.java
@@ -8,9 +8,6 @@ import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
-import android.content.Context;
-
-import android.util.Log;
import android.util.SparseArray;
/**
@@ -23,15 +20,6 @@ public class PrintingContext implements PrintingContextInterface {
private static final String TAG = "PrintingContext";
- /** Whether the framework supports printing. */
- public static final boolean sIsPrintingAvailable = isPrintingAvailable();
-
- /**
- * The full class name of the print manager used to test whether printing functionality is
- * available.
- */
- private static final String PRINT_MANAGER_CLASS_NAME = "android.print.PrintManager";
-
/**
* Mapping from a file descriptor (as originally provided from
* {@link PrintDocumentAdapter#onWrite}) to a PrintingContext.
@@ -48,26 +36,12 @@ public class PrintingContext implements PrintingContextInterface {
/** The pointer to the native PrintingContextAndroid object. */
private final int mNativeObject;
- private PrintingContext(Context context, int ptr) {
- mController = PrintingControllerFactory.getPrintingController(context);
+ private PrintingContext(int ptr) {
+ mController = PrintingControllerImpl.getInstance();
whywhat 2013/11/19 15:39:32 Are you going to override the controller for testi
cimamoglu1 2013/11/19 17:40:33 Yes. Also, if need be, I plan to add a method (jus
mNativeObject = ptr;
}
/**
- * @return Whether printing is supported by the platform.
- */
- private static boolean isPrintingAvailable() {
- // TODO(cimamoglu): Get rid of reflection once Build.VERSION_CODES.KEY_LIME_PIE is fixed.
- try {
- Class.forName(PRINT_MANAGER_CLASS_NAME);
- } catch (ClassNotFoundException e) {
- Log.d(TAG, "PrintManager not found on device");
- return false;
- }
- return true;
- }
-
- /**
* Updates sPrintingContextMap to map from the file descriptor to this object.
* @param fileDescriptor The file descriptor passed down from
* {@link PrintDocumentAdapter#onWrite}.
@@ -94,9 +68,9 @@ public class PrintingContext implements PrintingContextInterface {
}
@CalledByNative
- public static PrintingContext create(Context context, int nativeObjectPointer) {
+ public static PrintingContext create(int nativeObjectPointer) {
ThreadUtils.assertOnUiThread();
- return new PrintingContext(context, nativeObjectPointer);
+ return new PrintingContext(nativeObjectPointer);
}
@CalledByNative

Powered by Google App Engine
This is Rietveld 408576698