Commit 7e30c90e authored by paritosh.in's avatar paritosh.in Committed by Commit bot

Fix to respect --explicitly-allowed-ports command line option-Chromium Side

[PATCH 1] : This Patch
[PATCH 2] : https://codereview.chromium.org/908483002/

BUG=223927

Review URL: https://codereview.chromium.org/1036823003

Cr-Commit-Position: refs/heads/master@{#325263}
parent 46dec115
......@@ -65,6 +65,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/switches.h"
#include "net/base/net_util.h"
......
......@@ -593,10 +593,6 @@ const char kEnableWebsiteSettingsManager[] = "enable-website-settings-manager";
// Enables synchronizing WiFi credentials across devices, using Chrome Sync.
const char kEnableWifiCredentialSync[] = "enable-wifi-credential-sync";
// Explicitly allows additional ports using a comma-separated list of port
// numbers.
const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
// Values for the kExtensionContentVerification flag.
// See ContentVerifierDelegate::Mode for more explanation.
const char kExtensionContentVerificationBootstrap[] = "bootstrap";
......
......@@ -174,7 +174,6 @@ extern const char kEnableWebAppFrame[];
extern const char kEnableWebsiteSettingsManager[];
extern const char kEnableWifiCredentialSync[];
extern const char kEnhancedBookmarksExperiment[];
extern const char kExplicitlyAllowedPorts[];
extern const char kExtensionContentVerificationBootstrap[];
extern const char kExtensionContentVerificationEnforceStrict[];
extern const char kExtensionContentVerificationEnforce[];
......
......@@ -1299,6 +1299,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kEnableVtune,
switches::kEnableWebGLDraftExtensions,
switches::kEnableWebGLImageChromium,
switches::kExplicitlyAllowedPorts,
switches::kForceDeviceScaleFactor,
switches::kForceDisplayList2dCanvas,
switches::kFullMemoryCrashReport,
......
......@@ -505,6 +505,18 @@ bool BlinkPlatformImpl::isReservedIPAddress(
return net::IsIPAddressReserved(address);
}
bool BlinkPlatformImpl::portAllowed(const blink::WebURL& url) const {
GURL gurl = GURL(url);
if (!gurl.has_port())
return true;
int port = gurl.IntPort();
if (net::IsPortAllowedByOverride(port))
return true;
if (gurl.SchemeIs("ftp"))
return net::IsPortAllowedByFtp(port);
return net::IsPortAllowedByDefault(port);
}
blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
WebThreadImplForWorkerScheduler* thread =
new WebThreadImplForWorkerScheduler(name);
......
......@@ -86,6 +86,7 @@ class CONTENT_EXPORT BlinkPlatformImpl
blink::WebString& charset);
virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
virtual bool isReservedIPAddress(const blink::WebString& host) const;
virtual bool portAllowed(const blink::WebURL& url) const;
virtual blink::WebThread* createThread(const char* name);
virtual blink::WebThread* currentThread();
virtual void yieldCurrentThread();
......
......@@ -120,4 +120,16 @@ TEST(BlinkPlatformTest, IsReservedIPAddress) {
}
}
TEST(BlinkPlatformTest, portAllowed) {
TestBlinkPlatformImpl platform_impl;
EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com")));
EXPECT_TRUE(platform_impl.portAllowed(GURL("file://example.com")));
EXPECT_TRUE(platform_impl.portAllowed(GURL("file://example.com:87")));
EXPECT_TRUE(platform_impl.portAllowed(GURL("ftp://example.com:21")));
EXPECT_FALSE(platform_impl.portAllowed(GURL("ftp://example.com:87")));
EXPECT_FALSE(platform_impl.portAllowed(GURL("ws://example.com:21")));
EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:80")));
EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:8889")));
}
} // namespace content
......@@ -512,6 +512,10 @@ const char kEnableWebGLImageChromium[] = "enable-webgl-image-chromium";
// Enable rasterizer that writes directly to GPU memory associated with tiles.
const char kEnableZeroCopy[] = "enable-zero-copy";
// Explicitly allows additional ports using a comma-separated list of port
// numbers.
const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
// Load NPAPI plugins from the specified directory.
const char kExtraPluginDir[] = "extra-plugin-dir";
......
......@@ -147,6 +147,7 @@ CONTENT_EXPORT extern const char kEnableVtune[];
CONTENT_EXPORT extern const char kEnableWebGLDraftExtensions[];
CONTENT_EXPORT extern const char kEnableWebGLImageChromium[];
CONTENT_EXPORT extern const char kEnableZeroCopy[];
CONTENT_EXPORT extern const char kExplicitlyAllowedPorts[];
CONTENT_EXPORT extern const char kExtraPluginDir[];
CONTENT_EXPORT extern const char kForceDisplayList2dCanvas[];
CONTENT_EXPORT extern const char kForceFieldTrials[];
......
......@@ -1135,6 +1135,12 @@ void RenderThreadImpl::EnsureWebKitInitialized() {
memory_observer_.reset(new MemoryObserver());
message_loop()->AddTaskObserver(memory_observer_.get());
}
if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) {
std::string allowed_ports =
command_line.GetSwitchValueASCII(switches::kExplicitlyAllowedPorts);
net::SetExplicitlyAllowedPorts(allowed_ports);
}
}
void RenderThreadImpl::RegisterSchemes() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment