| 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 "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // static | 114 // static |
| 115 std::unique_ptr<NavigationThrottle> | 115 std::unique_ptr<NavigationThrottle> |
| 116 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { | 116 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { |
| 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 118 | 118 |
| 119 // Never intercept Flash Download navigations in a new window. | |
| 120 if (handle->GetWebContents()->HasOpener()) | |
| 121 return nullptr; | |
| 122 | |
| 123 // Browser initiated navigations like the Back button or the context menu | 119 // Browser initiated navigations like the Back button or the context menu |
| 124 // should never be intercepted. | 120 // should never be intercepted. |
| 125 if (!handle->IsRendererInitiated()) | 121 if (!handle->IsRendererInitiated()) |
| 126 return nullptr; | 122 return nullptr; |
| 127 | 123 |
| 128 // The source URL may be empty, it's a new tab. Intercepting that navigation | 124 // The source URL may be empty, it's a new tab. Intercepting that navigation |
| 129 // would lead to a blank new tab, which would be bad. | 125 // would lead to a blank new tab, which would be bad. |
| 130 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); | 126 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); |
| 131 if (source_url.is_empty()) | 127 if (source_url.is_empty()) |
| 132 return nullptr; | 128 return nullptr; |
| 133 | 129 |
| 134 Profile* profile = Profile::FromBrowserContext( | 130 Profile* profile = Profile::FromBrowserContext( |
| 135 handle->GetWebContents()->GetBrowserContext()); | 131 handle->GetWebContents()->GetBrowserContext()); |
| 136 HostContentSettingsMap* host_content_settings_map = | 132 HostContentSettingsMap* host_content_settings_map = |
| 137 HostContentSettingsMapFactory::GetForProfile(profile); | 133 HostContentSettingsMapFactory::GetForProfile(profile); |
| 138 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, | 134 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, |
| 139 handle->GetURL(), | 135 handle->GetURL(), |
| 140 handle->HasUserGesture())) { | 136 handle->HasUserGesture())) { |
| 141 return nullptr; | 137 return nullptr; |
| 142 } | 138 } |
| 143 | 139 |
| 144 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 140 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 145 handle, base::Bind(&InterceptNavigation, source_url), true); | 141 handle, base::Bind(&InterceptNavigation, source_url), true); |
| 146 } | 142 } |
| OLD | NEW |