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_permission_context.h" | 5 #include "chrome/browser/plugins/flash_permission_context.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | |
9 #include "chrome/browser/permissions/permission_request_id.h" | 8 #include "chrome/browser/permissions/permission_request_id.h" |
10 #include "chrome/browser/plugins/plugin_utils.h" | 9 #include "chrome/browser/plugins/plugin_utils.h" |
11 #include "chrome/browser/plugins/plugins_field_trial.h" | 10 #include "chrome/browser/plugins/plugins_field_trial.h" |
12 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h
" | |
13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 11 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 12 #include "content/public/browser/navigation_controller.h" |
14 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
| 14 #include "content/public/browser/web_contents.h" |
15 | 15 |
16 FlashPermissionContext::FlashPermissionContext(Profile* profile) | 16 FlashPermissionContext::FlashPermissionContext(Profile* profile) |
17 : PermissionContextBase(profile, | 17 : PermissionContextBase(profile, |
18 content::PermissionType::FLASH, | 18 content::PermissionType::FLASH, |
19 CONTENT_SETTINGS_TYPE_PLUGINS) {} | 19 CONTENT_SETTINGS_TYPE_PLUGINS) {} |
20 | 20 |
21 FlashPermissionContext::~FlashPermissionContext() {} | 21 FlashPermissionContext::~FlashPermissionContext() {} |
22 | 22 |
23 ContentSetting FlashPermissionContext::GetPermissionStatus( | 23 ContentSetting FlashPermissionContext::GetPermissionStatus( |
24 const GURL& requesting_origin, | 24 const GURL& requesting_origin, |
25 const GURL& embedding_origin) const { | 25 const GURL& embedding_origin) const { |
26 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 26 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( |
27 HostContentSettingsMapFactory::GetForProfile(profile()), embedding_origin, | 27 HostContentSettingsMapFactory::GetForProfile(profile()), embedding_origin, |
28 requesting_origin, nullptr); | 28 requesting_origin, nullptr); |
29 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 29 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
30 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 30 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
31 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) | 31 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) |
32 return CONTENT_SETTING_ASK; | 32 return CONTENT_SETTING_ASK; |
33 return flash_setting; | 33 return flash_setting; |
34 } | 34 } |
35 | 35 |
36 void FlashPermissionContext::UpdateTabContext(const PermissionRequestID& id, | 36 void FlashPermissionContext::UpdateTabContext(const PermissionRequestID& id, |
37 const GURL& requesting_origin, | 37 const GURL& requesting_origin, |
38 bool allowed) { | 38 bool allowed) { |
39 if (!allowed) | 39 if (!allowed) |
40 return; | 40 return; |
| 41 // Automatically refresh the page. |
41 content::WebContents* web_contents = | 42 content::WebContents* web_contents = |
42 content::WebContents::FromRenderFrameHost( | 43 content::WebContents::FromRenderFrameHost( |
43 content::RenderFrameHost::FromID(id.render_process_id(), | 44 content::RenderFrameHost::FromID(id.render_process_id(), |
44 id.render_frame_id())); | 45 id.render_frame_id())); |
45 InfoBarService* infobar_service = | 46 web_contents->GetController().Reload(true /* check_for_repost */); |
46 InfoBarService::FromWebContents(web_contents); | |
47 if (infobar_service) | |
48 WebsiteSettingsInfoBarDelegate::Create(infobar_service); | |
49 } | 47 } |
50 | 48 |
51 bool FlashPermissionContext::IsRestrictedToSecureOrigins() const { | 49 bool FlashPermissionContext::IsRestrictedToSecureOrigins() const { |
52 return false; | 50 return false; |
53 } | 51 } |
OLD | NEW |