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

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

Issue 1575623002: Disable Web Notifications in Incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permfix
Patch Set: No Profile* in WebsiteSettingsPopupView Created 4 years, 11 months 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/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "components/content_settings/core/browser/plugins_field_trial.h" 8 #include "components/content_settings/core/browser/plugins_field_trial.h"
9 #include "content/public/common/origin_util.h" 9 #include "content/public/common/origin_util.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for 52 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for
53 // fullscreen or mouse lock on file:// URLs, because there wouldn't be 53 // fullscreen or mouse lock on file:// URLs, because there wouldn't be
54 // a reasonable origin with which to associate the preference. 54 // a reasonable origin with which to associate the preference.
55 // TODO(estark): Revisit this when crbug.com/455882 is fixed. 55 // TODO(estark): Revisit this when crbug.com/455882 is fixed.
56 bool is_exclusive_access_on_file = 56 bool is_exclusive_access_on_file =
57 (permission_.type == CONTENT_SETTINGS_TYPE_FULLSCREEN || 57 (permission_.type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
58 permission_.type == CONTENT_SETTINGS_TYPE_MOUSELOCK) && 58 permission_.type == CONTENT_SETTINGS_TYPE_MOUSELOCK) &&
59 url.SchemeIsFile(); 59 url.SchemeIsFile();
60 60
61 // Notifications does not support CONTENT_SETTING_ALLOW in incognito.
62 bool allow_disabled_for_notifications =
63 permission_.is_incognito &&
64 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
61 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. 65 // Media only supports CONTENT_SETTTING_ALLOW for secure origins.
62 bool is_media_permission = 66 bool is_media_permission =
63 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 67 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
64 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; 68 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
65 if ((!is_media_permission || content::IsOriginSecure(url)) && 69 if (!allow_disabled_for_notifications &&
70 (!is_media_permission || content::IsOriginSecure(url)) &&
66 !is_exclusive_access_on_file) { 71 !is_exclusive_access_on_file) {
67 label = l10n_util::GetStringUTF16( 72 label = l10n_util::GetStringUTF16(
68 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); 73 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
69 AddCheckItem(CONTENT_SETTING_ALLOW, label); 74 AddCheckItem(CONTENT_SETTING_ALLOW, label);
70 } 75 }
71 76
72 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) { 77 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) {
73 label = l10n_util::GetStringUTF16( 78 label = l10n_util::GetStringUTF16(
74 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); 79 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT);
75 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); 80 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 int command_id, 123 int command_id,
119 ui::Accelerator* accelerator) { 124 ui::Accelerator* accelerator) {
120 // Accelerators are not supported. 125 // Accelerators are not supported.
121 return false; 126 return false;
122 } 127 }
123 128
124 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 129 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
125 permission_.setting = static_cast<ContentSetting>(command_id); 130 permission_.setting = static_cast<ContentSetting>(command_id);
126 callback_.Run(permission_); 131 callback_.Run(permission_);
127 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698