Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/plugins/flash_download_interception.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 #include "chrome/common/chrome_features.h" | |
| 12 #include "components/navigation_interception/intercept_navigation_throttle.h" | |
| 13 #include "components/navigation_interception/navigation_params.h" | |
| 14 #include "content/public/browser/browser_thread.h" | |
| 15 #include "content/public/browser/navigation_handle.h" | |
| 16 #include "content/public/browser/web_contents.h" | |
| 17 | |
| 18 using content::BrowserThread; | |
| 19 using content::WebContents; | |
|
Lei Zhang
2016/08/25 00:55:06
not needed
trizzofo
2016/08/25 01:50:36
Done.
| |
| 20 using content::NavigationHandle; | |
| 21 using content::NavigationThrottle; | |
| 22 | |
| 23 namespace { | |
| 24 | |
| 25 const char kFlashDownloadURL[] = "get.adobe.com/flashplayer"; | |
| 26 | |
| 27 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.
| |
| 28 content::WebContents* source, | |
| 29 const navigation_interception::NavigationParams& params) { | |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 31 return true; | |
| 32 } | |
| 33 | |
| 34 } // namespace | |
| 35 | |
| 36 // static | |
| 37 std::unique_ptr<NavigationThrottle> | |
| 38 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { | |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 40 | |
| 41 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) | |
| 42 return nullptr; | |
| 43 | |
| 44 if (!handle->HasUserGesture()) | |
| 45 return nullptr; | |
| 46 | |
| 47 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.
| |
| 48 kFlashDownloadURL)) { | |
| 49 return nullptr; | |
| 50 } | |
| 51 | |
| 52 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | |
| 53 handle, base::Bind(&ShouldInterceptNavigation), true); | |
| 54 } | |
| OLD | NEW |