| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "webkit/tools/test_shell/test_shell.h" | 5 #include "webkit/tools/test_shell/test_shell.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <fontconfig/fontconfig.h> | 9 #include <fontconfig/fontconfig.h> |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "webkit/glue/resource_loader_bridge.h" | 24 #include "webkit/glue/resource_loader_bridge.h" |
| 25 #include "webkit/glue/webdatasource.h" | 25 #include "webkit/glue/webdatasource.h" |
| 26 #include "webkit/glue/webframe.h" | 26 #include "webkit/glue/webframe.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 28 #include "webkit/glue/webpreferences.h" | 28 #include "webkit/glue/webpreferences.h" |
| 29 #include "webkit/glue/webview.h" | 29 #include "webkit/glue/webview.h" |
| 30 #include "webkit/tools/test_shell/test_navigation_controller.h" | 30 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 31 #include "webkit/tools/test_shell/test_webview_delegate.h" | 31 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 32 | 32 |
| 33 // Generated by GRIT | 33 // Generated by GRIT |
| 34 #include "test_shell_resources.h" |
| 34 #include "webkit_resources.h" | 35 #include "webkit_resources.h" |
| 35 #include "test_shell_resources.h" | |
| 36 // TODO(deanm): Needed for the localized string shim. | |
| 37 #include "webkit_strings.h" | |
| 38 | 36 |
| 39 namespace { | 37 namespace { |
| 40 | 38 |
| 41 // Convert a FilePath into an FcChar* (used by fontconfig). | 39 // Convert a FilePath into an FcChar* (used by fontconfig). |
| 42 // The pointer only lives for the duration for the expression. | 40 // The pointer only lives for the duration for the expression. |
| 43 const FcChar8* FilePathAsFcChar(const FilePath& path) { | 41 const FcChar8* FilePathAsFcChar(const FilePath& path) { |
| 44 return reinterpret_cast<const FcChar8*>(path.value().c_str()); | 42 return reinterpret_cast<const FcChar8*>(path.value().c_str()); |
| 45 } | 43 } |
| 46 | 44 |
| 47 // Data resources on linux. This is a pointer to the mmapped resources file. | 45 // Data resources on linux. This is a pointer to the mmapped resources file. |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 StringPiece TestShell::NetResourceProvider(int key) { | 669 StringPiece TestShell::NetResourceProvider(int key) { |
| 672 StringPiece res; | 670 StringPiece res; |
| 673 g_resource_data_pack->Get(key, &res); | 671 g_resource_data_pack->Get(key, &res); |
| 674 return res; | 672 return res; |
| 675 } | 673 } |
| 676 | 674 |
| 677 //----------------------------------------------------------------------------- | 675 //----------------------------------------------------------------------------- |
| 678 | 676 |
| 679 namespace webkit_glue { | 677 namespace webkit_glue { |
| 680 | 678 |
| 681 // TODO(deanm): This is just a shim for now. We need to extend GRIT to do | |
| 682 // proper resources on Linux, and figure out exactly how we'll do localization. | |
| 683 // For now this is just a copy of webkit_strings_en-US.rc in switch form. | |
| 684 std::wstring GetLocalizedString(int message_id) { | 679 std::wstring GetLocalizedString(int message_id) { |
| 685 const char* str = NULL; | 680 StringPiece res; |
| 686 | 681 if (!g_resource_data_pack->Get(message_id, &res)) { |
| 687 switch (message_id) { | 682 LOG(FATAL) << "failed to load webkit string with id " << message_id; |
| 688 case IDS_SEARCHABLE_INDEX_INTRO: | |
| 689 str = "This is a searchable index. Enter search keywords: "; | |
| 690 break; | |
| 691 case IDS_FORM_SUBMIT_LABEL: | |
| 692 str = "Submit"; | |
| 693 break; | |
| 694 case IDS_FORM_INPUT_ALT: | |
| 695 str = "Submit"; | |
| 696 break; | |
| 697 case IDS_FORM_RESET_LABEL: | |
| 698 str = "Reset"; | |
| 699 break; | |
| 700 case IDS_FORM_FILE_BUTTON_LABEL: | |
| 701 str = "Choose File"; | |
| 702 break; | |
| 703 case IDS_FORM_FILE_NO_FILE_LABEL: | |
| 704 str = "No file chosen"; | |
| 705 break; | |
| 706 case IDS_FORM_FILE_NO_FILE_DRAG_LABEL: | |
| 707 str = "Drag file here"; | |
| 708 break; | |
| 709 case IDS_RECENT_SEARCHES_NONE: | |
| 710 str = "No recent searches"; | |
| 711 break; | |
| 712 case IDS_RECENT_SEARCHES: | |
| 713 str = "Recent Searches"; | |
| 714 break; | |
| 715 case IDS_RECENT_SEARCHES_CLEAR: | |
| 716 str = "Clear Recent Searches"; | |
| 717 break; | |
| 718 case IDS_IMAGE_TITLE_FOR_FILENAME: | |
| 719 str = "%s%d\xc3\x97%d"; | |
| 720 break; | |
| 721 case IDS_AX_ROLE_WEB_AREA: | |
| 722 str = "web area"; | |
| 723 break; | |
| 724 case IDS_AX_ROLE_LINK: | |
| 725 str = "link"; | |
| 726 break; | |
| 727 case IDS_AX_ROLE_LIST_MARKER: | |
| 728 str = "list marker"; | |
| 729 break; | |
| 730 case IDS_AX_ROLE_IMAGE_MAP: | |
| 731 str = "image map"; | |
| 732 break; | |
| 733 case IDS_AX_ROLE_HEADING: | |
| 734 str = "heading"; | |
| 735 break; | |
| 736 case IDS_AX_BUTTON_ACTION_VERB: | |
| 737 str = "press"; | |
| 738 break; | |
| 739 case IDS_AX_RADIO_BUTTON_ACTION_VERB: | |
| 740 str = "select"; | |
| 741 break; | |
| 742 case IDS_AX_TEXT_FIELD_ACTION_VERB: | |
| 743 str = "activate"; | |
| 744 break; | |
| 745 case IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB: | |
| 746 str = "uncheck"; | |
| 747 break; | |
| 748 case IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB: | |
| 749 str = "check"; | |
| 750 break; | |
| 751 case IDS_AX_LINK_ACTION_VERB: | |
| 752 str = "jump"; | |
| 753 break; | |
| 754 case IDS_KEYGEN_HIGH_GRADE_KEY: | |
| 755 str = "2048 (High Grade)"; | |
| 756 break; | |
| 757 case IDS_KEYGEN_MED_GRADE_KEY: | |
| 758 str = "1024 (Medium Grade)"; | |
| 759 break; | |
| 760 case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG: | |
| 761 str = "$1 plugin is not installed"; | |
| 762 break; | |
| 763 case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_NO_PLUGIN_NAME: | |
| 764 str = "The required plugin is not installed"; | |
| 765 break; | |
| 766 case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_2: | |
| 767 str = "Click here to download plugin"; | |
| 768 break; | |
| 769 case IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG: | |
| 770 str = "After installing the plugin, click here to refresh"; | |
| 771 break; | |
| 772 case IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG: | |
| 773 str = "No plugin available to display this content"; | |
| 774 break; | |
| 775 case IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG: | |
| 776 str = "Downloading plugin..."; | |
| 777 break; | |
| 778 case IDS_DEFAULT_PLUGIN_GET_THE_PLUGIN_BTN_MSG: | |
| 779 str = "Get Plugin"; | |
| 780 break; | |
| 781 case IDS_DEFAULT_PLUGIN_CANCEL_PLUGIN_DOWNLOAD_MSG: | |
| 782 str = "Cancel"; | |
| 783 break; | |
| 784 case IDS_DEFAULT_PLUGIN_CONFIRMATION_DIALOG_TITLE: | |
| 785 str = "$1 plugin needed"; | |
| 786 break; | |
| 787 case IDS_DEFAULT_PLUGIN_CONFIRMATION_DIALOG_TITLE_NO_PLUGIN_NAME: | |
| 788 str = "Additional plugin needed"; | |
| 789 break; | |
| 790 case IDS_DEFAULT_PLUGIN_USER_OPTION_MSG: | |
| 791 str = "Please confirm that you would like to install the $1 plugin. You sh
ould only install plugins that you trust."; | |
| 792 break; | |
| 793 case IDS_DEFAULT_PLUGIN_USER_OPTION_MSG_NO_PLUGIN_NAME: | |
| 794 str = "Please confirm that you would like to install this plugin. You shou
ld only install plugins that you trust."; | |
| 795 break; | |
| 796 case IDS_DEFAULT_PLUGIN_USE_OPTION_CONFIRM: | |
| 797 str = "Install"; | |
| 798 break; | |
| 799 case IDS_DEFAULT_PLUGIN_USE_OPTION_CANCEL: | |
| 800 str = "Cancel"; | |
| 801 break; | |
| 802 case IDS_DEFAULT_PLUGIN_DOWNLOAD_FAILED_MSG: | |
| 803 str = "Failed to install plugin from $1"; | |
| 804 break; | |
| 805 case IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG: | |
| 806 str = "Plugin installation failed"; | |
| 807 break; | |
| 808 default: | |
| 809 NOTIMPLEMENTED(); | |
| 810 str = "No string for this identifier!"; | |
| 811 } | 683 } |
| 812 | 684 |
| 813 return UTF8ToWide(str); | 685 return UTF8ToWide(res.as_string()); |
| 814 } | 686 } |
| 815 | 687 |
| 816 std::string GetDataResource(int resource_id) { | 688 std::string GetDataResource(int resource_id) { |
| 817 switch (resource_id) { | 689 switch (resource_id) { |
| 818 case IDR_FEED_PREVIEW: | 690 case IDR_FEED_PREVIEW: |
| 819 // It is necessary to return a feed preview template that contains | 691 // It is necessary to return a feed preview template that contains |
| 820 // a {{URL}} substring where the feed URL should go; see the code | 692 // a {{URL}} substring where the feed URL should go; see the code |
| 821 // that computes feed previews in feed_preview.cc:MakeFeedPreview. | 693 // that computes feed previews in feed_preview.cc:MakeFeedPreview. |
| 822 // This fixes issue #932714. | 694 // This fixes issue #932714. |
| 823 resource_id = IDR_FEED_PREVIEW_TESTSHELL; | 695 resource_id = IDR_FEED_PREVIEW_TESTSHELL; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 837 } | 709 } |
| 838 | 710 |
| 839 bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { | 711 bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { |
| 840 // TODO(port): Implement plugins someday. Don't let the error message | 712 // TODO(port): Implement plugins someday. Don't let the error message |
| 841 // of NOTIMPLEMENTED into our layout test diffs. | 713 // of NOTIMPLEMENTED into our layout test diffs. |
| 842 // NOTIMPLEMENTED(); | 714 // NOTIMPLEMENTED(); |
| 843 return false; | 715 return false; |
| 844 } | 716 } |
| 845 | 717 |
| 846 } // namespace webkit_glue | 718 } // namespace webkit_glue |
| OLD | NEW |