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

Unified Diff: chrome/browser/component/navigation_interception/intercept_navigation_resource_throttle.cc

Issue 11293017: Move navigation interception component to content/components (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add findbugs suppression for compatibility code. Created 8 years, 1 month 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/component/navigation_interception/intercept_navigation_resource_throttle.cc
diff --git a/chrome/browser/component/navigation_interception/intercept_navigation_resource_throttle.cc b/chrome/browser/component/navigation_interception/intercept_navigation_resource_throttle.cc
deleted file mode 100644
index 33101759efa0266c2c8367aa0f5e5d6356edbab4..0000000000000000000000000000000000000000
--- a/chrome/browser/component/navigation_interception/intercept_navigation_resource_throttle.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// 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/component/navigation_interception/intercept_navigation_resource_throttle.h"
-
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/resource_request_info.h"
-#include "content/public/browser/resource_controller.h"
-#include "content/public/common/referrer.h"
-#include "net/url_request/url_request.h"
-
-using content::BrowserThread;
-using content::ChildProcessSecurityPolicy;
-using content::Referrer;
-using content::RenderViewHost;
-using content::ResourceRequestInfo;
-
-namespace navigation_interception {
-
-namespace {
-
-void CheckIfShouldIgnoreNavigationOnUIThread(
- int render_process_id,
- int render_view_id,
- const GURL& url,
- const Referrer& referrer,
- bool has_user_gesture,
- InterceptNavigationResourceThrottle::CheckOnUIThreadCallback
- should_ignore_callback,
- base::Callback<void(bool)> callback) {
-
- bool should_ignore_navigation = false;
- RenderViewHost* rvh =
- RenderViewHost::FromID(render_process_id, render_view_id);
-
- if (rvh) {
- GURL validated_url(url);
- RenderViewHost::FilterURL(rvh->GetProcess(), false, &validated_url);
-
- should_ignore_navigation = should_ignore_callback.Run(
- rvh, validated_url, referrer, has_user_gesture);
- }
-
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(callback, should_ignore_navigation));
-}
-
-} // namespace
-
-InterceptNavigationResourceThrottle::InterceptNavigationResourceThrottle(
- net::URLRequest* request,
- CheckOnUIThreadCallback should_ignore_callback)
- : request_(request),
- should_ignore_callback_(should_ignore_callback),
- weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
-}
-
-InterceptNavigationResourceThrottle::~InterceptNavigationResourceThrottle() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-}
-
-void InterceptNavigationResourceThrottle::WillStartRequest(bool* defer) {
- *defer = CheckIfShouldIgnoreNavigation(request_->url());
-}
-
-void InterceptNavigationResourceThrottle::WillRedirectRequest(
- const GURL& new_url,
- bool* defer) {
- *defer = CheckIfShouldIgnoreNavigation(new_url);
-}
-
-bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation(
- const GURL& url) {
- const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
- if (!info)
- return false;
-
- int render_process_id, render_view_id;
- if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id))
- return false;
-
- // This class should only be instantiated for top level frame requests.
- DCHECK(info->IsMainFrame());
-
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(
- &CheckIfShouldIgnoreNavigationOnUIThread,
- render_process_id,
- render_view_id,
- url,
- Referrer(GURL(request_->referrer()), info->GetReferrerPolicy()),
- info->HasUserGesture(),
- should_ignore_callback_,
- base::Bind(
- &InterceptNavigationResourceThrottle::OnResultObtained,
- weak_ptr_factory_.GetWeakPtr())));
-
- // Defer request while we wait for the UI thread to check if the navigation
- // should be ignored.
- return true;
-}
-
-void InterceptNavigationResourceThrottle::OnResultObtained(
- bool should_ignore_navigation) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- if (should_ignore_navigation) {
- controller()->CancelAndIgnore();
- } else {
- controller()->Resume();
- }
-}
-
-} // namespace navigation_interception

Powered by Google App Engine
This is Rietveld 408576698