OLD | NEW |
---|---|
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 "chrome/browser/component/web_contents_delegate_android/web_contents_de legate_android.h" | 5 #include "chrome/browser/component/web_contents_delegate_android/web_contents_de legate_android.h" |
6 | 6 |
7 #include <android/keycodes.h> | 7 #include <android/keycodes.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "content/public/browser/android/download_controller_android.h" | |
11 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
12 #include "content/public/browser/download_item.h" | 13 #include "content/public/browser/download_item.h" |
13 #include "content/public/browser/invalidate_type.h" | 14 #include "content/public/browser/invalidate_type.h" |
14 #include "content/public/browser/page_navigator.h" | 15 #include "content/public/browser/page_navigator.h" |
15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/page_transition_types.h" | 19 #include "content/public/common/page_transition_types.h" |
19 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
20 #include "jni/WebContentsDelegateAndroid_jni.h" | 21 #include "jni/WebContentsDelegateAndroid_jni.h" |
21 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
23 #include "webkit/glue/window_open_disposition.h" | 24 #include "webkit/glue/window_open_disposition.h" |
24 | 25 |
25 using base::android::AttachCurrentThread; | 26 using base::android::AttachCurrentThread; |
26 using base::android::CheckException; | 27 using base::android::CheckException; |
27 using base::android::ConvertUTF8ToJavaString; | 28 using base::android::ConvertUTF8ToJavaString; |
28 using base::android::ConvertUTF16ToJavaString; | 29 using base::android::ConvertUTF16ToJavaString; |
29 using base::android::GetClass; | 30 using base::android::GetClass; |
30 using base::android::GetMethodID; | 31 using base::android::GetMethodID; |
31 using base::android::HasClass; | 32 using base::android::HasClass; |
32 using base::android::ScopedJavaLocalRef; | 33 using base::android::ScopedJavaLocalRef; |
34 using content::DownloadControllerAndroid; | |
33 using content::DownloadItem; | 35 using content::DownloadItem; |
34 using content::JavaScriptDialogCreator; | 36 using content::JavaScriptDialogCreator; |
35 using content::RenderViewHost; | 37 using content::RenderViewHost; |
36 using content::WebContents; | 38 using content::WebContents; |
37 | 39 |
38 namespace web_contents_delegate_android { | 40 namespace web_contents_delegate_android { |
39 | 41 |
40 WebContentsDelegateAndroid::WebContentsDelegateAndroid(JNIEnv* env, jobject obj) | 42 WebContentsDelegateAndroid::WebContentsDelegateAndroid(JNIEnv* env, jobject obj) |
41 : weak_java_delegate_(env, obj) { | 43 : weak_java_delegate_(env, obj) { |
42 } | 44 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 Java_WebContentsDelegateAndroid_onUpdateUrl(env, | 274 Java_WebContentsDelegateAndroid_onUpdateUrl(env, |
273 obj.obj(), | 275 obj.obj(), |
274 java_url.obj()); | 276 java_url.obj()); |
275 } | 277 } |
276 | 278 |
277 bool WebContentsDelegateAndroid::CanDownload( | 279 bool WebContentsDelegateAndroid::CanDownload( |
278 RenderViewHost* source, | 280 RenderViewHost* source, |
279 int request_id, | 281 int request_id, |
280 const std::string& request_method) { | 282 const std::string& request_method) { |
281 if (request_method == net::HttpRequestHeaders::kGetMethod) { | 283 if (request_method == net::HttpRequestHeaders::kGetMethod) { |
282 // TODO(leandrogracia): re-enable this when calling DownloadController | 284 DownloadControllerAndroid::Get()->CreateGETDownload( |
283 // doesn't introduce a DEPS layering violation. | 285 source, request_id); |
284 // DownloadController::GetInstance()->CreateGETDownload( | |
285 // source, request_id); | |
286 return false; | 286 return false; |
287 } | 287 } |
288 return true; | 288 return true; |
289 } | 289 } |
290 | 290 |
291 void WebContentsDelegateAndroid::OnStartDownload(WebContents* source, | 291 void WebContentsDelegateAndroid::OnStartDownload(WebContents* source, |
292 DownloadItem* download) { | 292 DownloadItem* download) { |
293 // TODO(leandrogracia): re-enable this when calling DownloadController | 293 DownloadControllerAndroid::Get()->OnPostDownloadStarted( |
294 // doesn't introduce a DEPS layering violation. | 294 source, download); |
joth
2012/10/12 18:55:13
I'd suggest deleting these 2 methods from here, pu
nilesh
2012/10/12 19:23:22
I assume the plan is to move everything out of thi
| |
295 // DownloadController::GetInstance()->OnPostDownloadStarted( | |
296 // source, download); | |
297 } | 295 } |
298 | 296 |
299 bool WebContentsDelegateAndroid::ShouldOverrideLoading(const GURL& url) { | 297 bool WebContentsDelegateAndroid::ShouldOverrideLoading(const GURL& url) { |
300 if (!url.is_valid()) | 298 if (!url.is_valid()) |
301 return false; | 299 return false; |
302 | 300 |
303 JNIEnv* env = AttachCurrentThread(); | 301 JNIEnv* env = AttachCurrentThread(); |
304 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 302 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
305 if (obj.is_null()) | 303 if (obj.is_null()) |
306 return WebContentsDelegate::ShouldOverrideLoading(url); | 304 return WebContentsDelegate::ShouldOverrideLoading(url); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 | 340 |
343 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 341 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
344 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { | 342 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { |
345 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; | 343 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; |
346 return false; | 344 return false; |
347 } | 345 } |
348 return RegisterNativesImpl(env); | 346 return RegisterNativesImpl(env); |
349 } | 347 } |
350 | 348 |
351 } // namespace web_contents_delegate_android | 349 } // namespace web_contents_delegate_android |
OLD | NEW |