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

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 tommycli@'s comments Created 4 years, 4 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..bb0e5586e167af819a0bc2c29f7a1affaf8ed6e6
--- /dev/null
+++ b/chrome/browser/plugins/flash_download_interception.cc
@@ -0,0 +1,54 @@
+// 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 "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::WebContents;
Lei Zhang 2016/08/25 00:55:06 not needed
trizzofo 2016/08/25 01:50:36 Done.
+using content::NavigationHandle;
+using content::NavigationThrottle;
+
+namespace {
+
+const char kFlashDownloadURL[] = "get.adobe.com/flashplayer";
+
+bool ShouldInterceptNavigation(
Lei Zhang 2016/08/25 00:55:06 Does this need a comment or a TODO?
trizzofo 2016/08/25 01:50:36 Added a TODO to body.
+ content::WebContents* source,
+ const navigation_interception::NavigationParams& params) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ 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 (handle->GetURL().GetContent().compare(0, strlen(kFlashDownloadURL),
Lei Zhang 2016/08/25 00:55:07 Use base::StartsWith() ?
trizzofo 2016/08/25 01:50:36 Done.
+ kFlashDownloadURL)) {
+ return nullptr;
+ }
+
+ return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
+ handle, base::Bind(&ShouldInterceptNavigation), true);
+}

Powered by Google App Engine
This is Rietveld 408576698