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 // The subresource filter permission does not display the default menu item. |
| 74 if (permission_.type != CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) |
| 75 AddCheckItem(CONTENT_SETTING_DEFAULT, label); |
74 | 76 |
75 // Retrieve the string to show for allowing the permission. | 77 // Retrieve the string to show for allowing the permission. |
76 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. | 78 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. |
77 bool allow_disabled_for_notifications = | 79 bool allow_disabled_for_notifications = |
78 permission_.is_incognito && | 80 permission_.is_incognito && |
79 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 81 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
80 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. | 82 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. |
81 bool is_media_permission = | 83 bool is_media_permission = |
82 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 84 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
83 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 85 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
(...skipping 13 matching lines...) Expand all Loading... |
97 // Once the feature flag is gone, remove this block of code entirely. | 99 // Once the feature flag is gone, remove this block of code entirely. |
98 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && | 100 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && |
99 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { | 101 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { |
100 label = l10n_util::GetStringUTF16( | 102 label = l10n_util::GetStringUTF16( |
101 IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT); | 103 IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT); |
102 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); | 104 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); |
103 } | 105 } |
104 | 106 |
105 // Retrieve the string to show for blocking the permission. | 107 // Retrieve the string to show for blocking the permission. |
106 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK); | 108 label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK); |
| 109 if (permission_.type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) { |
| 110 label = l10n_util::GetStringUTF16( |
| 111 IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK); |
| 112 } |
107 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 113 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
108 label = PageInfoUI::PermissionActionToUIString( | 114 label = PageInfoUI::PermissionActionToUIString( |
109 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, | 115 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, |
110 info.source); | 116 info.source); |
111 } | 117 } |
112 AddCheckItem(CONTENT_SETTING_BLOCK, label); | 118 AddCheckItem(CONTENT_SETTING_BLOCK, label); |
113 } | 119 } |
114 | 120 |
115 PermissionMenuModel::PermissionMenuModel(Profile* profile, | 121 PermissionMenuModel::PermissionMenuModel(Profile* profile, |
116 const GURL& url, | 122 const GURL& url, |
(...skipping 27 matching lines...) Expand all Loading... |
144 } | 150 } |
145 | 151 |
146 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 152 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
147 return true; | 153 return true; |
148 } | 154 } |
149 | 155 |
150 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 156 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
151 permission_.setting = static_cast<ContentSetting>(command_id); | 157 permission_.setting = static_cast<ContentSetting>(command_id); |
152 callback_.Run(permission_); | 158 callback_.Run(permission_); |
153 } | 159 } |
OLD | NEW |