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

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

Issue 13649009: Android: Use a ResourceThrottle to intercept GET downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/file_select_helper.h" 10 #include "chrome/browser/file_select_helper.h"
11 #include "chrome/browser/google/google_url_tracker.h" 11 #include "chrome/browser/google/google_url_tracker.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" 13 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h"
14 #include "chrome/browser/ui/find_bar/find_match_rects_details.h" 14 #include "chrome/browser/ui/find_bar/find_match_rects_details.h"
15 #include "chrome/browser/ui/find_bar/find_notification_details.h" 15 #include "chrome/browser/ui/find_bar/find_notification_details.h"
16 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 16 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
17 #include "chrome/browser/ui/media_stream_infobar_delegate.h" 17 #include "chrome/browser/ui/media_stream_infobar_delegate.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "content/public/browser/android/download_controller_android.h"
20 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/file_chooser_params.h" 24 #include "content/public/common/file_chooser_params.h"
26 #include "content/public/common/page_transition_types.h" 25 #include "content/public/common/page_transition_types.h"
27 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" 26 #include "jni/ChromeWebContentsDelegateAndroid_jni.h"
28 #include "net/http/http_request_headers.h"
29 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
30 #include "ui/gfx/rect_f.h" 28 #include "ui/gfx/rect_f.h"
31 29
32 #if defined(ENABLE_PLUGINS) 30 #if defined(ENABLE_PLUGINS)
33 #include "chrome/browser/pepper_broker_infobar_delegate.h" 31 #include "chrome/browser/pepper_broker_infobar_delegate.h"
34 #endif 32 #endif
35 33
36 using base::android::ScopedJavaLocalRef; 34 using base::android::ScopedJavaLocalRef;
37 using content::FileChooserParams; 35 using content::FileChooserParams;
38 using content::NavigationController; 36 using content::NavigationController;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 env, 219 env,
222 obj.obj(), 220 obj.obj(),
223 details_object.obj()); 221 details_object.obj());
224 } 222 }
225 223
226 content::JavaScriptDialogManager* 224 content::JavaScriptDialogManager*
227 ChromeWebContentsDelegateAndroid::GetJavaScriptDialogManager() { 225 ChromeWebContentsDelegateAndroid::GetJavaScriptDialogManager() {
228 return GetJavaScriptDialogManagerInstance(); 226 return GetJavaScriptDialogManagerInstance();
229 } 227 }
230 228
231 void ChromeWebContentsDelegateAndroid::CanDownload(
232 content::RenderViewHost* source,
233 int request_id,
234 const std::string& request_method,
235 const base::Callback<void(bool)>& callback) {
236 if (request_method == net::HttpRequestHeaders::kGetMethod) {
237 content::DownloadControllerAndroid::Get()->CreateGETDownload(
238 source, request_id);
239 callback.Run(false);
240 }
241 // DownloadControllerAndroid::OnPostDownloadStarted() is called for the
242 // started download by the default DownloadUIController::Delegate
243 // implementation.
244 callback.Run(true);
245 }
246
247 void ChromeWebContentsDelegateAndroid::DidNavigateToPendingEntry( 229 void ChromeWebContentsDelegateAndroid::DidNavigateToPendingEntry(
248 content::WebContents* source) { 230 content::WebContents* source) {
249 navigation_start_time_ = base::TimeTicks::Now(); 231 navigation_start_time_ = base::TimeTicks::Now();
250 } 232 }
251 233
252 void ChromeWebContentsDelegateAndroid::DidNavigateMainFramePostCommit( 234 void ChromeWebContentsDelegateAndroid::DidNavigateMainFramePostCommit(
253 content::WebContents* source) { 235 content::WebContents* source) {
254 if (!IsActiveNavigationGoogleSearch(source)) 236 if (!IsActiveNavigationGoogleSearch(source))
255 return; 237 return;
256 238
(...skipping 22 matching lines...) Expand all
279 web_contents, url, plugin_path, callback); 261 web_contents, url, plugin_path, callback);
280 return true; 262 return true;
281 #else 263 #else
282 return false; 264 return false;
283 #endif 265 #endif
284 } 266 }
285 267
286 268
287 } // namespace android 269 } // namespace android
288 } // namespace chrome 270 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698