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

Side by Side Diff: printing/android/java/src/org/chromium/printing/PrintingContext.java

Issue 740983002: Implement window.print() on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 package org.chromium.printing; 5 package org.chromium.printing;
6 6
7 import android.print.PrintDocumentAdapter; 7 import android.print.PrintDocumentAdapter;
8 import android.util.SparseArray; 8 import android.util.SparseArray;
9 9
10 import org.chromium.base.CalledByNative; 10 import org.chromium.base.CalledByNative;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return mController.getPageWidth(); 90 return mController.getPageWidth();
91 } 91 }
92 92
93 @CalledByNative 93 @CalledByNative
94 public int getHeight() { 94 public int getHeight() {
95 ThreadUtils.assertOnUiThread(); 95 ThreadUtils.assertOnUiThread();
96 return mController.getPageHeight(); 96 return mController.getPageHeight();
97 } 97 }
98 98
99 @CalledByNative 99 @CalledByNative
100 public void showPrintDialog() {
101 ThreadUtils.assertOnUiThread();
102 if (mController != null) { // The native side doesn't check if printing is enabled
103 mController.startPendingPrint(this);
104 } else {
105 // Printing disabled. Notify the native side to stop waiting.
106 showSystemDialogDone();
107 }
108 }
109
110 @CalledByNative
100 public static void pdfWritingDone(int fd, boolean success) { 111 public static void pdfWritingDone(int fd, boolean success) {
101 ThreadUtils.assertOnUiThread(); 112 ThreadUtils.assertOnUiThread();
102 // TODO(cimamoglu): Do something when fd == -1. 113 // TODO(cimamoglu): Do something when fd == -1.
103 if (PRINTING_CONTEXT_MAP.get(fd) != null) { 114 if (PRINTING_CONTEXT_MAP.get(fd) != null) {
104 ThreadUtils.assertOnUiThread(); 115 ThreadUtils.assertOnUiThread();
105 PrintingContext printingContext = PRINTING_CONTEXT_MAP.get(fd); 116 PrintingContext printingContext = PRINTING_CONTEXT_MAP.get(fd);
106 printingContext.mController.pdfWritingDone(success); 117 printingContext.mController.pdfWritingDone(success);
107 PRINTING_CONTEXT_MAP.remove(fd); 118 PRINTING_CONTEXT_MAP.remove(fd);
108 } 119 }
109 } 120 }
(...skipping 12 matching lines...) Expand all
122 // NOTE: We don't call nativeAskUserForSettingsReply (hence Chromium callback in 133 // NOTE: We don't call nativeAskUserForSettingsReply (hence Chromium callback in
123 // AskUserForSettings callback) twice. See {@link PrintingControlle rImpl#onFinish} 134 // AskUserForSettings callback) twice. See {@link PrintingControlle rImpl#onFinish}
124 // for more explanation. 135 // for more explanation.
125 nativeAskUserForSettingsReply(mNativeObject, false); 136 nativeAskUserForSettingsReply(mNativeObject, false);
126 } else { 137 } else {
127 mController.setPrintingContext(this); 138 mController.setPrintingContext(this);
128 mController.pageCountEstimationDone(maxPages); 139 mController.pageCountEstimationDone(maxPages);
129 } 140 }
130 } 141 }
131 142
143 @Override
144 public void showSystemDialogDone() {
145 nativeShowSystemDialogDone(mNativeObject);
146 }
147
132 private native void nativeAskUserForSettingsReply( 148 private native void nativeAskUserForSettingsReply(
133 long nativePrintingContextAndroid, 149 long nativePrintingContextAndroid,
134 boolean success); 150 boolean success);
151
152 private native void nativeShowSystemDialogDone(long nativePrintingContextAnd roid);
135 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698