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

Side by Side Diff: chrome/browser/android/chrome_web_contents_delegate_android.cc

Issue 11112022: Add DownloadControllerAndroid public interface for android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 "chrome/browser/android/chrome_web_contents_delegate_android.h" 5 #include "chrome/browser/android/chrome_web_contents_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "chrome/browser/file_select_helper.h" 8 #include "chrome/browser/file_select_helper.h"
9 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" 9 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
10 #include "chrome/browser/ui/find_bar/find_match_rects_details.h" 10 #include "chrome/browser/ui/find_bar/find_match_rects_details.h"
11 #include "chrome/browser/ui/find_bar/find_notification_details.h" 11 #include "chrome/browser/ui/find_bar/find_notification_details.h"
12 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 12 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "content/public/browser/android/download_controller_android.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/file_chooser_params.h" 19 #include "content/public/common/file_chooser_params.h"
19 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" 20 #include "jni/ChromeWebContentsDelegateAndroid_jni.h"
21 #include "net/http/http_request_headers.h"
20 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
21 #include "ui/gfx/rect_f.h" 23 #include "ui/gfx/rect_f.h"
22 24
23 using base::android::AttachCurrentThread; 25 using base::android::AttachCurrentThread;
24 using base::android::GetClass; 26 using base::android::GetClass;
25 using base::android::ScopedJavaLocalRef; 27 using base::android::ScopedJavaLocalRef;
26 using content::FileChooserParams; 28 using content::FileChooserParams;
27 using content::WebContents; 29 using content::WebContents;
28 30
31 namespace content {
32 class DownloadItem;
33 }
jam 2012/10/15 06:45:04 nit: unnecessary
nilesh 2012/10/15 17:13:51 Removed
34
29 namespace { 35 namespace {
30 36
31 // Convenience method to create Android rects. 37 // Convenience method to create Android rects.
32 // RectType should be either gfx::Rect or gfx::RectF. 38 // RectType should be either gfx::Rect or gfx::RectF.
33 template <typename RectType> 39 template <typename RectType>
34 ScopedJavaLocalRef<jobject> CreateAndroidRect( 40 ScopedJavaLocalRef<jobject> CreateAndroidRect(
35 JNIEnv* env, 41 JNIEnv* env,
36 const ScopedJavaLocalRef<jclass>& clazz, 42 const ScopedJavaLocalRef<jclass>& clazz,
37 const jmethodID& constructor, 43 const jmethodID& constructor,
38 const RectType& rect) { 44 const RectType& rect) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 env, 233 env,
228 obj.obj(), 234 obj.obj(),
229 details_object.obj()); 235 details_object.obj());
230 } 236 }
231 237
232 content::JavaScriptDialogCreator* 238 content::JavaScriptDialogCreator*
233 ChromeWebContentsDelegateAndroid::GetJavaScriptDialogCreator() { 239 ChromeWebContentsDelegateAndroid::GetJavaScriptDialogCreator() {
234 return GetJavaScriptDialogCreatorInstance(); 240 return GetJavaScriptDialogCreatorInstance();
235 } 241 }
236 242
243 bool ChromeWebContentsDelegateAndroid::CanDownload(
244 content::RenderViewHost* source,
245 int request_id,
246 const std::string& request_method) {
247 if (request_method == net::HttpRequestHeaders::kGetMethod) {
248 content::DownloadControllerAndroid::Get()->CreateGETDownload(
249 source, request_id);
250 return false;
251 }
252 return true;
253 }
254
255 void ChromeWebContentsDelegateAndroid::OnStartDownload(
256 WebContents* source,
257 content::DownloadItem* download) {
258 content::DownloadControllerAndroid::Get()->OnPostDownloadStarted(
259 source, download);
260 }
261
237 } // namespace android 262 } // namespace android
238 } // namespace chrome 263 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698