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

Unified Diff: chrome/browser/android/chrome_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: chrome/browser/android/chrome_intercept_navigation_resource_throttle.cc
diff --git a/chrome/browser/android/chrome_intercept_navigation_resource_throttle.cc b/chrome/browser/android/chrome_intercept_navigation_resource_throttle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..15d50e5eba9083cf6991036f4bf485d0d6c53c8c
--- /dev/null
+++ b/chrome/browser/android/chrome_intercept_navigation_resource_throttle.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/chrome_intercept_navigation_resource_throttle.h"
+
+#include "base/callback.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "chrome/browser/android/chrome_web_contents_delegate_android.h"
+#include "chrome/browser/android/tab_android.h"
+
+using chrome::android::ChromeWebContentsDelegateAndroid;
+using content::BrowserThread;
+using content::RenderViewHost;
+using content::WebContents;
+using navigation_interception::InterceptNavigationResourceThrottle;
+
+namespace chrome {
+namespace android {
+
+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;
+ TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
+ if (!tab_android) return false;
+ ChromeWebContentsDelegateAndroid* chrome_web_contents_delegate =
+ tab_android->GetChromeWebContentsDelegateAndroid();
+ if (!chrome_web_contents_delegate) return false;
+
+ return chrome_web_contents_delegate->ShouldIgnoreNavigation(
+ url, is_content_initiated);
+}
+
+} // namespace
+
+// static
+InterceptNavigationResourceThrottle*
+ChromeInterceptNavigationResourceThrottle::Create(net::URLRequest* request) {
+ return new InterceptNavigationResourceThrottle(
+ request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread));
+}
+
+} // namespace android
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698