add {secure:} opt to protocol.registerStandardSchemes
authorPaul Frazee <pfrazee@gmail.com>
Fri, 11 Nov 2016 19:10:54 +0000 (13:10 -0600)
committerKevin Sawicki <kevinsawicki@gmail.com>
Mon, 12 Dec 2016 20:49:57 +0000 (12:49 -0800)
atom/app/atom_content_client.cc
atom/app/atom_content_client.h
atom/browser/api/atom_api_protocol.cc
atom/browser/api/atom_api_protocol.h
atom/common/options_switches.cc
atom/common/options_switches.h

index 40a6e1f..f1528b0 100644 (file)
@@ -204,4 +204,18 @@ void AtomContentClient::AddServiceWorkerSchemes(
   service_worker_schemes->insert(url::kFileScheme);
 }
 
+void AtomContentClient::AddSecureSchemesAndOrigins(
+    std::set<std::string>* secure_schemes,
+    std::set<GURL>* secure_origins) {
+  std::vector<std::string> schemes;
+  ConvertStringWithSeparatorToVector(&schemes, ",",
+                                     switches::kRegisterSecureSchemes);                        
+  if (!schemes.empty()) {
+    for (const std::string& scheme : schemes) {
+      secure_schemes->insert(scheme);
+    }
+  }
+}
+
+
 }  // namespace atom
index f31a146..e396dc2 100644 (file)
@@ -31,6 +31,9 @@ class AtomContentClient : public brightray::ContentClient {
       std::vector<content::PepperPluginInfo>* plugins) override;
   void AddServiceWorkerSchemes(
       std::set<std::string>* service_worker_schemes) override;
+  void AddSecureSchemesAndOrigins(
+      std::set<std::string>* secure_schemes,
+      std::set<GURL>* secure_origins) override;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
index fd24850..33ad0cb 100644 (file)
@@ -46,7 +46,7 @@ std::vector<std::string> GetStandardSchemes() {
   return g_standard_schemes;
 }
 
-void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
+void RegisterStandardSchemes(const std::vector<std::string>& schemes, mate::Arguments* args) {
   g_standard_schemes = schemes;
 
   auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
@@ -55,8 +55,17 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
     policy->RegisterWebSafeScheme(scheme);
   }
 
+  // add switches to register as standard
   base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
       atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
+
+  mate::Dictionary opts;
+  bool secure = false;
+  if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
+    // add switches to register as secure
+    base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      atom::switches::kRegisterSecureSchemes, base::JoinString(schemes, ","));
+  }
 }
 
 Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
@@ -220,7 +229,7 @@ void RegisterStandardSchemes(
     return;
   }
 
-  atom::api::RegisterStandardSchemes(schemes);
+  atom::api::RegisterStandardSchemes(schemes, args);
 }
 
 void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
index 3ad039c..bfbf998 100644 (file)
@@ -29,7 +29,7 @@ namespace atom {
 namespace api {
 
 std::vector<std::string> GetStandardSchemes();
-void RegisterStandardSchemes(const std::vector<std::string>& schemes);
+void RegisterStandardSchemes(const std::vector<std::string>& schemes, mate::Arguments* args);
 
 class Protocol : public mate::TrackableObject<Protocol> {
  public:
index 70aeccf..12e097a 100644 (file)
@@ -144,6 +144,9 @@ const char kStandardSchemes[] = "standard-schemes";
 // Register schemes to handle service worker.
 const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes";
 
+// Register schemes as secure.
+const char kRegisterSecureSchemes[] = "register-secure-schemes";
+
 // The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that
 // TLS fallback will accept.
 const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min";
index 3c9abeb..4ca7f61 100644 (file)
@@ -76,6 +76,7 @@ extern const char kPpapiFlashVersion[];
 extern const char kDisableHttpCache[];
 extern const char kStandardSchemes[];
 extern const char kRegisterServiceWorkerSchemes[];
+extern const char kRegisterSecureSchemes[];
 extern const char kSSLVersionFallbackMin[];
 extern const char kCipherSuiteBlacklist[];
 extern const char kAppUserModelId[];