summaryrefslogtreecommitdiffstats
path: root/chrome/browser/wrench_menu_model.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 01:56:52 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 01:56:52 +0000
commitbdb7ff6f3d14ea2c252f1946ea200326acc047e9 (patch)
tree793c5fb7947554416bf9342cc6c728715add31d2 /chrome/browser/wrench_menu_model.cc
parentcf5804412f3a525a35a7549bb557bc20d3243499 (diff)
downloadchromium_src-bdb7ff6f3d14ea2c252f1946ea200326acc047e9.zip
chromium_src-bdb7ff6f3d14ea2c252f1946ea200326acc047e9.tar.gz
chromium_src-bdb7ff6f3d14ea2c252f1946ea200326acc047e9.tar.bz2
Remove the page and app menus.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3033007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/wrench_menu_model.cc')
-rw-r--r--chrome/browser/wrench_menu_model.cc111
1 files changed, 82 insertions, 29 deletions
diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc
index 26fd4be..1dd1414 100644
--- a/chrome/browser/wrench_menu_model.cc
+++ b/chrome/browser/wrench_menu_model.cc
@@ -10,19 +10,17 @@
#include "app/l10n_util.h"
#include "app/menus/button_menu_item_model.h"
#include "app/resource_bundle.h"
-#include "base/command_line.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h"
-#include "chrome/browser/page_menu_model.h"
+#include "chrome/browser/encoding_menu_controller.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/upgrade_detector.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
@@ -31,6 +29,86 @@
#include "grit/theme_resources.h"
////////////////////////////////////////////////////////////////////////////////
+// EncodingMenuModel
+
+EncodingMenuModel::EncodingMenuModel(Browser* browser)
+ : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)),
+ browser_(browser) {
+ Build();
+}
+
+void EncodingMenuModel::Build() {
+ EncodingMenuController::EncodingMenuItemList encoding_menu_items;
+ EncodingMenuController encoding_menu_controller;
+ encoding_menu_controller.GetEncodingMenuItems(browser_->profile(),
+ &encoding_menu_items);
+
+ int group_id = 0;
+ EncodingMenuController::EncodingMenuItemList::iterator it =
+ encoding_menu_items.begin();
+ for (; it != encoding_menu_items.end(); ++it) {
+ int id = it->first;
+ string16& label = it->second;
+ if (id == 0) {
+ AddSeparator();
+ } else {
+ if (id == IDC_ENCODING_AUTO_DETECT) {
+ AddCheckItem(id, label);
+ } else {
+ // Use the id of the first radio command as the id of the group.
+ if (group_id <= 0)
+ group_id = id;
+ AddRadioItem(id, label, group_id);
+ }
+ }
+ }
+}
+
+bool EncodingMenuModel::IsCommandIdChecked(int command_id) const {
+ TabContents* current_tab = browser_->GetSelectedTabContents();
+ if (!current_tab)
+ return false;
+ EncodingMenuController controller;
+ return controller.IsItemChecked(browser_->profile(),
+ current_tab->encoding(), command_id);
+}
+
+bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const {
+ bool enabled = browser_->command_updater()->IsCommandEnabled(command_id);
+ // Special handling for the contents of the Encoding submenu. On Mac OS,
+ // instead of enabling/disabling the top-level menu item, the submenu's
+ // contents get disabled, per Apple's HIG.
+#if defined(OS_MACOSX)
+ enabled &= browser_->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU);
+#endif
+ return enabled;
+}
+
+bool EncodingMenuModel::GetAcceleratorForCommandId(
+ int command_id,
+ menus::Accelerator* accelerator) {
+ return false;
+}
+
+void EncodingMenuModel::ExecuteCommand(int command_id) {
+ browser_->ExecuteCommand(command_id);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ZoomMenuModel
+
+ZoomMenuModel::ZoomMenuModel(menus::SimpleMenuModel::Delegate* delegate)
+ : SimpleMenuModel(delegate) {
+ Build();
+}
+
+void ZoomMenuModel::Build() {
+ AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
+ AddItemWithStringId(IDC_ZOOM_NORMAL, IDS_ZOOM_NORMAL);
+ AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// ToolsMenuModel
ToolsMenuModel::ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate,
@@ -96,31 +174,6 @@ WrenchMenuModel::~WrenchMenuModel() {
tabstrip_model_->RemoveObserver(this);
}
-static bool CalculateEnabled() {
- CommandLine* cl = CommandLine::ForCurrentProcess();
- if (cl->HasSwitch(switches::kNewWrenchMenu)) {
- // Honor the switch if present.
- std::string value = cl->GetSwitchValueASCII(switches::kNewWrenchMenu);
- return value.empty() || value == "true";
- }
-#if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK)
- return true;
-#else
- return false;
-#endif
-}
-
-// static
-bool WrenchMenuModel::IsEnabled() {
- static bool checked = false;
- static bool enabled = false;
- if (!checked) {
- checked = true;
- enabled = CalculateEnabled();
- }
- return enabled;
-}
-
bool WrenchMenuModel::IsLabelDynamicAt(int index) const {
return IsDynamicItem(index) || SimpleMenuModel::IsLabelDynamicAt(index);
}