diff options
-rw-r--r-- | WebCore/platform/android/FileChooserAndroid.cpp | 17 | ||||
-rw-r--r-- | WebCore/platform/android/LocalizedStringsAndroid.cpp | 23 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 10 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 5 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 52 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.h | 10 |
6 files changed, 87 insertions, 30 deletions
diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp index 69d0883..1f8200f 100644 --- a/WebCore/platform/android/FileChooserAndroid.cpp +++ b/WebCore/platform/android/FileChooserAndroid.cpp @@ -25,7 +25,6 @@ #include "config.h" #include "FileChooser.h" - #include "Font.h" namespace WebCore { @@ -44,18 +43,4 @@ String FileChooser::basenameForWidth(const Font& font, int width) const return output; } -// The following two strings are used for File Upload form control, ie -// <input type="file">. The first is the text that appears on the button -// that when pressed, the user can browse for and select a file. The -// second string is rendered on the screen when no file has been selected. -String fileButtonChooseFileLabel() -{ - return String("Upload a file"); -} - -String fileButtonNoFileSelectedLabel() -{ - return String("No file selected"); -} - -} // namesapce WebCore +} // namespace WebCore diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp index 2fc880b..ab1c895 100644 --- a/WebCore/platform/android/LocalizedStringsAndroid.cpp +++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp @@ -31,10 +31,27 @@ #include "LocalizedStrings.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformString.h" namespace WebCore { +// The following two strings are used for File Upload form control, ie +// <input type="file">. The first is the text that appears on the button +// that when pressed, the user can browse for and select a file. The +// second string is rendered on the screen when no file has been selected. +String fileButtonChooseFileLabel() +{ + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::FileUploadLabel)); +} + +String fileButtonNoFileSelectedLabel() +{ + notImplemented(); + return String(); +} + String contextMenuItemTagInspectElement() { return String("Inspect Element"); @@ -305,12 +322,14 @@ String searchableIndexIntroduction() String resetButtonDefaultLabel() { - return String("Reset"); + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::ResetLabel)); } String submitButtonDefaultLabel() { - return String("Submit"); + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::SubmitLabel)); } String inputElementAltText() diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 977a0fd..e3f3b98 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -48,6 +48,16 @@ public: // KeyGenerator static WTF::Vector<String> getSupportedKeyStrengthList(); static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); + // These ids need to be in sync with the constants in BrowserFrame.java + enum rawResId { + NoDomain = 1, + LoadError, + DrawableDir, + FileUploadLabel, + ResetLabel, + SubmitLabel + }; + static String* globalLocalizedName(rawResId resId); }; } #endif // PlatformBridge_h diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index ae3d582..44c942d 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -44,6 +44,7 @@ #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "Page.h" +#include "PlatformBridge.h" #include "PlatformGraphicsContext.h" #include "PlatformString.h" #include "PluginDatabase.h" @@ -300,11 +301,11 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro AssetManager* am = globalAssetManager(); // Check to see if the error code was not generated internally - WebFrame::RAW_RES_ID id = WebFrame::NODOMAIN; + WebCore::PlatformBridge::rawResId id = WebCore::PlatformBridge::NoDomain; if ((error.errorCode() == ErrorFile || error.errorCode() == ErrorFileNotFound) && (!error.localizedDescription().isEmpty())) { - id = WebFrame::LOADERROR; + id = WebCore::PlatformBridge::LoadError; } String filename = m_webFrame->getRawResourceFilename(id); if (filename.isEmpty()) diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index f25e4a6..0ff8fe2 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -116,6 +116,49 @@ #include "TimeCounter.h" #endif +static String* gUploadFileLabel; +static String* gResetLabel; +static String* gSubmitLabel; + +String* WebCore::PlatformBridge::globalLocalizedName( + WebCore::PlatformBridge::rawResId resId) +{ + switch (resId) { + case WebCore::PlatformBridge::FileUploadLabel: + return gUploadFileLabel; + case WebCore::PlatformBridge::ResetLabel: + return gResetLabel; + case WebCore::PlatformBridge::SubmitLabel: + return gSubmitLabel; + default: + return 0; + } +} +/** + * Instantiate the localized name desired. + */ +void initGlobalLocalizedName(WebCore::PlatformBridge::rawResId resId, + android::WebFrame* webFrame) +{ + String** pointer; + switch (resId) { + case WebCore::PlatformBridge::FileUploadLabel: + pointer = &gUploadFileLabel; + break; + case WebCore::PlatformBridge::ResetLabel: + pointer = &gResetLabel; + break; + case WebCore::PlatformBridge::SubmitLabel: + pointer = &gSubmitLabel; + break; + default: + return; + } + if (!(*pointer) && webFrame) { + (*pointer) = new String(webFrame->getRawResourceFilename(resId).impl()); + } +} + namespace android { // ---------------------------------------------------------------------------- @@ -825,7 +868,7 @@ WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func) } WebCore::String -WebFrame::getRawResourceFilename(RAW_RES_ID id) const +WebFrame::getRawResourceFilename(WebCore::PlatformBridge::rawResId id) const { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = mJavaFrame->frame(env); @@ -927,7 +970,8 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Set the mNativeFrame field in Frame SET_NATIVE_FRAME(env, obj, (int)frame); - String directory = webFrame->getRawResourceFilename(WebFrame::DRAWABLEDIR); + String directory = webFrame->getRawResourceFilename( + WebCore::PlatformBridge::DrawableDir); if (directory.isEmpty()) LOGE("Can't find the drawable directory"); else { @@ -936,6 +980,10 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Initialize our skinning classes WebCore::RenderSkinAndroid::Init(am, directory); } + for (int i = WebCore::PlatformBridge::FileUploadLabel; + i <= WebCore::PlatformBridge::SubmitLabel; i++) + initGlobalLocalizedName( + static_cast<WebCore::PlatformBridge::rawResId>(i), webFrame); } static void DestroyFrame(JNIEnv* env, jobject obj) diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h index 7d18c40..657ebf1 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.h +++ b/WebKit/android/jni/WebCoreFrameBridge.h @@ -29,7 +29,7 @@ #define WEBFRAME_H #include "FrameLoaderClient.h" -#include "PlatformString.h" +#include "PlatformBridge.h" #include "WebCoreRefObject.h" #include <jni.h> #include <wtf/RefCounted.h> @@ -51,12 +51,6 @@ class WebViewCore; // one instance of WebFrame per Page for calling into Java's BrowserFrame class WebFrame : public WebCoreRefObject { public: - // these ids need to be in sync with the constants in BrowserFrame.java - enum RAW_RES_ID { - NODOMAIN = 1, - LOADERROR, - DRAWABLEDIR, - }; WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page); ~WebFrame(); @@ -108,7 +102,7 @@ class WebFrame : public WebCoreRefObject { void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; } - WebCore::String getRawResourceFilename(RAW_RES_ID) const; + WebCore::String getRawResourceFilename(WebCore::PlatformBridge::rawResId) const; float density() const; |