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

Side by Side Diff: chrome/browser/ui/website_settings/permission_menu_model.cc

Issue 2419413002: Deleted CONTENT_SETTINGS_TYPE_FULLSCREEN and MOUSELOCK. (Closed)
Patch Set: Fix more things. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK 55 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK
56 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT) ; 56 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT) ;
57 break; 57 break;
58 case CONTENT_SETTING_NUM_SETTINGS: 58 case CONTENT_SETTING_NUM_SETTINGS:
59 NOTREACHED(); 59 NOTREACHED();
60 default: 60 default:
61 break; 61 break;
62 } 62 }
63 AddCheckItem(CONTENT_SETTING_DEFAULT, label); 63 AddCheckItem(CONTENT_SETTING_DEFAULT, label);
64 64
65 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for
66 // fullscreen or mouse lock on file:// URLs, because there wouldn't be
67 // a reasonable origin with which to associate the preference.
68 // TODO(estark): Revisit this when crbug.com/455882 is fixed.
69 bool is_exclusive_access_on_file =
70 (permission_.type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
71 permission_.type == CONTENT_SETTINGS_TYPE_MOUSELOCK) &&
72 url.SchemeIsFile();
73
74 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. 65 // Notifications does not support CONTENT_SETTING_ALLOW in incognito.
75 bool allow_disabled_for_notifications = 66 bool allow_disabled_for_notifications =
76 permission_.is_incognito && 67 permission_.is_incognito &&
77 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 68 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
78 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. 69 // Media only supports CONTENT_SETTTING_ALLOW for secure origins.
79 bool is_media_permission = 70 bool is_media_permission =
80 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 71 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
81 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; 72 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
82 if (!allow_disabled_for_notifications && 73 if (!allow_disabled_for_notifications &&
83 (!is_media_permission || content::IsOriginSecure(url)) && 74 (!is_media_permission || content::IsOriginSecure(url))) {
84 !is_exclusive_access_on_file) {
85 label = l10n_util::GetStringUTF16( 75 label = l10n_util::GetStringUTF16(
86 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); 76 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
87 AddCheckItem(CONTENT_SETTING_ALLOW, label); 77 AddCheckItem(CONTENT_SETTING_ALLOW, label);
88 } 78 }
89 79
90 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the 80 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the
91 // same as any other permission with ASK, i.e. there is no ASK exception. 81 // same as any other permission with ASK, i.e. there is no ASK exception.
92 // Once the feature flag is gone, remove this block of code entirely. 82 // Once the feature flag is gone, remove this block of code entirely.
93 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && 83 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
94 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { 84 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) {
95 label = l10n_util::GetStringUTF16( 85 label = l10n_util::GetStringUTF16(
96 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); 86 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT);
97 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); 87 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label);
98 } 88 }
99 89
100 if (permission_.type != CONTENT_SETTINGS_TYPE_FULLSCREEN && 90 label = l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
101 !is_exclusive_access_on_file) { 91 AddCheckItem(CONTENT_SETTING_BLOCK, label);
102 label = l10n_util::GetStringUTF16(
103 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
104 AddCheckItem(CONTENT_SETTING_BLOCK, label);
105 }
106 } 92 }
107 93
108 PermissionMenuModel::PermissionMenuModel(Profile* profile, 94 PermissionMenuModel::PermissionMenuModel(Profile* profile,
109 const GURL& url, 95 const GURL& url,
110 ContentSetting setting, 96 ContentSetting setting,
111 const ChangeCallback& callback) 97 const ChangeCallback& callback)
112 : ui::SimpleMenuModel(this), 98 : ui::SimpleMenuModel(this),
113 host_content_settings_map_( 99 host_content_settings_map_(
114 HostContentSettingsMapFactory::GetForProfile(profile)), 100 HostContentSettingsMapFactory::GetForProfile(profile)),
115 callback_(callback) { 101 callback_(callback) {
(...skipping 21 matching lines...) Expand all
137 } 123 }
138 124
139 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 125 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
140 return true; 126 return true;
141 } 127 }
142 128
143 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 129 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
144 permission_.setting = static_cast<ContentSetting>(command_id); 130 permission_.setting = static_cast<ContentSetting>(command_id);
145 callback_.Run(permission_); 131 callback_.Run(permission_);
146 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698