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

Unified Diff: android_webview/native/aw_intercept_navigation_resource_throttle.cc

Issue 10946008: Componentize IgnoreNavigationResourceThrottle and add chrome and webview specific implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_intercept_navigation_resource_throttle.cc
diff --git a/android_webview/native/aw_intercept_navigation_resource_throttle.cc b/android_webview/native/aw_intercept_navigation_resource_throttle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..650e5c4faeb96678f53b94d29f4bc96af01d98df
--- /dev/null
+++ b/android_webview/native/aw_intercept_navigation_resource_throttle.cc
@@ -0,0 +1,46 @@
+#include "android_webview/browser/aw_intercept_navigation_resource_throttle.h"
benm (inactive) 2012/09/19 11:04:04 copyright
mkosiba (inactive) 2012/09/25 18:01:47 Done.
+
+#include "base/callback.h"
+#include "android_webview/native/aw_contents.h"
+#include "android_webview/native/aw_web_contents_delegate.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+
+using content::BrowserThread;
+using content::RenderViewHost;
+using content::WebContents;
+using navigation_interception::InterceptNavigationResourceThrottle;
+
+namespace android_webview {
+
+namespace {
+
+bool CheckIfShouldIgnoreNavigationOnUIThread(RenderViewHost* source,
+ const GURL& url,
+ const content::Referrer& referrer,
+ bool is_content_initiated) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(source);
+
+ WebContents* web_contents = WebContents::FromRenderViewHost(source);
+ if (!web_contents) return false;
+ AwContents* aw_contents = AwContents::FromWebContents(web_contents);
+ if (!web_contents) return false;
+ AwWebContentsDelegate* aw_web_contents_delegate =
+ aw_contents->GetAwWebContentsDelegate();
+ if (!aw_web_contents_delegate) return false;
+
+ return aw_web_contents_delegate->ShouldIgnoreNavigation(url);
+}
+
+} // namespace
+
+//static
+InterceptNavigationResourceThrottle*
+AwInterceptNavigationResourceThrottle::Create(net::URLRequest* request) {
+ return new InterceptNavigationResourceThrottle(
+ request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread));
+}
+
+} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698