Chromium Code Reviews| Index: chrome/browser/plugins/flash_download_interception.cc |
| diff --git a/chrome/browser/plugins/flash_download_interception.cc b/chrome/browser/plugins/flash_download_interception.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b9020fd37e5411077d22fbcf18e35bb20e3b6280 |
| --- /dev/null |
| +++ b/chrome/browser/plugins/flash_download_interception.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 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/plugins/flash_download_interception.h" |
| + |
| +#include <string> |
| + |
| +#include "base/bind.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "components/navigation_interception/intercept_navigation_throttle.h" |
| +#include "components/navigation_interception/navigation_params.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/navigation_handle.h" |
| +#include "content/public/browser/web_contents.h" |
| + |
| +using content::BrowserThread; |
| +using content::WebContents; |
| + |
| +namespace { |
| + |
| +const char kFlashDownloadURL[] = "get.adobe.com/flashplayer"; |
| + |
| +bool ShouldInterceptNavigation( |
| + content::WebContents* source, |
| + const navigation_interception::NavigationParams& params) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + return true; |
| +} |
| + |
| +} // namespace |
| + |
| +// static |
| +std::unique_ptr<content::NavigationThrottle> |
| +FlashDownloadInterception::MaybeCreateThrottleFor( |
|
tommycli
2016/08/24 19:11:30
nit: You ran git cl format right?
trizzofo
2016/08/24 22:45:13
Yes, I ran it. I've now added a "using content::Na
|
| + content::NavigationHandle* handle) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + |
| + if (!handle->HasUserGesture()) |
| + return nullptr; |
| + |
| + if (handle->GetURL().GetContent().compare(0, strlen(kFlashDownloadURL), |
| + kFlashDownloadURL)) { |
| + return nullptr; |
| + } |
| + |
| + return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| + handle, base::Bind(&ShouldInterceptNavigation), true); |
| +} |