OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/plugins/flash_download_interception.h" | 5 #include "chrome/browser/plugins/flash_download_interception.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 11 #include "chrome/browser/plugins/plugins_field_trial.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_features.h" | 13 #include "chrome/common/chrome_features.h" |
| 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
11 #include "components/navigation_interception/intercept_navigation_throttle.h" | 15 #include "components/navigation_interception/intercept_navigation_throttle.h" |
12 #include "components/navigation_interception/navigation_params.h" | 16 #include "components/navigation_interception/navigation_params.h" |
13 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/navigation_handle.h" | 18 #include "content/public/browser/navigation_handle.h" |
15 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
16 | 20 |
17 using content::BrowserThread; | 21 using content::BrowserThread; |
18 using content::NavigationHandle; | 22 using content::NavigationHandle; |
19 using content::NavigationThrottle; | 23 using content::NavigationThrottle; |
20 | 24 |
(...skipping 20 matching lines...) Expand all Loading... |
41 return nullptr; | 45 return nullptr; |
42 | 46 |
43 if (!handle->HasUserGesture()) | 47 if (!handle->HasUserGesture()) |
44 return nullptr; | 48 return nullptr; |
45 | 49 |
46 if (!base::StartsWith(handle->GetURL().GetContent(), kFlashDownloadURL, | 50 if (!base::StartsWith(handle->GetURL().GetContent(), kFlashDownloadURL, |
47 base::CompareCase::INSENSITIVE_ASCII)) { | 51 base::CompareCase::INSENSITIVE_ASCII)) { |
48 return nullptr; | 52 return nullptr; |
49 } | 53 } |
50 | 54 |
| 55 Profile* profile = Profile::FromBrowserContext( |
| 56 handle->GetWebContents()->GetBrowserContext()); |
| 57 HostContentSettingsMap* host_content_settings_map = |
| 58 HostContentSettingsMapFactory::GetForProfile(profile); |
| 59 GURL page_url = handle->GetWebContents()->GetLastCommittedURL(); |
| 60 |
| 61 std::unique_ptr<base::Value> general_setting = |
| 62 host_content_settings_map->GetWebsiteSetting( |
| 63 page_url, page_url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), |
| 64 nullptr); |
| 65 ContentSetting plugin_setting = |
| 66 content_settings::ValueToContentSetting(general_setting.get()); |
| 67 plugin_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 68 CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting); |
| 69 |
| 70 if (plugin_setting != CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) |
| 71 return nullptr; |
| 72 |
51 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 73 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
52 handle, base::Bind(&ShouldInterceptNavigation), true); | 74 handle, base::Bind(&ShouldInterceptNavigation), true); |
53 } | 75 } |
OLD | NEW |