Make "chrome-extension" a standard scheme.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 27 Aug 2014 12:48:49 +0000 (20:48 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 27 Aug 2014 12:48:49 +0000 (20:48 +0800)
If we do not do so, urls like "chrome-extension://extension-1" will
never get a hostname.

atom.gyp
atom/app/atom_content_client.cc [new file with mode: 0644]
atom/app/atom_content_client.h [new file with mode: 0644]
atom/app/atom_main_delegate.cc
atom/app/atom_main_delegate.h

index 21284c5..36fe2f0 100644 (file)
--- a/atom.gyp
+++ b/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',
diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc
new file mode 100644 (file)
index 0000000..6f7a4e2
--- /dev/null
@@ -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
diff --git a/atom/app/atom_content_client.h b/atom/app/atom_content_client.h
new file mode 100644 (file)
index 0000000..8982844
--- /dev/null
@@ -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_
index e8dbd0b..f754a1b 100644 (file)
@@ -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
index 72bc0f7..4afbf84 100644 (file)
@@ -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_;