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

Unified Diff: chrome/browser/plugins/flash_download_interception.cc

Issue 2272123002: [HBD] Intercept navigation to Flash download page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per Lei Zhang's comments Created 4 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/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..887ab7985fd233c2fad1998a6ec632d0cae6d21e
--- /dev/null
+++ b/chrome/browser/plugins/flash_download_interception.cc
@@ -0,0 +1,53 @@
+// 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 "base/bind.h"
+#include "base/memory/ptr_util.h"
+#include "base/strings/string_util.h"
+#include "chrome/common/chrome_features.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::NavigationHandle;
+using content::NavigationThrottle;
+
+namespace {
+
+const char kFlashDownloadURL[] = "get.adobe.com/flashplayer";
+
+bool ShouldInterceptNavigation(
+ content::WebContents* source,
+ const navigation_interception::NavigationParams& params) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ // TODO(crbug.com/626728): Implement permission prompt logic.
+ return true;
+}
+
+} // namespace
+
+// static
+std::unique_ptr<NavigationThrottle>
+FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins))
+ return nullptr;
+
+ if (!handle->HasUserGesture())
+ return nullptr;
+
+ if (!base::StartsWith(handle->GetURL().GetContent(), kFlashDownloadURL,
+ base::CompareCase::INSENSITIVE_ASCII)) {
+ return nullptr;
+ }
+
+ return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
+ handle, base::Bind(&ShouldInterceptNavigation), true);
+}
« no previous file with comments | « chrome/browser/plugins/flash_download_interception.h ('k') | chrome/browser/plugins/flash_download_interception_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698