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

Unified Diff: android_webview/native/aw_contents.cc

Issue 10946013: Add WebView.saveWebArchive support to android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_contents.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index be5193ce404c849adb519d353d9f0b57951cb075..4b21b58ad41d661d954f876094bb9ad87adbbfb0 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -102,10 +102,31 @@ void DocumentHasImagesCallback(ScopedJavaGlobalRef<jobject>* message,
} // namespace
void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) {
+ ScopedJavaGlobalRef<jobject>* j_message = new ScopedJavaGlobalRef<jobject>();
+ j_message->Reset(env, message);
render_view_host_ext_->DocumentHasImages(
- base::Bind(&DocumentHasImagesCallback,
- base::Owned(new ScopedJavaGlobalRef<jobject>(
- ScopedJavaLocalRef<jobject>(env, message)))));
+ base::Bind(&DocumentHasImagesCallback, base::Owned(j_message)));
+}
+
+namespace {
+void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback,
+ const FilePath& path, int64 size) {
+ JNIEnv* env = AttachCurrentThread();
+ // Android files are UTF8, so the path conversion below is safe.
+ Java_AwContents_generateMHTMLCallback(
+ env,
+ base::android::ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()).obj(),
+ size, callback->obj());
+}
+} // namespace
+
+void AwContents::GenerateMHTML(JNIEnv* env, jobject obj,
+ jstring jpath, jobject callback) {
+ ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
+ j_callback->Reset(env, callback);
+ contents_container_->GetWebContents()->GenerateMHTML(
+ FilePath(base::android::ConvertJavaStringToUTF8(env, jpath)),
+ base::Bind(&GenerateMHTMLCallback, base::Owned(j_callback)));
}
void AwContents::onReceivedHttpAuthRequest(
« no previous file with comments | « android_webview/native/aw_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698