diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 17:50:53 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 17:50:53 +0000 |
commit | 2bcec61a43b8b7ed7b9b0e96b68f5ed42110081a (patch) | |
tree | 957d756c489075bd18a8e09e5ee38c8a8e769ab8 /chrome/browser/encoding_menu_controller.h | |
parent | d0bc15b44084f5860456ef9beac1f64bcfaf0eaf (diff) | |
download | chromium_src-2bcec61a43b8b7ed7b9b0e96b68f5ed42110081a.zip chromium_src-2bcec61a43b8b7ed7b9b0e96b68f5ed42110081a.tar.gz chromium_src-2bcec61a43b8b7ed7b9b0e96b68f5ed42110081a.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@16072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/encoding_menu_controller.h')
-rw-r--r-- | chrome/browser/encoding_menu_controller.h | 53 |
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_ |