Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1173)

Unified Diff: webkit/api/src/LocalizedStrings.cpp

Issue 149760: Introduce WebLocalizedString and queryLocalizedString methods... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/api/public/WebLocalizedString.h ('k') | webkit/glue/localized_strings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/api/src/LocalizedStrings.cpp
===================================================================
--- webkit/api/src/LocalizedStrings.cpp (revision 20870)
+++ webkit/api/src/LocalizedStrings.cpp (working copy)
@@ -1,193 +1,241 @@
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "LocalizedStrings.h"
+
+#include "IntSize.h"
+#include "NotImplemented.h"
#include "PlatformString.h"
-#include "IntSize.h"
-#undef LOG
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebLocalizedString.h"
+#include "WebString.h"
-#include "base/logging.h"
-#include "base/file_util.h"
-#include "base/string16.h"
-#include "base/string_util.h"
-#include "grit/webkit_strings.h"
-#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webkit_glue.h"
+using WebKit::WebLocalizedString;
+namespace WebCore {
-using namespace WebCore;
+static String query(WebLocalizedString::Name name)
+{
+ return WebKit::webKitClient()->queryLocalizedString(name);
+}
-inline String GetLocalizedString(int message_id) {
- const string16& str = webkit_glue::GetLocalizedString(message_id);
- return webkit_glue::String16ToString(str);
+static String query(WebLocalizedString::Name name, int numericValue)
+{
+ return WebKit::webKitClient()->queryLocalizedString(name, numericValue);
}
-String WebCore::searchableIndexIntroduction() {
- return GetLocalizedString(IDS_SEARCHABLE_INDEX_INTRO);
+String searchableIndexIntroduction()
+{
+ return query(WebLocalizedString::SearchableIndexIntroduction);
}
-String WebCore::submitButtonDefaultLabel() {
- return GetLocalizedString(IDS_FORM_SUBMIT_LABEL);
+
+String submitButtonDefaultLabel()
+{
+ return query(WebLocalizedString::SubmitButtonDefaultLabel);
}
-String WebCore::inputElementAltText() {
- return GetLocalizedString(IDS_FORM_INPUT_ALT);
+
+String inputElementAltText()
+{
+ return query(WebLocalizedString::InputElementAltText);
}
-String WebCore::resetButtonDefaultLabel() {
- return GetLocalizedString(IDS_FORM_RESET_LABEL);
+
+String resetButtonDefaultLabel()
+{
+ return query(WebLocalizedString::ResetButtonDefaultLabel);
}
-String WebCore::fileButtonChooseFileLabel() {
- return GetLocalizedString(IDS_FORM_FILE_BUTTON_LABEL);
+
+String fileButtonChooseFileLabel()
+{
+ return query(WebLocalizedString::FileButtonChooseFileLabel);
}
-String WebCore::fileButtonNoFileSelectedLabel() {
- return GetLocalizedString(IDS_FORM_FILE_NO_FILE_LABEL);
+
+String fileButtonNoFileSelectedLabel()
+{
+ return query(WebLocalizedString::FileButtonNoFileSelectedLabel);
}
-String WebCore::searchMenuNoRecentSearchesText() {
- return GetLocalizedString(IDS_RECENT_SEARCHES_NONE);
+String searchMenuNoRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuNoRecentSearchesText);
}
-String WebCore::searchMenuRecentSearchesText() {
- return GetLocalizedString(IDS_RECENT_SEARCHES);
+String searchMenuRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuRecentSearchesText);
}
-String WebCore::searchMenuClearRecentSearchesText() {
- return GetLocalizedString(IDS_RECENT_SEARCHES_CLEAR);
+String searchMenuClearRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuClearRecentSearchesText);
}
-// A11y strings.
-String WebCore::AXWebAreaText() {
- return GetLocalizedString(IDS_AX_ROLE_WEB_AREA);
+String AXWebAreaText()
+{
+ return query(WebLocalizedString::AXWebAreaText);
}
-String WebCore::AXLinkText() {
- return GetLocalizedString(IDS_AX_ROLE_LINK);
+
+String AXLinkText()
+{
+ return query(WebLocalizedString::AXLinkText);
}
-String WebCore::AXListMarkerText() {
- return GetLocalizedString(IDS_AX_ROLE_LIST_MARKER);
+
+String AXListMarkerText()
+{
+ return query(WebLocalizedString::AXListMarkerText);
}
-String WebCore::AXImageMapText() {
- return GetLocalizedString(IDS_AX_ROLE_IMAGE_MAP);
+
+String AXImageMapText()
+{
+ return query(WebLocalizedString::AXImageMapText);
}
-String WebCore::AXHeadingText() {
- return GetLocalizedString(IDS_AX_ROLE_HEADING);
+
+String AXHeadingText()
+{
+ return query(WebLocalizedString::AXHeadingText);
}
-String WebCore::AXDefinitionListTermText() {
- NOTIMPLEMENTED();
- return String("term");
+
+String AXDefinitionListTermText()
+{
+ notImplemented();
+ return String("term");
}
-String WebCore::AXDefinitionListDefinitionText() {
- NOTIMPLEMENTED();
- return String("definition");
+
+String AXDefinitionListDefinitionText()
+{
+ notImplemented();
+ return String("definition");
}
-String WebCore::AXButtonActionVerb() {
- return GetLocalizedString(IDS_AX_BUTTON_ACTION_VERB);
+
+String AXButtonActionVerb()
+{
+ return query(WebLocalizedString::AXButtonActionVerb);
}
-String WebCore::AXRadioButtonActionVerb() {
- return GetLocalizedString(IDS_AX_RADIO_BUTTON_ACTION_VERB);
+
+String AXRadioButtonActionVerb()
+{
+ return query(WebLocalizedString::AXRadioButtonActionVerb);
}
-String WebCore::AXTextFieldActionVerb() {
- return GetLocalizedString(IDS_AX_TEXT_FIELD_ACTION_VERB);
+
+String AXTextFieldActionVerb()
+{
+ return query(WebLocalizedString::AXTextFieldActionVerb);
}
-String WebCore::AXCheckedCheckBoxActionVerb() {
- return GetLocalizedString(IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB);
+
+String AXCheckedCheckBoxActionVerb()
+{
+ return query(WebLocalizedString::AXCheckedCheckBoxActionVerb);
}
-String WebCore::AXUncheckedCheckBoxActionVerb() {
- return GetLocalizedString(IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB);
+
+String AXUncheckedCheckBoxActionVerb()
+{
+ return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb);
}
-String WebCore::AXLinkActionVerb() {
- return GetLocalizedString(IDS_AX_LINK_ACTION_VERB);
+
+String AXLinkActionVerb()
+{
+ return query(WebLocalizedString::AXLinkActionVerb);
}
-String WebCore::multipleFileUploadText(unsigned number_of_files) {
- return webkit_glue::String16ToString(ReplaceStringPlaceholders(
- webkit_glue::GetLocalizedString(IDS_FORM_FILE_MULTIPLE_UPLOAD),
- WideToUTF16Hack(UintToWString(number_of_files)),
- NULL));
+String multipleFileUploadText(unsigned numberOfFiles)
+{
+ return query(WebLocalizedString::MultipleFileUploadText, numberOfFiles);
}
+
// Used in FTPDirectoryDocument.cpp
-String WebCore::unknownFileSizeText() {
- return String();
+String unknownFileSizeText()
+{
+ return String();
}
// The following two functions are not declared in LocalizedStrings.h.
// They are used by the menu for the HTML keygen tag.
-namespace WebCore {
-String keygenMenuHighGradeKeySize() {
- return GetLocalizedString(IDS_KEYGEN_HIGH_GRADE_KEY);
+String keygenMenuHighGradeKeySize()
+{
+ return query(WebLocalizedString::KeygenMenuHighGradeKeySize);
}
-String keygenMenuMediumGradeKeySize() {
- return GetLocalizedString(IDS_KEYGEN_MED_GRADE_KEY);
+
+String keygenMenuMediumGradeKeySize()
+{
+ return query(WebLocalizedString::KeygenMenuMediumGradeKeySize);
}
// Used in ImageDocument.cpp as the title for pages when that page is an image.
-String imageTitle(const String& filename, const IntSize& size) {
- // C3 97 is UTF-8 for U+00D7 (multiplication sign).
- std::string size_str = StringPrintf(" (%d\xC3\x97%d)",
- size.width(), size.height());
- return filename + webkit_glue::StdStringToString(size_str);
+String imageTitle(const String& filename, const IntSize& size)
+{
+ // C3 97 is UTF-8 for U+00D7 (multiplication sign).
+ return filename + String::format(" (%d\xC3\x97%d)", size.width(), size.height());
}
-} //namespace WebCore
-
// We don't use these strings, so they return an empty String. We can't just
// make them asserts because webcore still calls them.
-String WebCore::contextMenuItemTagOpenLinkInNewWindow() { return String(); }
-String WebCore::contextMenuItemTagDownloadLinkToDisk() { return String(); }
-String WebCore::contextMenuItemTagCopyLinkToClipboard() { return String(); }
-String WebCore::contextMenuItemTagOpenImageInNewWindow() { return String(); }
-String WebCore::contextMenuItemTagDownloadImageToDisk() { return String(); }
-String WebCore::contextMenuItemTagCopyImageToClipboard() { return String(); }
-String WebCore::contextMenuItemTagOpenFrameInNewWindow() { return String(); }
-String WebCore::contextMenuItemTagCopy() { return String(); }
-String WebCore::contextMenuItemTagGoBack() { return String(); }
-String WebCore::contextMenuItemTagGoForward() { return String(); }
-String WebCore::contextMenuItemTagStop() { return String(); }
-String WebCore::contextMenuItemTagReload() { return String(); }
-String WebCore::contextMenuItemTagCut() { return String(); }
-String WebCore::contextMenuItemTagPaste() { return String(); }
-String WebCore::contextMenuItemTagNoGuessesFound() { return String(); }
-String WebCore::contextMenuItemTagIgnoreSpelling() { return String(); }
-String WebCore::contextMenuItemTagLearnSpelling() { return String(); }
-String WebCore::contextMenuItemTagSearchWeb() { return String(); }
-String WebCore::contextMenuItemTagLookUpInDictionary() { return String(); }
-String WebCore::contextMenuItemTagOpenLink() { return String(); }
-String WebCore::contextMenuItemTagIgnoreGrammar() { return String(); }
-String WebCore::contextMenuItemTagSpellingMenu() { return String(); }
-String WebCore::contextMenuItemTagCheckSpelling() { return String(); }
-String WebCore::contextMenuItemTagCheckSpellingWhileTyping() { return String(); }
-String WebCore::contextMenuItemTagCheckGrammarWithSpelling() { return String(); }
-String WebCore::contextMenuItemTagFontMenu() { return String(); }
-String WebCore::contextMenuItemTagBold() { return String(); }
-String WebCore::contextMenuItemTagItalic() { return String(); }
-String WebCore::contextMenuItemTagUnderline() { return String(); }
-String WebCore::contextMenuItemTagOutline() { return String(); }
-String WebCore::contextMenuItemTagWritingDirectionMenu() { return String(); }
-String WebCore::contextMenuItemTagTextDirectionMenu() { return String(); }
-String WebCore::contextMenuItemTagDefaultDirection() { return String(); }
-String WebCore::contextMenuItemTagLeftToRight() { return String(); }
-String WebCore::contextMenuItemTagRightToLeft() { return String(); }
-String WebCore::contextMenuItemTagInspectElement() { return String(); }
-String WebCore::contextMenuItemTagShowSpellingPanel(bool show) { return String(); }
-// TODO(scherkus): These should return something.
-String WebCore::mediaElementLiveBroadcastStateText() { return String(); }
-String WebCore::mediaElementLoadingStateText() { return String(); }
+String contextMenuItemTagOpenLinkInNewWindow() { return String(); }
+String contextMenuItemTagDownloadLinkToDisk() { return String(); }
+String contextMenuItemTagCopyLinkToClipboard() { return String(); }
+String contextMenuItemTagOpenImageInNewWindow() { return String(); }
+String contextMenuItemTagDownloadImageToDisk() { return String(); }
+String contextMenuItemTagCopyImageToClipboard() { return String(); }
+String contextMenuItemTagOpenFrameInNewWindow() { return String(); }
+String contextMenuItemTagCopy() { return String(); }
+String contextMenuItemTagGoBack() { return String(); }
+String contextMenuItemTagGoForward() { return String(); }
+String contextMenuItemTagStop() { return String(); }
+String contextMenuItemTagReload() { return String(); }
+String contextMenuItemTagCut() { return String(); }
+String contextMenuItemTagPaste() { return String(); }
+String contextMenuItemTagNoGuessesFound() { return String(); }
+String contextMenuItemTagIgnoreSpelling() { return String(); }
+String contextMenuItemTagLearnSpelling() { return String(); }
+String contextMenuItemTagSearchWeb() { return String(); }
+String contextMenuItemTagLookUpInDictionary() { return String(); }
+String contextMenuItemTagOpenLink() { return String(); }
+String contextMenuItemTagIgnoreGrammar() { return String(); }
+String contextMenuItemTagSpellingMenu() { return String(); }
+String contextMenuItemTagCheckSpelling() { return String(); }
+String contextMenuItemTagCheckSpellingWhileTyping() { return String(); }
+String contextMenuItemTagCheckGrammarWithSpelling() { return String(); }
+String contextMenuItemTagFontMenu() { return String(); }
+String contextMenuItemTagBold() { return String(); }
+String contextMenuItemTagItalic() { return String(); }
+String contextMenuItemTagUnderline() { return String(); }
+String contextMenuItemTagOutline() { return String(); }
+String contextMenuItemTagWritingDirectionMenu() { return String(); }
+String contextMenuItemTagTextDirectionMenu() { return String(); }
+String contextMenuItemTagDefaultDirection() { return String(); }
+String contextMenuItemTagLeftToRight() { return String(); }
+String contextMenuItemTagRightToLeft() { return String(); }
+String contextMenuItemTagInspectElement() { return String(); }
+String contextMenuItemTagShowSpellingPanel(bool show) { return String(); }
+
+// FIXME: These should return something.
+String mediaElementLiveBroadcastStateText() { return String(); }
+String mediaElementLoadingStateText() { return String(); }
+
+} // namespace WebCore
« no previous file with comments | « webkit/api/public/WebLocalizedString.h ('k') | webkit/glue/localized_strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698