Chromium Code Reviews| 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 |