[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
ap at apple.com
ap at apple.com
Wed Dec 22 14:46:31 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 39da9f695a98f08d3f33aaeb5b008fa70e51e648
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 19 22:28:57 2010 +0000
Reviewed by Anders Carlsson.
https://bugs.webkit.org/show_bug.cgi?id=47933
<rdar://problem/8494337> navigator.language doesn't work in WebKit2
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70095 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/CMakeListsEfl.txt b/WebCore/CMakeListsEfl.txt
index 9bb1f3d..e44dfd4 100644
--- a/WebCore/CMakeListsEfl.txt
+++ b/WebCore/CMakeListsEfl.txt
@@ -31,7 +31,7 @@ LIST(APPEND WebCore_SOURCES
platform/efl/FileChooserEfl.cpp
platform/efl/FileSystemEfl.cpp
platform/efl/KURLEfl.cpp
- platform/efl/Language.cpp
+ platform/efl/LanguageEfl.cpp
platform/efl/LocalizedStringsEfl.cpp
platform/efl/LoggingEfl.cpp
platform/efl/MIMETypeRegistryEfl.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1258fb8..38c48b7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-10-19 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Anders Carlsson.
+
+ https://bugs.webkit.org/show_bug.cgi?id=47933
+ <rdar://problem/8494337> navigator.language doesn't work in WebKit2
+
+ * CMakeListsEfl.txt:
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/chromium/Language.cpp: Removed.
+ * platform/chromium/LanguageChromium.cpp: Copied from WebCore/platform/chromium/Language.cpp.
+ * platform/efl/Language.cpp: Removed.
+ * platform/efl/LanguageEfl.cpp: Copied from WebCore/platform/efl/Language.cpp.
+ * platform/gtk/Language.cpp: Removed.
+ * platform/gtk/LanguageGtk.cpp: Copied from WebCore/platform/gtk/Language.cpp.
+ * platform/qt/Language.cpp: Removed.
+ * platform/qt/LanguageQt.cpp: Copied from WebCore/platform/qt/Language.cpp.
+ * platform/win/Language.cpp: Removed.
+ * platform/win/LanguageWin.cpp: Copied from WebCore/platform/win/Language.cpp.
+ * platform/Language.cpp: Added.
+ Cross platform code is now in platform/Language.cpp. So, I renamed platform files to match
+ the common pattern.
+
+ * WebCore.exp.in: Exported new functions.
+
+ * platform/Language.h: Added an ability to force the language, and an ability to set up
+ listeners for changes (if the platform implements that). Web process will always use the
+ forced language, as sent to it from UI process.
+
+ * platform/mac/Language.mm: Moved code from WebKit.
+ (WebCore::platformDefaultLanguage): Added code to synchronize user defaults. For some reason,
+ they come unsynchronized in WebKit2 here, unlike WebKit1.
+
+ * page/mac/WebCoreViewFactory.h: Removed defaultLanguageCode. WebCore no longer goes to WebKit
+ to ask for that.
+
+ * platform/mac/WebCoreSystemInterface.h:
+ * platform/mac/WebCoreSystemInterface.mm:
+ Added wkCopyCFLocalizationPreferredName().
+
2010-10-19 James Simonsen <simonjam at chromium.org>
Reviewed by Adam Barth.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 72eaa90..811ffa6 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -2342,6 +2342,7 @@ webcore_sources += \
WebCore/platform/KURL.cpp \
WebCore/platform/KURL.h \
WebCore/platform/KURLHash.h \
+ WebCore/platform/Language.cpp \
WebCore/platform/Language.h \
WebCore/platform/LengthBox.h \
WebCore/platform/Length.cpp \
@@ -3535,7 +3536,7 @@ webcoregtk_sources += \
WebCore/platform/gtk/GtkVersioning.h \
WebCore/platform/gtk/KeyEventGtk.cpp \
WebCore/platform/gtk/KURLGtk.cpp \
- WebCore/platform/gtk/Language.cpp \
+ WebCore/platform/gtk/LanguageGtk.cpp \
WebCore/platform/gtk/LocalizedStringsGtk.cpp \
WebCore/platform/gtk/LoggingGtk.cpp \
WebCore/platform/gtk/MainFrameScrollbarGtk.cpp \
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 36a8331..ac92256 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -375,6 +375,7 @@ __ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontEb
__ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontEb
__ZN7WebCore15VisiblePositionC1EPNS_4NodeEiNS_9EAffinityE
__ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
+__ZN7WebCore15defaultLanguageEv
__ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueE
__ZN7WebCore15visitedLinkHashEPKtj
__ZN7WebCore16AbstractDatabase14setIsAvailableEb
@@ -483,6 +484,7 @@ __ZN7WebCore22counterValueForElementEPNS_7ElementE
__ZN7WebCore22createFragmentFromTextEPNS_5RangeERKN3WTF6StringE
__ZN7WebCore22externalRepresentationEPNS_5FrameEj
__ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE
+__ZN7WebCore23overrideDefaultLanguageERKN3WTF6StringE
__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
__ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
__ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker10MarkerTypeE
@@ -503,6 +505,7 @@ __ZN7WebCore25PluginMainThreadScheduler12scheduleCallEP4_NPPPFvPvES3_
__ZN7WebCore25PluginMainThreadScheduler14registerPluginEP4_NPP
__ZN7WebCore25PluginMainThreadScheduler16unregisterPluginEP4_NPP
__ZN7WebCore25PluginMainThreadScheduler9schedulerEv
+__ZN7WebCore25addLanguageChangeObserverEPvPFvS0_E
__ZN7WebCore25contextMenuItemTagOutlineEv
__ZN7WebCore26CSSMutableStyleDeclarationC1Ev
__ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEPNS_32NetscapePlugInStreamLoaderClientE
@@ -523,6 +526,7 @@ __ZN7WebCore28contextMenuItemTagCapitalizeEv
__ZN7WebCore28contextMenuItemTagShowColorsEv
__ZN7WebCore28contextMenuItemTagSmartLinksEv
__ZN7WebCore28contextMenuItemTagSpeechMenuEv
+__ZN7WebCore28removeLanguageChangeObserverEPv
__ZN7WebCore29contextMenuItemTagLeftToRightEv
__ZN7WebCore29contextMenuItemTagRightToLeftEv
__ZN7WebCore29contextMenuItemTagSmartDashesEv
@@ -1125,6 +1129,7 @@ _stringIsCaseInsensitiveEqualToString
_suggestedFilenameWithMIMEType
_wkAdvanceDefaultButtonPulseAnimation
_wkCGContextGetShouldSmoothFonts
+_wkCopyCFLocalizationPreferredName
_wkCopyCONNECTProxyResponse
_wkCopyNSURLResponseStatusLine
_wkCreateCustomCFReadStream
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index af6d1ba..f79542e 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2324,7 +2324,7 @@
'platform/chromium/GeolocationServiceChromium.h',
'platform/chromium/KeyCodeConversion.h',
'platform/chromium/KeyCodeConversionGtk.cpp',
- 'platform/chromium/Language.cpp',
+ 'platform/chromium/LanguageChromium.cpp',
'platform/chromium/LinkHashChromium.cpp',
'platform/chromium/MIMETypeRegistryChromium.cpp',
'platform/chromium/PasteboardChromium.cpp',
@@ -2814,7 +2814,7 @@
'platform/gtk/GeolocationServiceGtk.h',
'platform/gtk/KURLGtk.cpp',
'platform/gtk/KeyEventGtk.cpp',
- 'platform/gtk/Language.cpp',
+ 'platform/gtk/LanguageGtk.cpp',
'platform/gtk/LocalizedStringsGtk.cpp',
'platform/gtk/LoggingGtk.cpp',
'platform/gtk/MIMETypeRegistryGtk.cpp',
@@ -3198,7 +3198,7 @@
'platform/win/GDIObjectCounter.cpp',
'platform/win/GDIObjectCounter.h',
'platform/win/KeyEventWin.cpp',
- 'platform/win/Language.cpp',
+ 'platform/win/LanguageWin.cpp',
'platform/win/LoggingWin.cpp',
'platform/win/MIMETypeRegistryWin.cpp',
'platform/win/PasteboardWin.cpp',
@@ -3302,6 +3302,7 @@
'platform/KURLGoogle.cpp',
'platform/KURLGooglePrivate.h',
'platform/KURLHash.h',
+ 'platform/Language.cpp',
'platform/Language.h',
'platform/Length.cpp',
'platform/Length.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index a964d89..1ce1055 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1170,6 +1170,7 @@ SOURCES += \
platform/graphics/transforms/TranslateTransformOperation.cpp \
platform/KillRingNone.cpp \
platform/KURL.cpp \
+ platform/Language.cpp \
platform/Length.cpp \
platform/text/LineEnding.cpp \
platform/LinkHash.cpp \
@@ -2641,7 +2642,7 @@ SOURCES += \
platform/qt/SharedTimerQt.cpp \
platform/qt/SoundQt.cpp \
platform/qt/LoggingQt.cpp \
- platform/qt/Language.cpp \
+ platform/qt/LanguageQt.cpp \
platform/qt/TemporaryLinkStubsQt.cpp \
platform/text/qt/TextBoundariesQt.cpp \
platform/text/qt/TextBreakIteratorQt.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index ff3b64a..706065b 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -24299,6 +24299,10 @@
>
</File>
<File
+ RelativePath="..\platform\Language.cpp"
+ >
+ </File>
+ <File
RelativePath="..\platform\Language.h"
>
</File>
@@ -24718,7 +24722,7 @@
>
</File>
<File
- RelativePath="..\platform\win\Language.cpp"
+ RelativePath="..\platform\win\LanguageWin.cpp"
>
</File>
<File
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 323ffca..163310e 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2420,7 +2420,7 @@
85E9E0A80AB3A11900069CD0 /* DOMXPathExpression.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85E9E09B0AB3A0C700069CD0 /* DOMXPathExpression.h */; };
85E9E0AA0AB3A11900069CD0 /* DOMXPathNSResolver.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85E9E09E0AB3A0C700069CD0 /* DOMXPathNSResolver.h */; };
85E9E0AB0AB3A11900069CD0 /* DOMXPathResult.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85E9E09F0AB3A0C700069CD0 /* DOMXPathResult.h */; };
- 85EC9AFB0A71A2C600EEEAED /* Language.h in Headers */ = {isa = PBXBuildFile; fileRef = 85EC9AF90A71A2C600EEEAED /* Language.h */; };
+ 85EC9AFB0A71A2C600EEEAED /* Language.h in Headers */ = {isa = PBXBuildFile; fileRef = 85EC9AF90A71A2C600EEEAED /* Language.h */; settings = {ATTRIBUTES = (Private, ); }; };
85ECBEEB0AA7626900544F0B /* DOMHTMLAreaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85ECBEDD0AA7626800544F0B /* DOMHTMLAreaElement.h */; };
85ECBEEC0AA7626900544F0B /* DOMHTMLAreaElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85ECBEDE0AA7626800544F0B /* DOMHTMLAreaElement.mm */; };
85ECBEED0AA7626900544F0B /* DOMHTMLBaseFontElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85ECBEDF0AA7626800544F0B /* DOMHTMLBaseFontElement.h */; };
@@ -5334,6 +5334,7 @@
E182568F0EF2B02D00933242 /* JSWorkerContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E182568D0EF2B02D00933242 /* JSWorkerContext.cpp */; };
E18256900EF2B02D00933242 /* JSWorkerContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E182568E0EF2B02D00933242 /* JSWorkerContext.h */; };
E18258AC0EF3CD7000933242 /* JSWorkerContextCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18258AB0EF3CD7000933242 /* JSWorkerContextCustom.cpp */; };
+ E18772F1126E2629003DD586 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18772F0126E2629003DD586 /* Language.cpp */; };
E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */; };
E1A5F99B0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */; };
E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A643F10EC0972500779668 /* WorkerScriptController.h */; };
@@ -11332,6 +11333,7 @@
E182568D0EF2B02D00933242 /* JSWorkerContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContext.cpp; sourceTree = "<group>"; };
E182568E0EF2B02D00933242 /* JSWorkerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContext.h; sourceTree = "<group>"; };
E18258AB0EF3CD7000933242 /* JSWorkerContextCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextCustom.cpp; sourceTree = "<group>"; };
+ E18772F0126E2629003DD586 /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; };
E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContainerNodeAlgorithms.h; sourceTree = "<group>"; };
E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannelCustom.cpp; sourceTree = "<group>"; };
E1A643F10EC0972500779668 /* WorkerScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptController.h; sourceTree = "<group>"; };
@@ -17260,6 +17262,7 @@
6593923509AE4346002C531F /* KURL.cpp */,
6593923609AE4346002C531F /* KURL.h */,
BCBD21AA0E417AD400A070F2 /* KURLHash.h */,
+ E18772F0126E2629003DD586 /* Language.cpp */,
85EC9AF90A71A2C600EEEAED /* Language.h */,
BCE65BE80EACDF16007E4533 /* Length.cpp */,
BCE65BE90EACDF16007E4533 /* Length.h */,
@@ -21141,6 +21144,7 @@
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -23630,6 +23634,7 @@
97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */,
9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
+ E18772F1126E2629003DD586 /* Language.cpp in Sources */,
7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/WebCore/page/mac/WebCoreViewFactory.h b/WebCore/page/mac/WebCoreViewFactory.h
index 9191abe..7af75cb 100644
--- a/WebCore/page/mac/WebCoreViewFactory.h
+++ b/WebCore/page/mac/WebCoreViewFactory.h
@@ -28,8 +28,6 @@
@protocol WebCoreViewFactory
-- (NSString *)defaultLanguageCode;
-
- (BOOL)objectIsTextMarker:(id)object;
- (BOOL)objectIsTextMarkerRange:(id)object;
diff --git a/WebCore/platform/Language.cpp b/WebCore/platform/Language.cpp
new file mode 100644
index 0000000..6cf2597
--- /dev/null
+++ b/WebCore/platform/Language.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Apple 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "Language.h"
+
+#include "PlatformString.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+typedef HashMap<void*, LanguageChangeObserverFunction> ObserverMap;
+static ObserverMap& observerMap()
+{
+ DEFINE_STATIC_LOCAL(ObserverMap, map, ());
+ return map;
+}
+
+void addLanguageChangeObserver(void* context, LanguageChangeObserverFunction customObserver)
+{
+ observerMap().set(context, customObserver);
+}
+
+void removeLanguageChangeObserver(void* context)
+{
+ ASSERT(observerMap().contains(context));
+ observerMap().remove(context);
+}
+
+void languageDidChange()
+{
+ ObserverMap::iterator end = observerMap().end();
+ for (ObserverMap::iterator iter = observerMap().begin(); iter != end; ++iter)
+ iter->second(iter->first);
+}
+
+static String& languageOverride()
+{
+ DEFINE_STATIC_LOCAL(String, override, ());
+ return override;
+}
+
+String defaultLanguage()
+{
+ const String& override = languageOverride();
+ if (!override.isNull())
+ return override;
+
+ return platformDefaultLanguage();
+}
+
+void overrideDefaultLanguage(const String& override)
+{
+ languageOverride() = override;
+}
+
+}
diff --git a/WebCore/platform/Language.h b/WebCore/platform/Language.h
index 4c92755..656caee 100644
--- a/WebCore/platform/Language.h
+++ b/WebCore/platform/Language.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,17 +10,17 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 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
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
#ifndef Language_h
@@ -30,8 +30,16 @@
namespace WebCore {
- String defaultLanguage();
+String defaultLanguage();
+void overrideDefaultLanguage(const String&);
+// The observer function will be called when system language changes (unless it's overridden by overrideDefaultLanguage()).
+typedef void (*LanguageChangeObserverFunction)(void* context);
+void addLanguageChangeObserver(void* context, LanguageChangeObserverFunction);
+void removeLanguageChangeObserver(void* context);
+
+String platformDefaultLanguage();
+void languageDidChange();
}
#endif
diff --git a/WebCore/platform/chromium/Language.cpp b/WebCore/platform/chromium/Language.cpp
deleted file mode 100644
index 2612af4..0000000
--- a/WebCore/platform/chromium/Language.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, 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:
- *
- * * 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 "Language.h"
-
-#include "ChromiumBridge.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- static String computedDefaultLanguage;
- if (computedDefaultLanguage.isEmpty())
- computedDefaultLanguage = ChromiumBridge::computedDefaultLanguage();
- return computedDefaultLanguage;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/chromium/LanguageChromium.cpp b/WebCore/platform/chromium/LanguageChromium.cpp
new file mode 100644
index 0000000..69fe372
--- /dev/null
+++ b/WebCore/platform/chromium/LanguageChromium.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2008, 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:
+ *
+ * * 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 "Language.h"
+
+#include "ChromiumBridge.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+String platformDefaultLanguage()
+{
+ static String computedDefaultLanguage;
+ if (computedDefaultLanguage.isEmpty())
+ computedDefaultLanguage = ChromiumBridge::computedDefaultLanguage();
+ return computedDefaultLanguage;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/efl/Language.cpp b/WebCore/platform/efl/Language.cpp
deleted file mode 100644
index 1da7925..0000000
--- a/WebCore/platform/efl/Language.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
- * Copyright (C) 2009-2010 ProFUSION embedded systems
- * Copyright (C) 2009-2010 Samsung Electronics
- *
- * 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.
- *
- * 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
- * (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 "Language.h"
-
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- notImplemented();
- return String();
-}
-
-}
diff --git a/WebCore/platform/efl/LanguageEfl.cpp b/WebCore/platform/efl/LanguageEfl.cpp
new file mode 100644
index 0000000..4b765a6
--- /dev/null
+++ b/WebCore/platform/efl/LanguageEfl.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
+ * Copyright (C) 2009-2010 ProFUSION embedded systems
+ * Copyright (C) 2009-2010 Samsung Electronics
+ *
+ * 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.
+ *
+ * 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
+ * (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 "Language.h"
+
+#include "NotImplemented.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+String platformDefaultLanguage()
+{
+ notImplemented();
+ return String();
+}
+
+}
diff --git a/WebCore/platform/gtk/Language.cpp b/WebCore/platform/gtk/Language.cpp
deleted file mode 100644
index e487946..0000000
--- a/WebCore/platform/gtk/Language.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp at atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Language.h"
-
-#include "GOwnPtr.h"
-#include "PlatformString.h"
-#include <wtf/text/CString.h>
-
-#include <glib.h>
-#include <locale.h>
-
-namespace WebCore {
-
-// Using pango_language_get_default() here is not an option, because
-// it doesn't support changing the locale in runtime, so it returns
-// always the same value.
-String defaultLanguage()
-{
- char* localeDefault = setlocale(LC_CTYPE, NULL);
-
- if (!localeDefault)
- return String("c");
-
- GOwnPtr<gchar> normalizedDefault(g_ascii_strdown(localeDefault, -1));
- char* ptr = strchr(normalizedDefault.get(), '_');
-
- if (ptr)
- *ptr = '-';
-
- ptr = strchr(normalizedDefault.get(), '.');
-
- if (ptr)
- *ptr = '\0';
-
- return String(normalizedDefault.get());
-}
-
-}
diff --git a/WebCore/platform/gtk/LanguageGtk.cpp b/WebCore/platform/gtk/LanguageGtk.cpp
new file mode 100644
index 0000000..7d7a66d
--- /dev/null
+++ b/WebCore/platform/gtk/LanguageGtk.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp at atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "Language.h"
+
+#include "GOwnPtr.h"
+#include "PlatformString.h"
+#include <wtf/text/CString.h>
+
+#include <glib.h>
+#include <locale.h>
+
+namespace WebCore {
+
+// Using pango_language_get_default() here is not an option, because
+// it doesn't support changing the locale in runtime, so it returns
+// always the same value.
+String platformDefaultLanguage()
+{
+ char* localeDefault = setlocale(LC_CTYPE, NULL);
+
+ if (!localeDefault)
+ return String("c");
+
+ GOwnPtr<gchar> normalizedDefault(g_ascii_strdown(localeDefault, -1));
+ char* ptr = strchr(normalizedDefault.get(), '_');
+
+ if (ptr)
+ *ptr = '-';
+
+ ptr = strchr(normalizedDefault.get(), '.');
+
+ if (ptr)
+ *ptr = '\0';
+
+ return String(normalizedDefault.get());
+}
+
+}
diff --git a/WebCore/platform/mac/Language.mm b/WebCore/platform/mac/Language.mm
index 96caaa6..bb51cb5 100644
--- a/WebCore/platform/mac/Language.mm
+++ b/WebCore/platform/mac/Language.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,32 +10,106 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 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
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
#import "config.h"
#import "Language.h"
#import "BlockExceptions.h"
-#import "PlatformString.h"
-#import "WebCoreViewFactory.h"
+#import "WebCoreSystemInterface.h"
+#import <wtf/Assertions.h>
+#import <wtf/MainThread.h>
+#import <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+static NSString *preferredLanguageCode;
+
+ at interface LanguageChangeObserver : NSObject {
+}
+ at end
+
+ at implementation LanguageChangeObserver
+
++ (void)_webkit_languagePreferencesDidChange
+{
+ ASSERT(isMainThread());
+
+ [preferredLanguageCode release];
+ preferredLanguageCode = nil;
+
+ languageDidChange();
+}
+
+ at end
namespace WebCore {
-String defaultLanguage()
+static NSString *createHTTPStyleLanguageCode(NSString *languageCode)
{
+ ASSERT(isMainThread());
+
+ // Look up the language code using CFBundle.
+ CFStringRef preferredLanguageCode = wkCopyCFLocalizationPreferredName((CFStringRef)languageCode);
+
+ if (preferredLanguageCode)
+ languageCode = (NSString *)preferredLanguageCode;
+
+ // Make the string lowercase.
+ NSString *lowercaseLanguageCode = [languageCode lowercaseString];
+
+ // Turn a '_' into a '-' if it appears after a 2-letter language code.
+ if ([lowercaseLanguageCode length] < 3 || [lowercaseLanguageCode characterAtIndex:2] != '_')
+ return lowercaseLanguageCode;
+
+ NSMutableString *result = [lowercaseLanguageCode mutableCopy];
+ [result replaceCharactersInRange:NSMakeRange(2, 1) withString:@"-"];
+
+ if (preferredLanguageCode)
+ CFRelease(preferredLanguageCode);
+
+ return result;
+}
+
+String platformDefaultLanguage()
+{
+ ASSERT(isMainThread());
+
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] defaultLanguageCode];
+
+ if (!preferredLanguageCode) {
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ NSArray *languages = [[NSUserDefaults standardUserDefaults] stringArrayForKey:@"AppleLanguages"];
+ if (![languages count])
+ preferredLanguageCode = @"en";
+ else
+ preferredLanguageCode = createHTTPStyleLanguageCode([languages objectAtIndex:0]);
+ }
+
+ NSString *code = [[preferredLanguageCode retain] autorelease];
+
+ static bool languageChangeObserverAdded;
+ if (!languageChangeObserverAdded) {
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:[LanguageChangeObserver self]
+ selector:@selector(_webkit_languagePreferencesDidChange)
+ name:@"AppleLanguagePreferencesChangedNotification"
+ object:nil];
+ languageChangeObserverAdded = true;
+ }
+
+ return code;
+
END_BLOCK_OBJC_EXCEPTIONS;
return String();
}
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.h b/WebCore/platform/mac/WebCoreSystemInterface.h
index 0cc7fd5..7cac443 100644
--- a/WebCore/platform/mac/WebCoreSystemInterface.h
+++ b/WebCore/platform/mac/WebCoreSystemInterface.h
@@ -94,6 +94,7 @@ extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadS
void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
void *context);
+extern CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
extern id (*wkCreateNSURLConnectionDelegateProxy)(void);
extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.mm b/WebCore/platform/mac/WebCoreSystemInterface.mm
index 309a8fb..52e0064 100644
--- a/WebCore/platform/mac/WebCoreSystemInterface.mm
+++ b/WebCore/platform/mac/WebCoreSystemInterface.mm
@@ -29,6 +29,7 @@
void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
+CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
NSString* (*wkCreateURLPasteboardFlavorTypeName)(void);
NSString* (*wkCreateURLNPasteboardFlavorTypeName)(void);
diff --git a/WebCore/platform/qt/Language.cpp b/WebCore/platform/qt/Language.cpp
deleted file mode 100644
index 0d2900b..0000000
--- a/WebCore/platform/qt/Language.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * 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.
- *
- * 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
- * (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 "Language.h"
-
-#include "PlatformString.h"
-#include <QLocale>
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- QLocale locale;
- return locale.name().replace("_", "-");
-}
-
-}
diff --git a/WebCore/platform/qt/LanguageQt.cpp b/WebCore/platform/qt/LanguageQt.cpp
new file mode 100644
index 0000000..71e554f
--- /dev/null
+++ b/WebCore/platform/qt/LanguageQt.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ *
+ * 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
+ * (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 "Language.h"
+
+#include "PlatformString.h"
+#include <QLocale>
+
+namespace WebCore {
+
+String platformDefaultLanguage()
+{
+ QLocale locale;
+ return locale.name().replace("_", "-");
+}
+
+}
diff --git a/WebCore/platform/win/Language.cpp b/WebCore/platform/win/Language.cpp
deleted file mode 100644
index e0fd206..0000000
--- a/WebCore/platform/win/Language.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2007 Apple 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.
- *
- * 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
- * (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 "Language.h"
-
-#include <wtf/text/StringConcatenate.h>
-
-namespace WebCore {
-
-static String localeInfo(LCTYPE localeType, const String& fallback)
-{
- LANGID langID = GetUserDefaultUILanguage();
- int localeChars = GetLocaleInfo(langID, localeType, 0, 0);
- if (!localeChars)
- return fallback;
- UChar* localeNameBuf;
- String localeName = String::createUninitialized(localeChars, localeNameBuf);
- localeChars = GetLocaleInfo(langID, localeType, localeNameBuf, localeChars);
- if (!localeChars)
- return fallback;
- if (localeName.isEmpty())
- return fallback;
-
- localeName.truncate(localeName.length() - 1);
- return localeName;
-}
-
-String defaultLanguage()
-{
- static String computedDefaultLanguage;
- if (!computedDefaultLanguage.isEmpty())
- return computedDefaultLanguage;
-
- String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en");
- String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String());
-
- if (countryName.isEmpty())
- computedDefaultLanguage = languageName;
- else
- computedDefaultLanguage = makeString(languageName, '-', countryName);
-
- return computedDefaultLanguage;
-}
-
-}
diff --git a/WebCore/platform/win/LanguageWin.cpp b/WebCore/platform/win/LanguageWin.cpp
new file mode 100644
index 0000000..cafda5d
--- /dev/null
+++ b/WebCore/platform/win/LanguageWin.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 Apple 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.
+ *
+ * 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
+ * (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 "Language.h"
+
+#include <wtf/text/StringConcatenate.h>
+
+namespace WebCore {
+
+static String localeInfo(LCTYPE localeType, const String& fallback)
+{
+ LANGID langID = GetUserDefaultUILanguage();
+ int localeChars = GetLocaleInfo(langID, localeType, 0, 0);
+ if (!localeChars)
+ return fallback;
+ UChar* localeNameBuf;
+ String localeName = String::createUninitialized(localeChars, localeNameBuf);
+ localeChars = GetLocaleInfo(langID, localeType, localeNameBuf, localeChars);
+ if (!localeChars)
+ return fallback;
+ if (localeName.isEmpty())
+ return fallback;
+
+ localeName.truncate(localeName.length() - 1);
+ return localeName;
+}
+
+String platformDefaultLanguage()
+{
+ static String computedDefaultLanguage;
+ if (!computedDefaultLanguage.isEmpty())
+ return computedDefaultLanguage;
+
+ String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en");
+ String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String());
+
+ if (countryName.isEmpty())
+ computedDefaultLanguage = languageName;
+ else
+ computedDefaultLanguage = makeString(languageName, '-', countryName);
+
+ return computedDefaultLanguage;
+}
+
+}
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 533e41b..da79307 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,18 @@
+2010-10-19 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Anders Carlsson.
+
+ https://bugs.webkit.org/show_bug.cgi?id=47933
+ <rdar://problem/8494337> navigator.language doesn't work in WebKit2
+
+ * Misc/WebNSUserDefaultsExtras.mm: Moved code for computing default language to WebCore.
+ We need to keep _webkit_preferredLanguageCode for Safari.
+
+ * WebCoreSupport/WebSystemInterface.mm: (InitWebCoreSystemInterface):
+ Initialize wkCopyCFLocalizationPreferredName.
+
+ * WebCoreSupport/WebViewFactory.mm: Removed defaultLanguage. WebCore was the only caller.
+
2010-10-18 Alexey Proskuryakov <ap at apple.com>
Reviewed by David Kilzer.
diff --git a/WebKit/mac/Misc/WebNSUserDefaultsExtras.mm b/WebKit/mac/Misc/WebNSUserDefaultsExtras.mm
index ad76f76..a255935 100644
--- a/WebKit/mac/Misc/WebNSUserDefaultsExtras.mm
+++ b/WebKit/mac/Misc/WebNSUserDefaultsExtras.mm
@@ -28,74 +28,16 @@
#import "WebNSUserDefaultsExtras.h"
-#import "WebNSObjectExtras.h"
-#import <WebKitSystemInterface.h>
-#import <wtf/Assertions.h>
-#import <wtf/MainThread.h>
+#import <WebCore/Language.h>
+#import <wtf/text/WTFString.h>
-static NSString *createHTTPStyleLanguageCode(NSString *languageCode)
-{
- ASSERT(isMainThread());
-
- // Look up the language code using CFBundle.
- NSString *preferredLanguageCode = WebCFAutorelease(WKCopyCFLocalizationPreferredName((CFStringRef)languageCode));
-
- if (preferredLanguageCode)
- languageCode = preferredLanguageCode;
-
- // Make the string lowercase.
- NSString *lowercaseLanguageCode = [languageCode lowercaseString];
-
- // Turn a '_' into a '-' if it appears after a 2-letter language code.
- if ([lowercaseLanguageCode length] < 3 || [lowercaseLanguageCode characterAtIndex:2] != '_')
- return lowercaseLanguageCode;
-
- NSMutableString *result = [lowercaseLanguageCode mutableCopy];
- [result replaceCharactersInRange:NSMakeRange(2, 1) withString:@"-"];
- return result;
-}
+using namespace WebCore;
@implementation NSUserDefaults (WebNSUserDefaultsExtras)
-static NSString *preferredLanguageCode = nil;
-static bool languageChangeObserverAdded = false;
-
-+ (void)_webkit_languagePreferencesDidChange
-{
- ASSERT(isMainThread());
-
- [preferredLanguageCode release];
- preferredLanguageCode = nil;
-}
-
-static void addLanguageChangeObserver(void)
-{
- [[NSDistributedNotificationCenter defaultCenter] addObserver:[NSUserDefaults self]
- selector:@selector(_webkit_languagePreferencesDidChange)
- name:@"AppleLanguagePreferencesChangedNotification"
- object:nil];
-}
-
+ (NSString *)_webkit_preferredLanguageCode
{
- ASSERT(isMainThread());
-
- if (!preferredLanguageCode) {
- NSArray *languages = [[self standardUserDefaults] stringArrayForKey:@"AppleLanguages"];
- if (![languages count])
- preferredLanguageCode = [@"en" retain];
- else
- preferredLanguageCode = createHTTPStyleLanguageCode([languages objectAtIndex:0]);
- }
-
- NSString *code = [[preferredLanguageCode retain] autorelease];
-
- if (!languageChangeObserverAdded) {
- addLanguageChangeObserver();
- languageChangeObserverAdded = true;
- }
-
- return code;
+ return defaultLanguage();
}
@end
diff --git a/WebKit/mac/WebCoreSupport/WebSystemInterface.mm b/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
index 47b16b2..03cb33f 100644
--- a/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
+++ b/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
@@ -44,6 +44,7 @@ void InitWebCoreSystemInterface(void)
INIT(AdvanceDefaultButtonPulseAnimation);
INIT(CGContextGetShouldSmoothFonts);
+ INIT(CopyCFLocalizationPreferredName);
INIT(CopyCONNECTProxyResponse);
INIT(CopyNSURLResponseStatusLine);
INIT(CreateCustomCFReadStream);
diff --git a/WebKit/mac/WebCoreSupport/WebViewFactory.mm b/WebKit/mac/WebCoreSupport/WebViewFactory.mm
index 6c7347f..055e3b4 100644
--- a/WebKit/mac/WebCoreSupport/WebViewFactory.mm
+++ b/WebKit/mac/WebCoreSupport/WebViewFactory.mm
@@ -63,11 +63,6 @@
ASSERT([[self sharedFactory] isKindOfClass:self]);
}
-- (NSString *)defaultLanguageCode
-{
- return [NSUserDefaults _webkit_preferredLanguageCode];
-}
-
- (BOOL)objectIsTextMarker:(id)object
{
return object != nil && CFGetTypeID(object) == WKGetAXTextMarkerTypeID();
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 6d063a8..2ec263b 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2010-10-19 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Anders Carlsson.
+
+ https://bugs.webkit.org/show_bug.cgi?id=47933
+ <rdar://problem/8494337> navigator.language doesn't work in WebKit2
+
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ Pass language code when creating a web process.
+
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::~WebContext): Don't send language change notifications to the destroyed
+ process.
+ (WebKit::languageChanged): Make web process know about the change.
+ (WebKit::WebContext::ensureWebProcess): Fill WebProcessCreationParameters, and register for
+ change notifications.
+
+ * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: (InitWebCoreSystemInterface):
+ Initialize wkCopyCFLocalizationPreferredName.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess): Use passed in language as an override. Web process
+ doesn't know about per-application settings, so it depends on UI process for those.
+ (WebKit::WebProcess::languageChanged): Update the language override when messaged.
+
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+ Added LanguageChanged message.
+
2010-10-19 Anders Carlsson <andersca at apple.com>
Reviewed by Adam Roben.
diff --git a/WebKit2/Shared/WebProcessCreationParameters.cpp b/WebKit2/Shared/WebProcessCreationParameters.cpp
index 3d24fa0..ad30107 100644
--- a/WebKit2/Shared/WebProcessCreationParameters.cpp
+++ b/WebKit2/Shared/WebProcessCreationParameters.cpp
@@ -50,6 +50,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
encoder->encode(static_cast<uint32_t>(cacheModel));
encoder->encode(shouldTrackVisitedLinks);
+ encoder->encode(languageCode);
#if PLATFORM(MAC)
encoder->encode(acceleratedCompositingPort);
@@ -83,6 +84,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
if (!decoder->decode(parameters.shouldTrackVisitedLinks))
return false;
+ if (!decoder->decode(parameters.languageCode))
+ return false;
#if PLATFORM(MAC)
if (!decoder->decode(parameters.acceleratedCompositingPort))
diff --git a/WebKit2/Shared/WebProcessCreationParameters.h b/WebKit2/Shared/WebProcessCreationParameters.h
index b524a81..bb15920 100644
--- a/WebKit2/Shared/WebProcessCreationParameters.h
+++ b/WebKit2/Shared/WebProcessCreationParameters.h
@@ -60,6 +60,8 @@ struct WebProcessCreationParameters {
CacheModel cacheModel;
bool shouldTrackVisitedLinks;
+ String languageCode;
+
#if PLATFORM(MAC)
CoreIPC::MachPort acceleratedCompositingPort;
#elif PLATFORM(WIN)
diff --git a/WebKit2/UIProcess/WebContext.cpp b/WebKit2/UIProcess/WebContext.cpp
index c94c0f3..52a205f 100644
--- a/WebKit2/UIProcess/WebContext.cpp
+++ b/WebKit2/UIProcess/WebContext.cpp
@@ -38,6 +38,7 @@
#include "WebProcessManager.h"
#include "WebProcessMessages.h"
#include "WebProcessProxy.h"
+#include <WebCore/Language.h>
#include <WebCore/LinkHash.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassOwnArrayPtr.h>
@@ -101,7 +102,8 @@ WebContext::~WebContext()
{
ASSERT(m_pageNamespaces.isEmpty());
m_preferences->removeContext(this);
-
+ removeLanguageChangeObserver(this);
+
#ifndef NDEBUG
webContextCounter.decrement();
#endif
@@ -122,6 +124,13 @@ void WebContext::initializeHistoryClient(const WKContextHistoryClient* client)
m_process->send(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()), 0);
}
+static void languageChanged(void* context)
+{
+ WebProcessProxy* process = static_cast<WebContext*>(context)->process();
+ if (process)
+ process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0);
+}
+
void WebContext::ensureWebProcess()
{
if (hasValidProcess())
@@ -150,7 +159,12 @@ void WebContext::ensureWebProcess()
parameters.shouldTrackVisitedLinks = m_historyClient.shouldTrackVisitedLinks();
parameters.cacheModel = m_cacheModel;
-
+
+ parameters.languageCode = defaultLanguage();
+ addLanguageChangeObserver(this, languageChanged);
+
+ parameters.applicationCacheDirectory = applicationCacheDirectory();
+
copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument);
copyToVector(m_schemesToRegisterAsSecure, parameters.urlSchemesRegisteredAsSecure);
copyToVector(m_schemesToSetDomainRelaxationForbiddenFor, parameters.urlSchemesForWhichDomainRelaxationIsForbidden);
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
index d72f378..caff262 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
@@ -36,6 +36,7 @@ void InitWebCoreSystemInterface(void)
dispatch_once(&initOnce, ^{
INIT(AdvanceDefaultButtonPulseAnimation);
+ INIT(CopyCFLocalizationPreferredName);
INIT(CGContextGetShouldSmoothFonts);
INIT(CopyCONNECTProxyResponse);
INIT(CopyNSURLResponseStatusLine);
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 9a7f489..66c697e 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -38,6 +38,7 @@
#include "WebProcessMessages.h"
#include "WebProcessProxyMessageKinds.h"
#include <WebCore/ApplicationCacheStorage.h>
+#include <WebCore/Language.h>
#include <WebCore/Page.h>
#include <WebCore/PageGroup.h>
#include <WebCore/SchemeRegistry.h>
@@ -134,6 +135,9 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
setShouldTrackVisitedLinks(parameters.shouldTrackVisitedLinks);
setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
+ if (!parameters.languageCode.isEmpty())
+ overrideDefaultLanguage(parameters.languageCode);
+
for (size_t i = 0; i < parameters.urlSchemesRegistererdAsEmptyDocument.size(); ++i)
registerURLSchemeAsEmptyDocument(parameters.urlSchemesRegistererdAsEmptyDocument[i]);
@@ -171,6 +175,11 @@ void WebProcess::setDomainRelaxationForbiddenForURLScheme(const String& urlSchem
SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(true, urlScheme);
}
+void WebProcess::languageChanged(const String& language) const
+{
+ overrideDefaultLanguage(language);
+}
+
void WebProcess::setVisitedLinkTable(const SharedMemory::Handle& handle)
{
RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadOnly);
diff --git a/WebKit2/WebProcess/WebProcess.h b/WebKit2/WebProcess/WebProcess.h
index b0d3703..6776d2d 100644
--- a/WebKit2/WebProcess/WebProcess.h
+++ b/WebKit2/WebProcess/WebProcess.h
@@ -92,6 +92,7 @@ private:
void registerURLSchemeAsEmptyDocument(const String&);
void registerURLSchemeAsSecure(const String&) const;
void setDomainRelaxationForbiddenForURLScheme(const String&) const;
+ void languageChanged(const String&) const;
#if PLATFORM(WIN)
void setShouldPaintNativeControls(bool);
#endif
diff --git a/WebKit2/WebProcess/WebProcess.messages.in b/WebKit2/WebProcess/WebProcess.messages.in
index 50b8afb..355e3a9 100644
--- a/WebKit2/WebProcess/WebProcess.messages.in
+++ b/WebKit2/WebProcess/WebProcess.messages.in
@@ -38,6 +38,7 @@ messages -> WebProcess {
RegisterURLSchemeAsEmptyDocument(WTF::String scheme)
RegisterURLSchemeAsSecure(WTF::String scheme)
SetDomainRelaxationForbiddenForURLScheme(WTF::String scheme)
+ LanguageChanged(WTF::String language)
#if PLATFORM(WIN)
SetShouldPaintNativeControls(bool shouldPaintNativeControls)
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list