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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « android_webview/native/aw_contents.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
8 #include "android_webview/native/aw_browser_dependency_factory.h" 8 #include "android_webview/native/aw_browser_dependency_factory.h"
9 #include "android_webview/native/aw_contents_container.h" 9 #include "android_webview/native/aw_contents_container.h"
10 #include "android_webview/native/aw_web_contents_delegate.h" 10 #include "android_webview/native/aw_web_contents_delegate.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // when the callback goes out of scope. 95 // when the callback goes out of scope.
96 void DocumentHasImagesCallback(ScopedJavaGlobalRef<jobject>* message, 96 void DocumentHasImagesCallback(ScopedJavaGlobalRef<jobject>* message,
97 bool has_images) { 97 bool has_images) {
98 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), 98 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(),
99 has_images, 99 has_images,
100 message->obj()); 100 message->obj());
101 } 101 }
102 } // namespace 102 } // namespace
103 103
104 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) { 104 void AwContents::DocumentHasImages(JNIEnv* env, jobject obj, jobject message) {
105 ScopedJavaGlobalRef<jobject>* j_message = new ScopedJavaGlobalRef<jobject>();
106 j_message->Reset(env, message);
105 render_view_host_ext_->DocumentHasImages( 107 render_view_host_ext_->DocumentHasImages(
106 base::Bind(&DocumentHasImagesCallback, 108 base::Bind(&DocumentHasImagesCallback, base::Owned(j_message)));
107 base::Owned(new ScopedJavaGlobalRef<jobject>( 109 }
108 ScopedJavaLocalRef<jobject>(env, message))))); 110
111 namespace {
112 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback,
113 const FilePath& path, int64 size) {
114 JNIEnv* env = AttachCurrentThread();
115 // Android files are UTF8, so the path conversion below is safe.
116 Java_AwContents_generateMHTMLCallback(
117 env,
118 base::android::ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()).obj(),
119 size, callback->obj());
120 }
121 } // namespace
122
123 void AwContents::GenerateMHTML(JNIEnv* env, jobject obj,
124 jstring jpath, jobject callback) {
125 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
126 j_callback->Reset(env, callback);
127 contents_container_->GetWebContents()->GenerateMHTML(
128 FilePath(base::android::ConvertJavaStringToUTF8(env, jpath)),
129 base::Bind(&GenerateMHTMLCallback, base::Owned(j_callback)));
109 } 130 }
110 131
111 void AwContents::onReceivedHttpAuthRequest( 132 void AwContents::onReceivedHttpAuthRequest(
112 const base::android::JavaRef<jobject>& handler, 133 const base::android::JavaRef<jobject>& handler,
113 const std::string& host, 134 const std::string& host,
114 const std::string& realm) { 135 const std::string& realm) {
115 JNIEnv* env = AttachCurrentThread(); 136 JNIEnv* env = AttachCurrentThread();
116 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); 137 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host);
117 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); 138 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm);
118 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(), 139 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(),
(...skipping 16 matching lines...) Expand all
135 private_browsing); 156 private_browsing);
136 return reinterpret_cast<jint>(tab); 157 return reinterpret_cast<jint>(tab);
137 } 158 }
138 159
139 bool RegisterAwContents(JNIEnv* env) { 160 bool RegisterAwContents(JNIEnv* env) {
140 return RegisterNativesImpl(env) >= 0; 161 return RegisterNativesImpl(env) >= 0;
141 } 162 }
142 163
143 164
144 } // namespace android_webview 165 } // namespace android_webview
OLDNEW
« 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