| 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 "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/common/chrome_features.h" |
| 11 #include "components/navigation_interception/intercept_navigation_throttle.h" |
| 12 #include "components/navigation_interception/navigation_params.h" |
| 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/navigation_handle.h" |
| 15 #include "content/public/browser/web_contents.h" |
| 16 |
| 17 using content::BrowserThread; |
| 18 using content::NavigationHandle; |
| 19 using content::NavigationThrottle; |
| 20 |
| 21 namespace { |
| 22 |
| 23 const char kFlashDownloadURL[] = "get.adobe.com/flashplayer"; |
| 24 |
| 25 bool ShouldInterceptNavigation( |
| 26 content::WebContents* source, |
| 27 const navigation_interception::NavigationParams& params) { |
| 28 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 29 // TODO(crbug.com/626728): Implement permission prompt logic. |
| 30 return true; |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
| 35 // static |
| 36 std::unique_ptr<NavigationThrottle> |
| 37 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { |
| 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 39 |
| 40 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) |
| 41 return nullptr; |
| 42 |
| 43 if (!handle->HasUserGesture()) |
| 44 return nullptr; |
| 45 |
| 46 if (!base::StartsWith(handle->GetURL().GetContent(), kFlashDownloadURL, |
| 47 base::CompareCase::INSENSITIVE_ASCII)) { |
| 48 return nullptr; |
| 49 } |
| 50 |
| 51 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 52 handle, base::Bind(&ShouldInterceptNavigation), true); |
| 53 } |
| OLD | NEW |