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/website_settings/permission_menu_model.h" | 5 #include "chrome/browser/ui/website_settings/permission_menu_model.h" |
6 | 6 |
7 #include "chrome/browser/plugins/plugins_field_trial.h" | 7 #include "chrome/browser/plugins/plugins_field_trial.h" |
8 #include "chrome/common/chrome_features.h" | |
8 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
9 #include "content/public/common/origin_util.h" | 10 #include "content/public/common/origin_util.h" |
10 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
11 | 12 |
12 PermissionMenuModel::PermissionMenuModel( | 13 PermissionMenuModel::PermissionMenuModel( |
13 const GURL& url, | 14 const GURL& url, |
14 const WebsiteSettingsUI::PermissionInfo& info, | 15 const WebsiteSettingsUI::PermissionInfo& info, |
15 const ChangeCallback& callback) | 16 const ChangeCallback& callback) |
16 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { | 17 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { |
17 DCHECK(!callback_.is_null()); | 18 DCHECK(!callback_.is_null()); |
(...skipping 13 matching lines...) Expand all Loading... | |
31 break; | 32 break; |
32 case CONTENT_SETTING_BLOCK: | 33 case CONTENT_SETTING_BLOCK: |
33 label = l10n_util::GetStringUTF16( | 34 label = l10n_util::GetStringUTF16( |
34 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); | 35 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); |
35 break; | 36 break; |
36 case CONTENT_SETTING_ASK: | 37 case CONTENT_SETTING_ASK: |
37 label = | 38 label = |
38 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK); | 39 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK); |
39 break; | 40 break; |
40 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: | 41 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: |
42 // TODO(tommycli): Once HTML5 by Default is shipped and the feature flag | |
43 // is removed, just migrate the actual content setting to ASK. | |
41 label = l10n_util::GetStringUTF16( | 44 label = l10n_util::GetStringUTF16( |
42 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT); | 45 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins) |
raymes
2016/09/15 02:54:53
nit: Please add a comment explaining why we displa
tommycli
2016/09/15 16:40:45
Done.
| |
46 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK | |
47 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT) ; | |
43 break; | 48 break; |
44 case CONTENT_SETTING_NUM_SETTINGS: | 49 case CONTENT_SETTING_NUM_SETTINGS: |
45 NOTREACHED(); | 50 NOTREACHED(); |
46 default: | 51 default: |
47 break; | 52 break; |
48 } | 53 } |
49 AddCheckItem(CONTENT_SETTING_DEFAULT, label); | 54 AddCheckItem(CONTENT_SETTING_DEFAULT, label); |
50 | 55 |
51 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for | 56 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for |
52 // fullscreen or mouse lock on file:// URLs, because there wouldn't be | 57 // fullscreen or mouse lock on file:// URLs, because there wouldn't be |
(...skipping 13 matching lines...) Expand all Loading... | |
66 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 71 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
67 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 72 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
68 if (!allow_disabled_for_notifications && | 73 if (!allow_disabled_for_notifications && |
69 (!is_media_permission || content::IsOriginSecure(url)) && | 74 (!is_media_permission || content::IsOriginSecure(url)) && |
70 !is_exclusive_access_on_file) { | 75 !is_exclusive_access_on_file) { |
71 label = l10n_util::GetStringUTF16( | 76 label = l10n_util::GetStringUTF16( |
72 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); | 77 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); |
73 AddCheckItem(CONTENT_SETTING_ALLOW, label); | 78 AddCheckItem(CONTENT_SETTING_ALLOW, label); |
74 } | 79 } |
75 | 80 |
76 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 81 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && |
82 !base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { | |
raymes
2016/09/15 02:54:53
nit: Please add a comment here explaining why we d
tommycli
2016/09/15 16:40:45
Done.
| |
77 label = l10n_util::GetStringUTF16( | 83 label = l10n_util::GetStringUTF16( |
78 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); | 84 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); |
79 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); | 85 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); |
80 } | 86 } |
81 | 87 |
82 if (permission_.type != CONTENT_SETTINGS_TYPE_FULLSCREEN && | 88 if (permission_.type != CONTENT_SETTINGS_TYPE_FULLSCREEN && |
83 !is_exclusive_access_on_file) { | 89 !is_exclusive_access_on_file) { |
84 label = l10n_util::GetStringUTF16( | 90 label = l10n_util::GetStringUTF16( |
85 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK); | 91 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK); |
86 AddCheckItem(CONTENT_SETTING_BLOCK, label); | 92 AddCheckItem(CONTENT_SETTING_BLOCK, label); |
(...skipping 28 matching lines...) Expand all Loading... | |
115 } | 121 } |
116 | 122 |
117 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 123 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
118 return true; | 124 return true; |
119 } | 125 } |
120 | 126 |
121 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 127 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
122 permission_.setting = static_cast<ContentSetting>(command_id); | 128 permission_.setting = static_cast<ContentSetting>(command_id); |
123 callback_.Run(permission_); | 129 callback_.Run(permission_); |
124 } | 130 } |
OLD | NEW |