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

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

Issue 10887027: (GTK only) Replace checkboxes with menus and add support for managed settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
6
7 #include "grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h"
9
10 namespace {
11
12 // An array with |ContentSetting|s ordered by CommandID. The array is used to
13 // lookup a content setting for a given command id.
14 const ContentSetting kSettingsForCommandIDs[] = {
15 CONTENT_SETTING_DEFAULT, // COMMAND_SET_TO_DEFAULT
16 CONTENT_SETTING_ALLOW, // COMMAND_SET_TO_ALLOW
17 CONTENT_SETTING_BLOCK, // COMMAND_SET_TO_BLOCK
18 };
19
20 }
21
22 PermissionMenuModel::PermissionMenuModel(
23 PermissionMenuDelegate* delegate,
24 ContentSettingsType type,
25 ContentSetting default_setting,
26 ContentSetting current_setting)
27 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
28 delegate_(delegate),
29 type_(type),
30 default_setting_(default_setting),
31 current_setting_(current_setting) {
32 string16 label;
33 switch (default_setting_) {
34 case CONTENT_SETTING_ALLOW:
35 label = l10n_util::GetStringUTF16(
36 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
37 break;
38 case CONTENT_SETTING_BLOCK:
39 label = l10n_util::GetStringUTF16(
40 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
41 break;
42 case CONTENT_SETTING_ASK:
43 label = l10n_util::GetStringUTF16(
44 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
45 break;
46 default:
47 break;
48 }
49 AddCheckItem(COMMAND_SET_TO_DEFAULT, label);
50
51 label = l10n_util::GetStringUTF16(
52 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
53 AddCheckItem(COMMAND_SET_TO_ALLOW, label);
54
55 if (type_ != CONTENT_SETTINGS_TYPE_FULLSCREEN) {
56 label = l10n_util::GetStringUTF16(
57 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
58 AddCheckItem(COMMAND_SET_TO_BLOCK, label);
59 }
60 }
61
62 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
63 return current_setting_ == kSettingsForCommandIDs[command_id];
64 }
65
66 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
67 return true;
68 }
69
70 bool PermissionMenuModel::GetAcceleratorForCommandId(
71 int command_id,
72 ui::Accelerator* accelerator) {
73 // Accelerators are not supported.
74 return false;
75 }
76
77 void PermissionMenuModel::ExecuteCommand(int command_id) {
78 current_setting_ = kSettingsForCommandIDs[command_id];
79 if (delegate_)
80 delegate_->OnPermissionSelected();
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698