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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/website_settings/permission_menu_model.cc
diff --git a/chrome/browser/ui/website_settings/permission_menu_model.cc b/chrome/browser/ui/website_settings/permission_menu_model.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff2435c6c1b92d1584abbd7b4f1f919c5f6cf169
--- /dev/null
+++ b/chrome/browser/ui/website_settings/permission_menu_model.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/website_settings/permission_menu_model.h"
+
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+// An array with |ContentSetting|s ordered by CommandID. The array is used to
+// lookup a content setting for a given command id.
+const ContentSetting kSettingsForCommandIDs[] = {
+ CONTENT_SETTING_DEFAULT, // COMMAND_SET_TO_DEFAULT
+ CONTENT_SETTING_ALLOW, // COMMAND_SET_TO_ALLOW
+ CONTENT_SETTING_BLOCK, // COMMAND_SET_TO_BLOCK
+};
+
+}
+
+PermissionMenuModel::PermissionMenuModel(
+ PermissionMenuDelegate* delegate,
+ ContentSettingsType type,
+ ContentSetting default_setting,
+ ContentSetting current_setting)
+ : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
+ delegate_(delegate),
+ type_(type),
+ default_setting_(default_setting),
+ current_setting_(current_setting) {
+ string16 label;
+ switch (default_setting_) {
+ case CONTENT_SETTING_ALLOW:
+ label = l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
+ break;
+ case CONTENT_SETTING_BLOCK:
+ label = l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
+ break;
+ case CONTENT_SETTING_ASK:
+ label = l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
+ break;
+ default:
+ break;
+ }
+ AddCheckItem(COMMAND_SET_TO_DEFAULT, label);
+
+ label = l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
+ AddCheckItem(COMMAND_SET_TO_ALLOW, label);
+
+ if (type_ != CONTENT_SETTINGS_TYPE_FULLSCREEN) {
+ label = l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
+ AddCheckItem(COMMAND_SET_TO_BLOCK, label);
+ }
+}
+
+bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
+ return current_setting_ == kSettingsForCommandIDs[command_id];
+}
+
+bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
+ return true;
+}
+
+bool PermissionMenuModel::GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) {
+ // Accelerators are not supported.
+ return false;
+}
+
+void PermissionMenuModel::ExecuteCommand(int command_id) {
+ current_setting_ = kSettingsForCommandIDs[command_id];
+ if (delegate_)
+ delegate_->OnPermissionSelected();
+}

Powered by Google App Engine
This is Rietveld 408576698