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

Unified Diff: chrome/browser/plugins/flash_download_interception.cc

Issue 2354443002: Implement PluginsPermissionContext and hookup to flash download interception. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/plugins/plugins_permission_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 13e0e164f72c8cd5ce18c9bec1bd06ee46edcb4f..e6adfbaff20236de1a818c197542c0b564c3a6ed 100644
--- a/chrome/browser/plugins/flash_download_interception.cc
+++ b/chrome/browser/plugins/flash_download_interception.cc
@@ -8,15 +8,17 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
-#include "chrome/browser/plugins/plugins_field_trial.h"
+#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
-#include "components/content_settings/core/browser/host_content_settings_map.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/permission_type.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
+#include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h"
using content::BrowserThread;
using content::NavigationHandle;
@@ -26,11 +28,19 @@ namespace {
const char kFlashDownloadURL[] = "get.adobe.com/flashplayer";
+void DoNothing(blink::mojom::PermissionStatus result) {}
tommycli 2016/09/19 16:44:26 Don't we need to refresh the page after getting th
raymes 2016/09/21 05:46:06 This happens in FlashPermissionContext::UpdateTabC
tommycli 2016/09/23 23:27:26 Sounds good. The CL as-is makes sense, but I think
+
bool ShouldInterceptNavigation(
content::WebContents* source,
const navigation_interception::NavigationParams& params) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // TODO(crbug.com/626728): Implement permission prompt logic.
+ PermissionManager* manager = PermissionManager::Get(
+ Profile::FromBrowserContext(source->GetBrowserContext()));
+ content::RenderFrameHost* rfh = source->GetMainFrame();
dominickn 2016/09/19 05:54:22 Nit: inline source->GetMainFrame() and use source-
raymes 2016/09/21 05:46:05 Done.
+ manager->RequestPermission(content::PermissionType::PLUGINS, rfh,
+ rfh->GetLastCommittedURL(), true,
+ base::Bind(&DoNothing));
+
return true;
}
@@ -52,22 +62,15 @@ FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) {
return nullptr;
}
- Profile* profile = Profile::FromBrowserContext(
- handle->GetWebContents()->GetBrowserContext());
- HostContentSettingsMap* host_content_settings_map =
- HostContentSettingsMapFactory::GetForProfile(profile);
GURL page_url = handle->GetWebContents()->GetLastCommittedURL();
- std::unique_ptr<base::Value> general_setting =
- host_content_settings_map->GetWebsiteSetting(
- page_url, page_url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
raymes 2016/09/19 05:40:28 We need to decide if we should be passing the reso
- nullptr);
- ContentSetting plugin_setting =
- content_settings::ValueToContentSetting(general_setting.get());
- plugin_setting = PluginsFieldTrial::EffectiveContentSetting(
- CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting);
+ Profile* profile = Profile::FromBrowserContext(
+ handle->GetWebContents()->GetBrowserContext());
+ PermissionManager* manager = PermissionManager::Get(profile);
+ blink::mojom::PermissionStatus status = manager->GetPermissionStatus(
+ content::PermissionType::PLUGINS, page_url, page_url);
- if (plugin_setting != CONTENT_SETTING_DETECT_IMPORTANT_CONTENT)
+ if (status != blink::mojom::PermissionStatus::ASK)
tommycli 2016/09/19 16:44:26 As I understand it, the code was moved because the
raymes 2016/09/21 05:46:05 Correct - the code is pretty much needed there so
return nullptr;
return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
« no previous file with comments | « no previous file | chrome/browser/plugins/plugins_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698