OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/page_info/permission_menu_model.h" | 5 #include "chrome/browser/ui/page_info/permission_menu_model.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/plugins/plugin_utils.h" | 8 #include "chrome/browser/plugins/plugin_utils.h" |
9 #include "chrome/browser/plugins/plugins_field_trial.h" | 9 #include "chrome/browser/plugins/plugins_field_trial.h" |
10 #include "chrome/common/chrome_features.h" | 10 #include "chrome/common/chrome_features.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 | 63 |
64 // The Material UI for site settings uses comboboxes instead of menubuttons, | 64 // The Material UI for site settings uses comboboxes instead of menubuttons, |
65 // which means the elements of the menu themselves have to be shorter, instead | 65 // which means the elements of the menu themselves have to be shorter, instead |
66 // of simply setting a shorter label on the menubutton. | 66 // of simply setting a shorter label on the menubutton. |
67 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 67 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
68 label = PageInfoUI::PermissionActionToUIString( | 68 label = PageInfoUI::PermissionActionToUIString( |
69 profile, permission_.type, CONTENT_SETTING_DEFAULT, | 69 profile, permission_.type, CONTENT_SETTING_DEFAULT, |
70 effective_default_setting, permission_.source); | 70 effective_default_setting, permission_.source); |
71 } | 71 } |
72 | 72 |
73 AddCheckItem(CONTENT_SETTING_DEFAULT, label); | 73 bool subresource_filter_permission = |
74 permission_.type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER; | |
75 | |
76 // The subresource filter permission does not display the default menu item. | |
77 if (!subresource_filter_permission) | |
78 AddCheckItem(CONTENT_SETTING_DEFAULT, label); | |
74 | 79 |
75 // Retrieve the string to show for allowing the permission. | 80 // Retrieve the string to show for allowing the permission. |
76 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. | 81 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. |
77 bool allow_disabled_for_notifications = | 82 bool allow_disabled_for_notifications = |
78 permission_.is_incognito && | 83 permission_.is_incognito && |
79 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 84 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
80 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. | 85 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. |
81 bool is_media_permission = | 86 bool is_media_permission = |
82 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 87 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
83 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 88 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
84 if (!allow_disabled_for_notifications && | 89 if (!allow_disabled_for_notifications && |
85 (!is_media_permission || content::IsOriginSecure(url))) { | 90 (!is_media_permission || content::IsOriginSecure(url))) { |
86 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_ALLOW); | 91 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_ALLOW); |
87 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 92 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
88 label = PageInfoUI::PermissionActionToUIString( | 93 label = PageInfoUI::PermissionActionToUIString( |
89 profile, permission_.type, CONTENT_SETTING_ALLOW, | 94 profile, permission_.type, CONTENT_SETTING_ALLOW, |
90 effective_default_setting, permission_.source); | 95 effective_default_setting, permission_.source); |
91 } | 96 } |
97 | |
98 if (subresource_filter_permission) | |
99 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SUBRESOURCE_FILTER_ALLOW); | |
raymes
2017/05/15 23:41:21
Why can't we just leave this as IDS_PAGE_INFO_MENU
Charlie Harrison
2017/05/16 01:47:26
We will eventually want the string to be slightly
raymes
2017/05/16 06:19:51
Oh - I thought it would always be the same as befo
Charlie Harrison
2017/05/16 12:10:14
Followed up offline.
| |
100 | |
92 AddCheckItem(CONTENT_SETTING_ALLOW, label); | 101 AddCheckItem(CONTENT_SETTING_ALLOW, label); |
93 } | 102 } |
94 | 103 |
95 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the | 104 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the |
96 // same as any other permission with ASK, i.e. there is no ASK exception. | 105 // same as any other permission with ASK, i.e. there is no ASK exception. |
97 // Once the feature flag is gone, remove this block of code entirely. | 106 // Once the feature flag is gone, remove this block of code entirely. |
98 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && | 107 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && |
99 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { | 108 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { |
100 label = l10n_util::GetStringUTF16( | 109 label = l10n_util::GetStringUTF16( |
101 IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT); | 110 IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT); |
102 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); | 111 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); |
103 } | 112 } |
104 | 113 |
105 // Retrieve the string to show for blocking the permission. | 114 // Retrieve the string to show for blocking the permission. |
106 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK); | 115 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK); |
107 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 116 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
108 label = PageInfoUI::PermissionActionToUIString( | 117 label = PageInfoUI::PermissionActionToUIString( |
109 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, | 118 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, |
110 info.source); | 119 info.source); |
111 } | 120 } |
121 if (subresource_filter_permission) | |
122 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SUBRESOURCE_FILTER_BLOCK); | |
raymes
2017/05/15 23:41:21
I think we can move this up above the if (..) stat
Charlie Harrison
2017/05/16 01:47:26
You mean the IsSecondaryUiMaterial if statement? D
| |
112 AddCheckItem(CONTENT_SETTING_BLOCK, label); | 123 AddCheckItem(CONTENT_SETTING_BLOCK, label); |
113 } | 124 } |
114 | 125 |
115 PermissionMenuModel::PermissionMenuModel(Profile* profile, | 126 PermissionMenuModel::PermissionMenuModel(Profile* profile, |
116 const GURL& url, | 127 const GURL& url, |
117 ContentSetting setting, | 128 ContentSetting setting, |
118 const ChangeCallback& callback) | 129 const ChangeCallback& callback) |
119 : ui::SimpleMenuModel(this), | 130 : ui::SimpleMenuModel(this), |
120 host_content_settings_map_( | 131 host_content_settings_map_( |
121 HostContentSettingsMapFactory::GetForProfile(profile)), | 132 HostContentSettingsMapFactory::GetForProfile(profile)), |
(...skipping 22 matching lines...) Expand all Loading... | |
144 } | 155 } |
145 | 156 |
146 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 157 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
147 return true; | 158 return true; |
148 } | 159 } |
149 | 160 |
150 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 161 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
151 permission_.setting = static_cast<ContentSetting>(command_id); | 162 permission_.setting = static_cast<ContentSetting>(command_id); |
152 callback_.Run(permission_); | 163 callback_.Run(permission_); |
153 } | 164 } |
OLD | NEW |