Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / permission_menu_model.cc
blobe013f102877d5ee17178356c7a4d8ce27c45fd52
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(
11 Delegate* delegate,
12 const GURL& url,
13 ContentSettingsType type,
14 ContentSetting default_setting,
15 ContentSetting current_setting)
16 : ui::SimpleMenuModel(this),
17 delegate_(delegate),
18 site_url_(url) {
19 base::string16 label;
20 switch (default_setting) {
21 case CONTENT_SETTING_ALLOW:
22 label = l10n_util::GetStringUTF16(
23 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
24 break;
25 case CONTENT_SETTING_BLOCK:
26 label = l10n_util::GetStringUTF16(
27 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
28 break;
29 case CONTENT_SETTING_ASK:
30 label = l10n_util::GetStringUTF16(
31 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
32 break;
33 default:
34 break;
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 {
53 if (delegate_)
54 return delegate_->IsCommandIdChecked(command_id);
55 return false;
58 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
59 return true;
62 bool PermissionMenuModel::GetAcceleratorForCommandId(
63 int command_id,
64 ui::Accelerator* accelerator) {
65 // Accelerators are not supported.
66 return false;
69 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
70 if (delegate_)
71 delegate_->ExecuteCommand(command_id);