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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
7 #include "grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h"
10 PermissionMenuModel::PermissionMenuModel(
13 ContentSettingsType type
,
14 ContentSetting default_setting
,
15 ContentSetting current_setting
)
16 : ui::SimpleMenuModel(this),
20 switch (default_setting
) {
21 case CONTENT_SETTING_ALLOW
:
22 label
= l10n_util::GetStringUTF16(
23 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW
);
25 case CONTENT_SETTING_BLOCK
:
26 label
= l10n_util::GetStringUTF16(
27 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK
);
29 case CONTENT_SETTING_ASK
:
30 label
= l10n_util::GetStringUTF16(
31 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK
);
36 AddCheckItem(COMMAND_SET_TO_DEFAULT
, label
);
38 // Media only support COMMAND_SET_TO_ALLOW for https.
39 if (type
!= CONTENT_SETTINGS_TYPE_MEDIASTREAM
||
40 url
.SchemeIsSecure()) {
41 label
= l10n_util::GetStringUTF16(
42 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW
);
43 AddCheckItem(COMMAND_SET_TO_ALLOW
, label
);
45 if (type
!= CONTENT_SETTINGS_TYPE_FULLSCREEN
) {
46 label
= l10n_util::GetStringUTF16(
47 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK
);
48 AddCheckItem(COMMAND_SET_TO_BLOCK
, label
);
52 bool PermissionMenuModel::IsCommandIdChecked(int command_id
) const {
54 return delegate_
->IsCommandIdChecked(command_id
);
58 bool PermissionMenuModel::IsCommandIdEnabled(int command_id
) const {
62 bool PermissionMenuModel::GetAcceleratorForCommandId(
64 ui::Accelerator
* accelerator
) {
65 // Accelerators are not supported.
69 void PermissionMenuModel::ExecuteCommand(int command_id
, int event_flags
) {
71 delegate_
->ExecuteCommand(command_id
);