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

Side by Side Diff: printing/printing_context_android.cc

Issue 1477783002: jni: Pass method parameters as JavaParamRef in printing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « printing/printing_context_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "printing/printing_context_android.h" 5 #include "printing/printing_context_android.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 if (is_scripted) { 97 if (is_scripted) {
98 Java_PrintingContext_showPrintDialog(env, j_printing_context_.obj()); 98 Java_PrintingContext_showPrintDialog(env, j_printing_context_.obj());
99 } else { 99 } else {
100 Java_PrintingContext_pageCountEstimationDone(env, 100 Java_PrintingContext_pageCountEstimationDone(env,
101 j_printing_context_.obj(), 101 j_printing_context_.obj(),
102 max_pages); 102 max_pages);
103 } 103 }
104 } 104 }
105 105
106 void PrintingContextAndroid::AskUserForSettingsReply(JNIEnv* env, 106 void PrintingContextAndroid::AskUserForSettingsReply(
107 jobject obj, 107 JNIEnv* env,
108 jboolean success) { 108 const JavaParamRef<jobject>& obj,
109 jboolean success) {
109 if (!success) { 110 if (!success) {
110 // TODO(cimamoglu): Differentiate between FAILED And CANCEL. 111 // TODO(cimamoglu): Differentiate between FAILED And CANCEL.
111 callback_.Run(FAILED); 112 callback_.Run(FAILED);
112 return; 113 return;
113 } 114 }
114 115
115 // We use device name variable to store the file descriptor. This is hacky 116 // We use device name variable to store the file descriptor. This is hacky
116 // but necessary. Since device name is not necessary for the upstream 117 // but necessary. Since device name is not necessary for the upstream
117 // printing code for Android, this is harmless. 118 // printing code for Android, this is harmless.
118 int fd = Java_PrintingContext_getFileDescriptor(env, 119 int fd = Java_PrintingContext_getFileDescriptor(env,
(...skipping 11 matching lines...) Expand all
130 int dpi = Java_PrintingContext_getDpi(env, j_printing_context_.obj()); 131 int dpi = Java_PrintingContext_getDpi(env, j_printing_context_.obj());
131 int width = Java_PrintingContext_getWidth(env, j_printing_context_.obj()); 132 int width = Java_PrintingContext_getWidth(env, j_printing_context_.obj());
132 int height = Java_PrintingContext_getHeight(env, j_printing_context_.obj()); 133 int height = Java_PrintingContext_getHeight(env, j_printing_context_.obj());
133 width = Round(ConvertUnitDouble(width, kInchToMil, 1.0) * dpi); 134 width = Round(ConvertUnitDouble(width, kInchToMil, 1.0) * dpi);
134 height = Round(ConvertUnitDouble(height, kInchToMil, 1.0) * dpi); 135 height = Round(ConvertUnitDouble(height, kInchToMil, 1.0) * dpi);
135 SetSizes(&settings_, dpi, width, height); 136 SetSizes(&settings_, dpi, width, height);
136 137
137 callback_.Run(OK); 138 callback_.Run(OK);
138 } 139 }
139 140
140 void PrintingContextAndroid::ShowSystemDialogDone(JNIEnv* env, 141 void PrintingContextAndroid::ShowSystemDialogDone(
141 jobject obj) { 142 JNIEnv* env,
143 const JavaParamRef<jobject>& obj) {
142 // Settings are not updated, callback is called only to unblock javascript. 144 // Settings are not updated, callback is called only to unblock javascript.
143 callback_.Run(CANCEL); 145 callback_.Run(CANCEL);
144 } 146 }
145 147
146 PrintingContext::Result PrintingContextAndroid::UseDefaultSettings() { 148 PrintingContext::Result PrintingContextAndroid::UseDefaultSettings() {
147 DCHECK(!in_print_job_); 149 DCHECK(!in_print_job_);
148 150
149 ResetSettings(); 151 ResetSettings();
150 settings_.set_dpi(kDefaultPdfDpi); 152 settings_.set_dpi(kDefaultPdfDpi);
151 gfx::Size physical_size = GetPdfPaperSizeDeviceUnits(); 153 gfx::Size physical_size = GetPdfPaperSizeDeviceUnits();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Intentional No-op. 253 // Intentional No-op.
252 return NULL; 254 return NULL;
253 } 255 }
254 256
255 // static 257 // static
256 bool PrintingContextAndroid::RegisterPrintingContext(JNIEnv* env) { 258 bool PrintingContextAndroid::RegisterPrintingContext(JNIEnv* env) {
257 return RegisterNativesImpl(env); 259 return RegisterNativesImpl(env);
258 } 260 }
259 261
260 } // namespace printing 262 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing_context_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698