Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #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.
| |
| 2 | |
| 3 #include "base/callback.h" | |
| 4 #include "android_webview/native/aw_contents.h" | |
| 5 #include "android_webview/native/aw_web_contents_delegate.h" | |
| 6 #include "content/public/browser/browser_thread.h" | |
| 7 #include "content/public/browser/render_view_host.h" | |
| 8 #include "content/public/browser/web_contents.h" | |
| 9 | |
| 10 using content::BrowserThread; | |
| 11 using content::RenderViewHost; | |
| 12 using content::WebContents; | |
| 13 using navigation_interception::InterceptNavigationResourceThrottle; | |
| 14 | |
| 15 namespace android_webview { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 bool CheckIfShouldIgnoreNavigationOnUIThread(RenderViewHost* source, | |
| 20 const GURL& url, | |
| 21 const content::Referrer& referrer, | |
| 22 bool is_content_initiated) { | |
| 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 24 DCHECK(source); | |
| 25 | |
| 26 WebContents* web_contents = WebContents::FromRenderViewHost(source); | |
| 27 if (!web_contents) return false; | |
| 28 AwContents* aw_contents = AwContents::FromWebContents(web_contents); | |
| 29 if (!web_contents) return false; | |
| 30 AwWebContentsDelegate* aw_web_contents_delegate = | |
| 31 aw_contents->GetAwWebContentsDelegate(); | |
| 32 if (!aw_web_contents_delegate) return false; | |
| 33 | |
| 34 return aw_web_contents_delegate->ShouldIgnoreNavigation(url); | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 //static | |
| 40 InterceptNavigationResourceThrottle* | |
| 41 AwInterceptNavigationResourceThrottle::Create(net::URLRequest* request) { | |
| 42 return new InterceptNavigationResourceThrottle( | |
| 43 request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread)); | |
| 44 } | |
| 45 | |
| 46 } // namespace android_webview | |
| OLD | NEW |