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 "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
9 | 9 |
10 PermissionMenuModel::PermissionMenuModel( | 10 PermissionMenuModel::PermissionMenuModel( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 PermissionMenuModel::PermissionMenuModel(const GURL& url, | 52 PermissionMenuModel::PermissionMenuModel(const GURL& url, |
53 ContentSetting setting, | 53 ContentSetting setting, |
54 const ChangeCallback& callback) | 54 const ChangeCallback& callback) |
55 : ui::SimpleMenuModel(this), callback_(callback) { | 55 : ui::SimpleMenuModel(this), callback_(callback) { |
56 DCHECK(setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_BLOCK); | 56 DCHECK(setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_BLOCK); |
57 permission_.type = CONTENT_SETTINGS_TYPE_DEFAULT; | 57 permission_.type = CONTENT_SETTINGS_TYPE_DEFAULT; |
58 permission_.setting = setting; | 58 permission_.setting = setting; |
59 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; | 59 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; |
60 AddCheckItem(CONTENT_SETTING_ALLOW, | 60 AddCheckItem(CONTENT_SETTING_ALLOW, |
61 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW)); | 61 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); |
62 AddCheckItem(CONTENT_SETTING_BLOCK, | 62 AddCheckItem(CONTENT_SETTING_BLOCK, |
63 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK)); | 63 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); |
64 } | 64 } |
65 | 65 |
66 PermissionMenuModel::~PermissionMenuModel() {} | 66 PermissionMenuModel::~PermissionMenuModel() {} |
67 | 67 |
68 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { | 68 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { |
69 return permission_.setting == command_id; | 69 return permission_.setting == command_id; |
70 } | 70 } |
71 | 71 |
72 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 72 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 bool PermissionMenuModel::GetAcceleratorForCommandId( | 76 bool PermissionMenuModel::GetAcceleratorForCommandId( |
77 int command_id, | 77 int command_id, |
78 ui::Accelerator* accelerator) { | 78 ui::Accelerator* accelerator) { |
79 // Accelerators are not supported. | 79 // Accelerators are not supported. |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 83 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
84 permission_.setting = static_cast<ContentSetting>(command_id); | 84 permission_.setting = static_cast<ContentSetting>(command_id); |
85 callback_.Run(permission_); | 85 callback_.Run(permission_); |
86 } | 86 } |
OLD | NEW |