Browse Source

Make "chrome-extension" a standard scheme.

If we do not do so, urls like "chrome-extension://extension-1" will
never get a hostname.
Cheng Zhao 10 years ago
parent
commit
b80f109524

+ 2 - 0
atom.gyp

@@ -47,6 +47,8 @@
       'atom/renderer/api/lib/web-view.coffee',
     ],
     'lib_sources': [
+      'atom/app/atom_content_client.cc',
+      'atom/app/atom_content_client.h',
       'atom/app/atom_main_delegate.cc',
       'atom/app/atom_main_delegate.h',
       'atom/app/atom_main_delegate_mac.mm',

+ 21 - 0
atom/app/atom_content_client.cc

@@ -0,0 +1,21 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/app/atom_content_client.h"
+
+namespace atom {
+
+AtomContentClient::AtomContentClient() {
+}
+
+AtomContentClient::~AtomContentClient() {
+}
+
+void AtomContentClient::AddAdditionalSchemes(
+    std::vector<std::string>* standard_schemes,
+    std::vector<std::string>* savable_schemes) {
+  standard_schemes->push_back("chrome-extension");
+}
+
+}  // namespace atom

+ 29 - 0
atom/app/atom_content_client.h

@@ -0,0 +1,29 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_APP_ATOM_CONTENT_CLIENT_H_
+#define ATOM_APP_ATOM_CONTENT_CLIENT_H_
+
+#include "brightray/common/content_client.h"
+
+namespace atom {
+
+class AtomContentClient : public brightray::ContentClient {
+ public:
+  AtomContentClient();
+  virtual ~AtomContentClient();
+
+ protected:
+  // content::ContentClient:
+  virtual void AddAdditionalSchemes(
+      std::vector<std::string>* standard_schemes,
+      std::vector<std::string>* savable_schemes) OVERRIDE;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
+};
+
+}  // namespace atom
+
+#endif  // ATOM_APP_ATOM_CONTENT_CLIENT_H_

+ 17 - 12
atom/app/atom_main_delegate.cc

@@ -6,6 +6,7 @@
 
 #include <string>
 
+#include "atom/app/atom_content_client.h"
 #include "atom/browser/atom_browser_client.h"
 #include "atom/renderer/atom_renderer_client.h"
 #include "base/command_line.h"
@@ -22,18 +23,6 @@ AtomMainDelegate::AtomMainDelegate() {
 AtomMainDelegate::~AtomMainDelegate() {
 }
 
-void AtomMainDelegate::AddDataPackFromPath(
-    ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {
-#if defined(OS_WIN)
-  bundle->AddDataPackFromPath(
-      pak_dir.Append(FILE_PATH_LITERAL("ui_resources_200_percent.pak")),
-      ui::SCALE_FACTOR_200P);
-  bundle->AddDataPackFromPath(
-      pak_dir.Append(FILE_PATH_LITERAL("webkit_resources_200_percent.pak")),
-      ui::SCALE_FACTOR_200P);
-#endif
-}
-
 bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
   // Disable logging out to debug.log on Windows
 #if defined(OS_WIN)
@@ -99,4 +88,20 @@ content::ContentRendererClient*
   return renderer_client_.get();
 }
 
+scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
+  return scoped_ptr<brightray::ContentClient>(new AtomContentClient).Pass();
+}
+
+void AtomMainDelegate::AddDataPackFromPath(
+    ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {
+#if defined(OS_WIN)
+  bundle->AddDataPackFromPath(
+      pak_dir.Append(FILE_PATH_LITERAL("ui_resources_200_percent.pak")),
+      ui::SCALE_FACTOR_200P);
+  bundle->AddDataPackFromPath(
+      pak_dir.Append(FILE_PATH_LITERAL("webkit_resources_200_percent.pak")),
+      ui::SCALE_FACTOR_200P);
+#endif
+}
+
 }  // namespace atom

+ 7 - 8
atom/app/atom_main_delegate.h

@@ -16,24 +16,23 @@ class AtomMainDelegate : public brightray::MainDelegate {
   ~AtomMainDelegate();
 
  protected:
-  // brightray::MainDelegate:
-  virtual void AddDataPackFromPath(
-      ui::ResourceBundle* bundle, const base::FilePath& pak_dir) OVERRIDE;
-
   // content::ContentMainDelegate:
   virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
   virtual void PreSandboxStartup() OVERRIDE;
+  virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
+  virtual content::ContentRendererClient*
+      CreateContentRendererClient() OVERRIDE;
 
+  // brightray::MainDelegate:
+  virtual scoped_ptr<brightray::ContentClient> CreateContentClient() OVERRIDE;
+  virtual void AddDataPackFromPath(
+      ui::ResourceBundle* bundle, const base::FilePath& pak_dir) OVERRIDE;
 #if defined(OS_MACOSX)
   virtual void OverrideChildProcessPath() OVERRIDE;
   virtual void OverrideFrameworkBundlePath() OVERRIDE;
 #endif
 
  private:
-  virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
-  virtual content::ContentRendererClient*
-      CreateContentRendererClient() OVERRIDE;
-
   brightray::ContentClient content_client_;
   scoped_ptr<content::ContentBrowserClient> browser_client_;
   scoped_ptr<content::ContentRendererClient> renderer_client_;