Chromium Code Reviews| 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/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 "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| 10 | 11 |
| 11 PermissionMenuModel::PermissionMenuModel( | 12 PermissionMenuModel::PermissionMenuModel( |
| 12 const GURL& url, | 13 const GURL& url, |
| 13 const WebsiteSettingsUI::PermissionInfo& info, | 14 const WebsiteSettingsUI::PermissionInfo& info, |
| 14 const ChangeCallback& callback) | 15 const ChangeCallback& callback) |
| 15 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { | 16 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { |
| 16 DCHECK(!callback_.is_null()); | 17 DCHECK(!callback_.is_null()); |
| 17 base::string16 label; | 18 base::string16 label; |
| 18 | 19 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 | 51 |
| 51 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for | 52 // CONTENT_SETTING_ALLOW and CONTENT_SETTING_BLOCK are not allowed for |
| 52 // 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 |
| 53 // a reasonable origin with which to associate the preference. | 54 // a reasonable origin with which to associate the preference. |
| 54 // TODO(estark): Revisit this when crbug.com/455882 is fixed. | 55 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
| 55 bool is_exclusive_access_on_file = | 56 bool is_exclusive_access_on_file = |
| 56 (permission_.type == CONTENT_SETTINGS_TYPE_FULLSCREEN || | 57 (permission_.type == CONTENT_SETTINGS_TYPE_FULLSCREEN || |
| 57 permission_.type == CONTENT_SETTINGS_TYPE_MOUSELOCK) && | 58 permission_.type == CONTENT_SETTINGS_TYPE_MOUSELOCK) && |
| 58 url.SchemeIsFile(); | 59 url.SchemeIsFile(); |
| 59 | 60 |
| 60 // Media only support CONTENT_SETTTING_ALLOW for https. | 61 // Media only support CONTENT_SETTTING_ALLOW for https. |
|
felt
2015/05/09 15:14:27
pls update the comment too
lgarron
2015/05/12 01:53:08
Done.
| |
| 61 if ((permission_.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM || | 62 if ((permission_.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM || |
| 62 url.SchemeIsSecure()) && | 63 IsOriginSecure(url)) && |
| 63 !is_exclusive_access_on_file) { | 64 !is_exclusive_access_on_file) { |
| 64 label = l10n_util::GetStringUTF16( | 65 label = l10n_util::GetStringUTF16( |
| 65 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); | 66 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); |
| 66 AddCheckItem(CONTENT_SETTING_ALLOW, label); | 67 AddCheckItem(CONTENT_SETTING_ALLOW, label); |
| 67 } | 68 } |
| 68 | 69 |
| 69 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 70 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 70 label = l10n_util::GetStringUTF16( | 71 label = l10n_util::GetStringUTF16( |
| 71 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); | 72 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); |
| 72 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); | 73 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 int command_id, | 116 int command_id, |
| 116 ui::Accelerator* accelerator) { | 117 ui::Accelerator* accelerator) { |
| 117 // Accelerators are not supported. | 118 // Accelerators are not supported. |
| 118 return false; | 119 return false; |
| 119 } | 120 } |
| 120 | 121 |
| 121 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 122 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
| 122 permission_.setting = static_cast<ContentSetting>(command_id); | 123 permission_.setting = static_cast<ContentSetting>(command_id); |
| 123 callback_.Run(permission_); | 124 callback_.Run(permission_); |
| 124 } | 125 } |
| OLD | NEW |