summaryrefslogtreecommitdiffstats
path: root/chrome/browser/encoding_menu_controller.h
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 17:10:41 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 17:10:41 +0000
commitf14159cb6385f271bec21d4ddf04c353a869fb70 (patch)
tree2fc1ab6633333d1a7292f5e9acd21a8bd7d833b6 /chrome/browser/encoding_menu_controller.h
parentd680c5c189ec40b97cee8c201de88dfe5256153f (diff)
downloadchromium_src-f14159cb6385f271bec21d4ddf04c353a869fb70.zip
chromium_src-f14159cb6385f271bec21d4ddf04c353a869fb70.tar.gz
chromium_src-f14159cb6385f271bec21d4ddf04c353a869fb70.tar.bz2
Implement OS X Encoding Menu.
Also refactor Windows Encoding menu a bit to make the moving parts x-platform. Add a unit test for the menu encoding logic. In a followup CL I'll add some UI tests around this. Review URL: http://codereview.chromium.org/113315 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/encoding_menu_controller.h')
-rw-r--r--chrome/browser/encoding_menu_controller.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/encoding_menu_controller.h b/chrome/browser/encoding_menu_controller.h
new file mode 100644
index 0000000..9134b54
--- /dev/null
+++ b/chrome/browser/encoding_menu_controller.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_
+#define CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_
+
+#include <vector>
+
+#include "base/basictypes.h" // For DISALLOW_IMPLICIT_CONSTRUCTORS
+#include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST
+
+class Browser;
+class Profile;
+
+// Cross-platform logic needed for the encoding menu.
+// For now, we don't need to track state so all methods are static.
+class EncodingMenuController {
+ FRIEND_TEST(EncodingMenuControllerTest, EncodingIDsBelongTest);
+ FRIEND_TEST(EncodingMenuControllerTest, IsItemChecked);
+
+ public:
+ typedef std::pair<int, std::wstring> EncodingMenuItem;
+ typedef std::vector<EncodingMenuItem> EncodingMenuItemList;
+
+ public:
+ EncodingMenuController() {}
+
+ // Given a command ID, does this command belong to the encoding menu?
+ bool DoesCommandBelongToEncodingMenu(int id);
+
+ // Returns true if the given encoding menu item (specified by item_id)
+ // is checked. Note that this header is included from objc, where the name
+ // "id" is reserved.
+ bool IsItemChecked(Profile* browser_profile,
+ const std::wstring& current_tab_encoding,
+ int item_id);
+
+ // Fills in a list of menu items in the order they should appear in the menu.
+ // Items whose ids are 0 are separators.
+ void GetEncodingMenuItems(Profile* profile,
+ EncodingMenuItemList* menuItems);
+
+ private:
+ // List of all valid encoding GUI IDs.
+ static const int kValidEncodingIds[];
+ const int* ValidGUIEncodingIDs();
+ int NumValidGUIEncodingIDs();
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EncodingMenuController);
+};
+
+#endif // CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_