| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_ENCODING_MENU_CONTROLLER_H_ |
| 6 #define CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_ | 6 #define CHROME_BROWSER_ENCODING_MENU_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <utility> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" // For DISALLOW_IMPLICIT_CONSTRUCTORS | 12 #include "base/basictypes.h" // For DISALLOW_COPY_AND_ASSIGN |
| 13 #include "base/string16.h" |
| 12 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST | 14 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST |
| 13 | 15 |
| 14 class Browser; | 16 class Browser; |
| 15 class Profile; | 17 class Profile; |
| 16 | 18 |
| 17 // Cross-platform logic needed for the encoding menu. | 19 // Cross-platform logic needed for the encoding menu. |
| 18 // For now, we don't need to track state so all methods are static. | 20 // For now, we don't need to track state so all methods are static. |
| 19 class EncodingMenuController { | 21 class EncodingMenuController { |
| 20 FRIEND_TEST(EncodingMenuControllerTest, EncodingIDsBelongTest); | 22 FRIEND_TEST(EncodingMenuControllerTest, EncodingIDsBelongTest); |
| 21 FRIEND_TEST(EncodingMenuControllerTest, IsItemChecked); | 23 FRIEND_TEST(EncodingMenuControllerTest, IsItemChecked); |
| 22 | 24 |
| 23 public: | 25 public: |
| 24 typedef std::pair<int, std::wstring> EncodingMenuItem; | 26 typedef std::pair<int, string16> EncodingMenuItem; |
| 25 typedef std::vector<EncodingMenuItem> EncodingMenuItemList; | 27 typedef std::vector<EncodingMenuItem> EncodingMenuItemList; |
| 26 | 28 |
| 27 public: | 29 public: |
| 28 EncodingMenuController() {} | 30 EncodingMenuController() {} |
| 29 | 31 |
| 30 // Given a command ID, does this command belong to the encoding menu? | 32 // Given a command ID, does this command belong to the encoding menu? |
| 31 bool DoesCommandBelongToEncodingMenu(int id); | 33 bool DoesCommandBelongToEncodingMenu(int id); |
| 32 | 34 |
| 33 // Returns true if the given encoding menu item (specified by item_id) | 35 // Returns true if the given encoding menu item (specified by item_id) |
| 34 // is checked. Note that this header is included from objc, where the name | 36 // is checked. Note that this header is included from objc, where the name |
| 35 // "id" is reserved. | 37 // "id" is reserved. |
| 36 bool IsItemChecked(Profile* browser_profile, | 38 bool IsItemChecked(Profile* browser_profile, |
| 37 const std::wstring& current_tab_encoding, | 39 const std::string& current_tab_encoding, |
| 38 int item_id); | 40 int item_id); |
| 39 | 41 |
| 40 // Fills in a list of menu items in the order they should appear in the menu. | 42 // Fills in a list of menu items in the order they should appear in the menu. |
| 41 // Items whose ids are 0 are separators. | 43 // Items whose ids are 0 are separators. |
| 42 void GetEncodingMenuItems(Profile* profile, | 44 void GetEncodingMenuItems(Profile* profile, |
| 43 EncodingMenuItemList* menuItems); | 45 EncodingMenuItemList* menuItems); |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 // List of all valid encoding GUI IDs. | 48 // List of all valid encoding GUI IDs. |
| 47 static const int kValidEncodingIds[]; | 49 static const int kValidEncodingIds[]; |
| 48 const int* ValidGUIEncodingIDs(); | 50 const int* ValidGUIEncodingIDs(); |
| 49 int NumValidGUIEncodingIDs(); | 51 int NumValidGUIEncodingIDs(); |
| 50 private: | 52 |
| 51 DISALLOW_COPY_AND_ASSIGN(EncodingMenuController); | 53 DISALLOW_COPY_AND_ASSIGN(EncodingMenuController); |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 #endif // CHORME_BROWSER_ENCODING_MENU_CONTROLLER_H_ | 56 #endif // CHROME_BROWSER_ENCODING_MENU_CONTROLLER_H_ |
| OLD | NEW |