Skip to content

Commit 4904459

Browse files
authored
browser(webkit): introduce Browser.setLanguage (#781)
1 parent c57fd22 commit 4904459

File tree

2 files changed

+60
-9
lines changed

2 files changed

+60
-9
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1128
1+
1129

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ index 1eb7abb2fa21d7a8ec0833160f53e5c523ec4317..7709bcc2ec69aab0589ca1b954db1fb2
359359
FrontendChannel::ConnectionType connectionType() const;
360360
diff --git a/Source/JavaScriptCore/inspector/protocol/Browser.json b/Source/JavaScriptCore/inspector/protocol/Browser.json
361361
new file mode 100644
362-
index 0000000000000000000000000000000000000000..b9ac6ebfb1ba16f83663f3fbe29e619ba2befe13
362+
index 0000000000000000000000000000000000000000..efd406f0a6b7aa0e1e484665cbe863f1233524dd
363363
--- /dev/null
364364
+++ b/Source/JavaScriptCore/inspector/protocol/Browser.json
365-
@@ -0,0 +1,202 @@
365+
@@ -0,0 +1,210 @@
366366
+{
367367
+ "domain": "Browser",
368368
+ "availability": ["web"],
@@ -539,6 +539,14 @@ index 0000000000000000000000000000000000000000..b9ac6ebfb1ba16f83663f3fbe29e619b
539539
+ { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
540540
+ ],
541541
+ "description": "Clears permission overrides."
542+
+ },
543+
+ {
544+
+ "name": "setLanguage",
545+
+ "description": "Allows to set locale language for context.",
546+
+ "parameters": [
547+
+ { "name": "language", "type": "string" },
548+
+ { "name": "browserContextId", "$ref": "ContextID", "optional": true, "description": "Browser context id." }
549+
+ ]
542550
+ }
543551
+ ],
544552
+ "events": [
@@ -7371,10 +7379,10 @@ index 78caedf0c0ce83675569502d150fcc44e5f9868c..46b9901263286eab6de0bc4f899349d5
73717379
} // namespace WebKit
73727380
diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp b/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp
73737381
new file mode 100644
7374-
index 0000000000000000000000000000000000000000..d8dbb6391594955a23a5ed3cb34b05ca0b47acc1
7382+
index 0000000000000000000000000000000000000000..3a945691c06155bdcfe8d6928447c3dcb047f686
73757383
--- /dev/null
73767384
+++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.cpp
7377-
@@ -0,0 +1,497 @@
7385+
@@ -0,0 +1,505 @@
73787386
+/*
73797387
+ * Copyright (C) 2019 Microsoft Corporation.
73807388
+ *
@@ -7812,6 +7820,14 @@ index 0000000000000000000000000000000000000000..d8dbb6391594955a23a5ed3cb34b05ca
78127820
+ }
78137821
+}
78147822
+
7823+
+void InspectorBrowserAgent::setLanguage(Inspector::ErrorString& errorString, const String& language, const String* browserContextID)
7824+
+{
7825+
+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);
7826+
+ if (!errorString.isEmpty())
7827+
+ return;
7828+
+ browserContext.processPool->setLanguageForAutomation(language);
7829+
+}
7830+
+
78157831
+void InspectorBrowserAgent::setGeolocationOverride(Inspector::ErrorString& errorString, const String* browserContextID, const JSON::Object* geolocation)
78167832
+{
78177833
+ BrowserContext browserContext = lookupBrowserContext(errorString, browserContextID);
@@ -7874,10 +7890,10 @@ index 0000000000000000000000000000000000000000..d8dbb6391594955a23a5ed3cb34b05ca
78747890
+#endif // ENABLE(REMOTE_INSPECTOR)
78757891
diff --git a/Source/WebKit/UIProcess/InspectorBrowserAgent.h b/Source/WebKit/UIProcess/InspectorBrowserAgent.h
78767892
new file mode 100644
7877-
index 0000000000000000000000000000000000000000..8f224acabb5b2010368f25b9b6d5ca0a3b75cd0b
7893+
index 0000000000000000000000000000000000000000..87951616c1ad9afbaf645a7ef164df4c93c53f27
78787894
--- /dev/null
78797895
+++ b/Source/WebKit/UIProcess/InspectorBrowserAgent.h
7880-
@@ -0,0 +1,113 @@
7896+
@@ -0,0 +1,114 @@
78817897
+/*
78827898
+ * Copyright (C) 2019 Microsoft Corporation.
78837899
+ *
@@ -7970,6 +7986,7 @@ index 0000000000000000000000000000000000000000..8f224acabb5b2010368f25b9b6d5ca0a
79707986
+ void grantPermissions(Inspector::ErrorString&, const String* browserContextID, const String& origin, const JSON::Array& permissions) override;
79717987
+ void resetPermissions(Inspector::ErrorString&, const String* browserContextID) override;
79727988
+ void setGeolocationOverride(Inspector::ErrorString&, const String* browserContextID, const JSON::Object* geolocation) override;
7989+
+ void setLanguage(Inspector::ErrorString&, const String& language, const String* browserContextID) override;
79737990
+
79747991
+ static String toBrowserContextIDProtocolString(const PAL::SessionID&);
79757992
+ static String toPageProxyIDProtocolString(const WebPageProxy&);
@@ -9357,8 +9374,25 @@ index a6d4c6173b0fd75a5f507e44f60f7dfd14f433b4..d2721d8356841fd5b3b16c808c35522d
93579374

93589375
#if ENABLE(NETSCAPE_PLUGIN_API)
93599376
UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
9377+
diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp
9378+
index e1ce3a17d5c6d38a12e54cc1f45f951c16b290d6..de49f636874949990ffba16fc8c8bc8e8b9e7efb 100644
9379+
--- a/Source/WebKit/UIProcess/WebProcessPool.cpp
9380+
+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp
9381+
@@ -987,7 +987,11 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
9382+
#endif
9383+
9384+
parameters.cacheModel = LegacyGlobalSettings::singleton().cacheModel();
9385+
- parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
9386+
+ if (m_languageForAutomation.isNull()) {
9387+
+ parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
9388+
+ } else {
9389+
+ parameters.languages.append(m_languageForAutomation);
9390+
+ }
9391+
9392+
parameters.urlSchemesRegisteredAsEmptyDocument = copyToVector(m_schemesToRegisterAsEmptyDocument);
9393+
parameters.urlSchemesRegisteredAsSecure = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsSecure());
93609394
diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h
9361-
index 64b1dbce4c907536999b1c2a5eb314670f423e1e..e86d634f64fdaa0fd4a9338ffba566bf7209e02d 100644
9395+
index 64b1dbce4c907536999b1c2a5eb314670f423e1e..b9297305dab1d5001ee184747d58bd8b4999ac84 100644
93629396
--- a/Source/WebKit/UIProcess/WebProcessPool.h
93639397
+++ b/Source/WebKit/UIProcess/WebProcessPool.h
93649398
@@ -416,7 +416,7 @@ public:
@@ -9370,7 +9404,24 @@ index 64b1dbce4c907536999b1c2a5eb314670f423e1e..e86d634f64fdaa0fd4a9338ffba566bf
93709404
void setIgnoreTLSErrors(bool);
93719405
bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
93729406
#endif
9373-
@@ -711,8 +711,8 @@ private:
9407+
@@ -537,6 +537,8 @@ public:
9408+
9409+
PlugInAutoStartProvider& plugInAutoStartProvider() { return m_plugInAutoStartProvider; }
9410+
9411+
+ void setLanguageForAutomation(const String& language) { m_languageForAutomation = language; }
9412+
+
9413+
void setUseSeparateServiceWorkerProcess(bool);
9414+
bool useSeparateServiceWorkerProcess() const { return m_useSeparateServiceWorkerProcess; }
9415+
9416+
@@ -642,6 +644,7 @@ private:
9417+
std::unique_ptr<API::CustomProtocolManagerClient> m_customProtocolManagerClient;
9418+
9419+
RefPtr<WebAutomationSession> m_automationSession;
9420+
+ String m_languageForAutomation;
9421+
9422+
#if ENABLE(NETSCAPE_PLUGIN_API)
9423+
PluginInfoStore m_pluginInfoStore;
9424+
@@ -711,8 +714,8 @@ private:
93749425
HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
93759426
HashMap<uint64_t, RefPtr<StatisticsRequest>> m_statisticsRequests;
93769427

0 commit comments

Comments
 (0)