| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/chrome_intercept_navigation_resource_throttle.h
" |
| 6 |
| 7 #include "base/callback.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/browser/web_contents.h" |
| 11 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
| 12 #include "chrome/browser/android/tab_android.h" |
| 13 |
| 14 using chrome::android::ChromeWebContentsDelegateAndroid; |
| 15 using content::BrowserThread; |
| 16 using content::RenderViewHost; |
| 17 using content::WebContents; |
| 18 using navigation_interception::InterceptNavigationResourceThrottle; |
| 19 |
| 20 namespace chrome { |
| 21 namespace android { |
| 22 |
| 23 namespace { |
| 24 |
| 25 bool CheckIfShouldIgnoreNavigationOnUIThread(RenderViewHost* source, |
| 26 const GURL& url, |
| 27 const content::Referrer& referrer, |
| 28 bool is_content_initiated) { |
| 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 30 DCHECK(source); |
| 31 |
| 32 WebContents* web_contents = WebContents::FromRenderViewHost(source); |
| 33 if (!web_contents) return false; |
| 34 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 35 if (!tab_android) return false; |
| 36 ChromeWebContentsDelegateAndroid* chrome_web_contents_delegate = |
| 37 tab_android->GetChromeWebContentsDelegateAndroid(); |
| 38 if (!chrome_web_contents_delegate) return false; |
| 39 |
| 40 return chrome_web_contents_delegate->ShouldIgnoreNavigation( |
| 41 url, is_content_initiated); |
| 42 } |
| 43 |
| 44 } // namespace |
| 45 |
| 46 // static |
| 47 InterceptNavigationResourceThrottle* |
| 48 ChromeInterceptNavigationResourceThrottle::Create(net::URLRequest* request) { |
| 49 return new InterceptNavigationResourceThrottle( |
| 50 request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread)); |
| 51 } |
| 52 |
| 53 } // namespace android |
| 54 } // namespace chrome |
| OLD | NEW |