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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 9379002: Move socket API restriction check to browser process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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 | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index da011198b3138690bcbaed4936b38916d398b4cc..f4406908af0107f904b8d831ad34c8100842f0fa 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/string_tokenizer.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/breakpad_mac.h"
#include "chrome/browser/browser_about_handler.h"
@@ -137,6 +138,11 @@ using content::WebContents;
namespace {
+const char* kPredefinedAllowedSocketOrigins[] = {
+ "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
+ "pnhechapfaindjhompbnflcldabbghjo" // HTerm App (SSH Client)
+};
+
// Handles rewriting Web UI URLs.
bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
@@ -269,6 +275,24 @@ void FillFontFamilyMap(const PrefService* prefs,
namespace chrome {
+ChromeContentBrowserClient::ChromeContentBrowserClient() {
+ for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
+ allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string allowed_list =
+ command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI);
+ if (!allowed_list.empty()) {
+ StringTokenizer t(allowed_list, ",");
+ while (t.GetNext()) {
+ allowed_socket_origins_.insert(t.token());
+ }
+ }
+}
+
+ChromeContentBrowserClient::~ChromeContentBrowserClient() {
+}
+
content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
ChromeBrowserMainParts* main_parts;
@@ -640,7 +664,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
static const char* const kSwitchNames[] = {
switches::kAllowHTTPBackgroundPage,
switches::kAllowLegacyExtensionManifests,
- switches::kAllowNaClSocketAPI,
switches::kAllowScriptingGallery,
switches::kAppsCheckoutURL,
switches::kAppsGalleryURL,
@@ -1310,6 +1333,11 @@ std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
}
+bool ChromeContentBrowserClient::AllowSocketAPI(const GURL& url) {
+ return url.is_valid() &&
+ allowed_socket_origins_.find(url.host()) != allowed_socket_origins_.end();
+}
+
#if defined(OS_POSIX) && !defined(OS_MACOSX)
int ChromeContentBrowserClient::GetCrashSignalFD(
const CommandLine& command_line) {
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698