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

Side by Side Diff: content/browser/android/download_controller.cc

Issue 10696173: Revert "Revert 146000 - Split out ContentViewCore from ContentView for embedders." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase number deux Created 8 years, 5 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
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 "content/browser/android/download_controller.h" 5 #include "content/browser/android/download_controller.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/browser/android/content_view_core_impl.h"
12 #include "content/browser/download/download_item_impl.h" 13 #include "content/browser/download/download_item_impl.h"
13 #include "content/browser/renderer_host/render_process_host_impl.h" 14 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/browser/renderer_host/render_view_host_delegate.h" 15 #include "content/browser/renderer_host/render_view_host_delegate.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 17 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/global_request_id.h" 20 #include "content/public/browser/global_request_id.h"
20 #include "jni/download_controller_jni.h" 21 #include "jni/download_controller_jni.h"
21 #include "net/cookies/cookie_options.h" 22 #include "net/cookies/cookie_options.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 212
212 void DownloadController::OnPostDownloadStarted( 213 void DownloadController::OnPostDownloadStarted(
213 WebContents* web_contents, 214 WebContents* web_contents,
214 DownloadItem* download_item) { 215 DownloadItem* download_item) {
215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
216 JNIEnv* env = AttachCurrentThread(); 217 JNIEnv* env = AttachCurrentThread();
217 218
218 // Register for updates to the DownloadItem. 219 // Register for updates to the DownloadItem.
219 download_item->AddObserver(this); 220 download_item->AddObserver(this);
220 221
221 jobject view = GetContentViewFromWebContents(web_contents); 222 jobject view = GetContentViewCoreFromWebContents(web_contents);
222 if(!view) { 223 if(!view) {
223 // The view went away. Can't proceed. 224 // The view went away. Can't proceed.
224 return; 225 return;
225 } 226 }
226 227
227 Java_DownloadController_onHttpPostDownloadStarted( 228 Java_DownloadController_onHttpPostDownloadStarted(
228 env, GetJavaObject()->Controller(env).obj(), view); 229 env, GetJavaObject()->Controller(env).obj(), view);
229 } 230 }
230 231
231 void DownloadController::OnDownloadUpdated(DownloadItem* item) { 232 void DownloadController::OnDownloadUpdated(DownloadItem* item) {
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
233 234
234 if (item->GetState() != DownloadItem::COMPLETE) 235 if (item->GetState() != DownloadItem::COMPLETE)
235 return; 236 return;
236 237
237 // Call onHttpPostDownloadCompleted 238 // Call onHttpPostDownloadCompleted
238 JNIEnv* env = AttachCurrentThread(); 239 JNIEnv* env = AttachCurrentThread();
239 ScopedJavaLocalRef<jstring> jurl = 240 ScopedJavaLocalRef<jstring> jurl =
240 ConvertUTF8ToJavaString(env, item->GetURL().spec()); 241 ConvertUTF8ToJavaString(env, item->GetURL().spec());
241 ScopedJavaLocalRef<jstring> jcontent_disposition = 242 ScopedJavaLocalRef<jstring> jcontent_disposition =
242 ConvertUTF8ToJavaString(env, item->GetContentDisposition()); 243 ConvertUTF8ToJavaString(env, item->GetContentDisposition());
243 ScopedJavaLocalRef<jstring> jmime_type = 244 ScopedJavaLocalRef<jstring> jmime_type =
244 ConvertUTF8ToJavaString(env, item->GetMimeType()); 245 ConvertUTF8ToJavaString(env, item->GetMimeType());
245 ScopedJavaLocalRef<jstring> jpath = 246 ScopedJavaLocalRef<jstring> jpath =
246 ConvertUTF8ToJavaString(env, item->GetFullPath().value()); 247 ConvertUTF8ToJavaString(env, item->GetFullPath().value());
247 248
248 jobject view = GetContentViewFromWebContents(item->GetWebContents()); 249 jobject view_core = GetContentViewCoreFromWebContents(item->GetWebContents());
249 if(!view) { 250 if (!view_core) {
250 // We can get NULL WebContents from the DownloadItem. 251 // We can get NULL WebContents from the DownloadItem.
251 return; 252 return;
252 } 253 }
253 254
254 Java_DownloadController_onHttpPostDownloadCompleted(env, 255 Java_DownloadController_onHttpPostDownloadCompleted(env,
255 GetJavaObject()->Controller(env).obj(), view, jurl.obj(), 256 GetJavaObject()->Controller(env).obj(), view_core, jurl.obj(),
256 jcontent_disposition.obj(), jmime_type.obj(), jpath.obj(), 257 jcontent_disposition.obj(), jmime_type.obj(), jpath.obj(),
257 item->GetReceivedBytes(), true); 258 item->GetReceivedBytes(), true);
258 } 259 }
259 260
260 void DownloadController::OnDownloadOpened(DownloadItem* item) { 261 void DownloadController::OnDownloadOpened(DownloadItem* item) {
261 } 262 }
262 263
263 jobject DownloadController::GetContentView(int render_process_id, 264 jobject DownloadController::GetContentView(int render_process_id,
264 int render_view_id) { 265 int render_view_id) {
265 RenderViewHost* render_view_host = 266 RenderViewHost* render_view_host =
266 RenderViewHost::FromID(render_process_id, render_view_id); 267 RenderViewHost::FromID(render_process_id, render_view_id);
267 268
268 if (!render_view_host) 269 if (!render_view_host)
269 return NULL; 270 return NULL;
270 271
271 WebContents* web_contents = 272 WebContents* web_contents =
272 render_view_host->GetDelegate()->GetAsWebContents(); 273 render_view_host->GetDelegate()->GetAsWebContents();
273 274
274 if (!web_contents) 275 if (!web_contents)
275 return NULL; 276 return NULL;
276 277
277 return GetContentViewFromWebContents(web_contents); 278 return GetContentViewCoreFromWebContents(web_contents);
278 } 279 }
279 280
280 jobject DownloadController::GetContentViewFromWebContents( 281 jobject DownloadController::GetContentViewCoreFromWebContents(
281 WebContents* web_contents) { 282 WebContents* web_contents) {
282 NOTIMPLEMENTED(); 283 NOTIMPLEMENTED();
283 return NULL; 284 return NULL;
284 } 285 }
285 286
286 DownloadController::JavaObject* DownloadController::GetJavaObject() { 287 DownloadController::JavaObject* DownloadController::GetJavaObject() {
287 if (!java_object_) { 288 if (!java_object_) {
288 // Initialize Java DownloadController by calling 289 // Initialize Java DownloadController by calling
289 // DownloadController.getInstance(), which will call Init() 290 // DownloadController.getInstance(), which will call Init()
290 // if Java DownloadController is not instantiated already. 291 // if Java DownloadController is not instantiated already.
(...skipping 18 matching lines...) Expand all
309 request->extra_request_headers().GetHeader( 310 request->extra_request_headers().GetHeader(
310 net::HttpRequestHeaders::kUserAgent, 311 net::HttpRequestHeaders::kUserAgent,
311 &user_agent); 312 &user_agent);
312 if (!request->url_chain().empty()) { 313 if (!request->url_chain().empty()) {
313 original_url = request->url_chain().front(); 314 original_url = request->url_chain().front();
314 url = request->url_chain().back(); 315 url = request->url_chain().back();
315 } 316 }
316 } 317 }
317 318
318 } // namespace content 319 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/download_controller.h ('k') | content/browser/renderer_host/render_widget_host_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698