This commit is contained in:
Cheng Zhao 2013-04-12 09:46:58 +08:00
Родитель 6ef8875b1e
Коммит a915cf2e81
25 изменённых файлов: 3770 добавлений и 3 удалений

3
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,3 @@
.DS_Store
build/
*.xcodeproj

3
.gitmodules поставляемый
Просмотреть файл

@ -1,6 +1,3 @@
[submodule "vendor/ninja"]
path = vendor/ninja
url = https://github.com/martine/ninja.git
[submodule "vendor/brightray"]
path = vendor/brightray
url = git@github.com:aroben/brightray.git

28
LICENSE Normal file
Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

22
README.md Normal file
Просмотреть файл

@ -0,0 +1,22 @@
# Atom Shell
Experimental native layer for the [Atom](https://github.com/github/atom).
## Development
### One-time setup
You must previously have built and uploaded libchromiumcontent using its
`script/upload` script.
$ script/bootstrap http://base.url.com/used/by/script/upload
### Building
$ script/build
This will build the app into the `build` directory.
## License
See the [`LICENSE`](LICENSE) file.

13
app/atom_library_main.cc Normal file
Просмотреть файл

@ -0,0 +1,13 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_library_main.h"
#include "app/atom_main_delegate.h"
#include "content/public/app/content_main.h"
int AtomMain(int argc, const char* argv[]) {
atom::AtomMainDelegate delegate;
return content::ContentMain(argc, argv, &delegate);
}

15
app/atom_library_main.h Normal file
Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_ATOM_LIBRARY_MAIN_
#define ATOM_APP_ATOM_LIBRARY_MAIN_
extern "C" {
__attribute__ ((visibility ("default")))
int AtomMain(int argc, const char* argv[]);
}
#endif // ATOM_APP_ATOM_LIBRARY_MAIN_

9
app/atom_main.cc Normal file
Просмотреть файл

@ -0,0 +1,9 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_library_main.h"
int main(int argc, const char* argv[]) {
return AtomMain(argc, argv);
}

29
app/atom_main_delegate.cc Normal file
Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/atom_main_delegate.h"
#include "browser/atom_browser_client.h"
#include "renderer/atom_renderer_client.h"
namespace atom {
AtomMainDelegate::AtomMainDelegate() {
}
AtomMainDelegate::~AtomMainDelegate() {
}
content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new AtomBrowserClient);
return browser_client_.get();
}
content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() {
renderer_client_.reset(new AtomRendererClient);
return renderer_client_.get();
}
} // namespace atom

30
app/atom_main_delegate.h Normal file
Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_
#define ATOM_APP_ATOM_MAIN_DELEGATE_
#include "brightray/common/main_delegate.h"
namespace atom {
class AtomMainDelegate : public brightray::MainDelegate {
public:
AtomMainDelegate();
~AtomMainDelegate();
private:
virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
virtual content::ContentRendererClient*
CreateContentRendererClient() OVERRIDE;
scoped_ptr<content::ContentBrowserClient> browser_client_;
scoped_ptr<content::ContentRendererClient> renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate);
};
} // namespace atom
#endif // ATOM_APP_ATOM_MAIN_DELEGATE_

165
atom.gyp Normal file
Просмотреть файл

@ -0,0 +1,165 @@
{
'variables': {
'project_name': 'atom',
'product_name': 'Atom',
'app_sources': [
'app/atom_main.cc',
],
'lib_sources': [
'app/atom_main_delegate.cc',
'app/atom_main_delegate.h',
'browser/atom_browser_client.cc',
'browser/atom_browser_client.h',
'browser/atom_browser_main_parts.cc',
'browser/atom_browser_main_parts.h',
'browser/atom_browser_main_parts_mac.mm',
'renderer/atom_render_view_observer.cc',
'renderer/atom_render_view_observer.h',
'renderer/atom_renderer_client.cc',
'renderer/atom_renderer_client.h',
],
'framework_sources': [
'app/atom_library_main.cc',
'app/atom_library_main.h',
],
},
'includes': [
'vendor/brightray/brightray.gypi',
],
'targets': [
{
'target_name': '<(project_name)',
'type': 'executable',
'dependencies': [
'<(project_name)_lib',
],
'sources': [
'<@(app_sources)',
],
'include_dirs': [
'.',
],
'conditions': [
['OS=="mac"', {
'product_name': '<(product_name)',
'mac_bundle': 1,
'dependencies!': [
'<(project_name)_lib',
],
'dependencies': [
'<(project_name)_framework',
'<(project_name)_helper',
],
'xcode_settings': {
'INFOPLIST_FILE': 'browser/mac/Info.plist',
'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../Frameworks',
},
'copies': [
{
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks',
'files': [
'<(PRODUCT_DIR)/<(product_name) Helper.app',
'<(PRODUCT_DIR)/<(product_name).framework',
],
},
],
'postbuilds': [
{
# This postbuid step is responsible for creating the following
# helpers:
#
# <(product_name) EH.app and <(product_name) NP.app are created
# from <(product_name).app.
#
# The EH helper is marked for an executable heap. The NP helper
# is marked for no PIE (ASLR).
'postbuild_name': 'Make More Helpers',
'action': [
'vendor/brightray/tools/mac/make_more_helpers.sh',
'Frameworks',
'<(product_name)',
],
},
]
}],
],
},
{
'target_name': '<(project_name)_lib',
'type': 'static_library',
'dependencies': [
'vendor/brightray/brightray.gyp:brightray',
],
'sources': [
'<@(lib_sources)',
],
'include_dirs': [
'.',
'vendor',
],
},
],
'conditions': [
['OS=="mac"', {
'targets': [
{
'target_name': '<(project_name)_framework',
'product_name': '<(product_name)',
'type': 'shared_library',
'dependencies': [
'<(project_name)_lib',
],
'sources': [
'<@(framework_sources)',
],
'include_dirs': [
'.',
'vendor',
'<(libchromiumcontent_include_dir)',
],
'mac_bundle': 1,
'mac_bundle_resources': [
'browser/mac/MainMenu.xib',
'<(libchromiumcontent_resources_dir)/content_shell.pak',
],
'xcode_settings': {
'LIBRARY_SEARCH_PATHS': '<(libchromiumcontent_library_dir)',
'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name).framework/<(product_name)',
'LD_RUNPATH_SEARCH_PATHS': '@loader_path/Libraries',
'OTHER_LDFLAGS': [
'-ObjC',
],
},
'copies': [
{
'destination': '<(PRODUCT_DIR)/<(product_name).framework/Versions/A/Libraries',
'files': [
'<(libchromiumcontent_library_dir)/ffmpegsumo.so',
'<(libchromiumcontent_library_dir)/libchromiumcontent.dylib',
],
},
],
},
{
'target_name': '<(project_name)_helper',
'product_name': '<(product_name) Helper',
'type': 'executable',
'dependencies': [
'<(project_name)_framework',
],
'sources': [
'<@(app_sources)',
],
'include_dirs': [
'.',
],
'mac_bundle': 1,
'xcode_settings': {
'INFOPLIST_FILE': 'renderer/mac/Info.plist',
'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../../../../Frameworks',
},
},
],
}],
],
}

Просмотреть файл

@ -0,0 +1,22 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_client.h"
#include "browser/atom_browser_main_parts.h"
namespace atom {
AtomBrowserClient::AtomBrowserClient() {
}
AtomBrowserClient::~AtomBrowserClient() {
}
brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) {
return new AtomBrowserMainParts;
}
} // namespace atom

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_CLIENT_
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_
#include "brightray/browser/browser_client.h"
namespace atom {
class AtomBrowserClient : public brightray::BrowserClient {
public:
AtomBrowserClient();
~AtomBrowserClient();
private:
virtual brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_CLIENT_

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_main_parts.h"
namespace atom {
AtomBrowserMainParts::AtomBrowserMainParts() {
}
AtomBrowserMainParts::~AtomBrowserMainParts() {
}
} // namespace atom

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#include "brightray/browser/browser_main_parts.h"
namespace atom {
class AtomBrowserMainParts : public brightray::BrowserMainParts {
public:
AtomBrowserMainParts();
~AtomBrowserMainParts();
protected:
virtual void PreMainMessageLoopRun() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_

Просмотреть файл

@ -0,0 +1,51 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_browser_main_parts.h"
#import <AppKit/AppKit.h>
#include "brightray/browser/browser_context.h"
#include "brightray/browser/default_web_contents_delegate.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
namespace atom {
void AtomBrowserMainParts::PreMainMessageLoopRun() {
brightray::BrowserMainParts::PreMainMessageLoopRun();
auto contentRect = NSMakeRect(0, 0, 800, 600);
auto styleMask = NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask;
auto window = [[NSWindow alloc] initWithContentRect:contentRect
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:YES];
window.title = @"Atom";
// FIXME: We're leaking this object (see #3).
auto contents = brightray::InspectableWebContents::Create(content::WebContents::CreateParams(browser_context()));
// FIXME: And this one!
contents->GetWebContents()->SetDelegate(
new brightray::DefaultWebContentsDelegate());
auto contentsView = contents->GetView()->GetNativeView();
contentsView.frame = [window.contentView bounds];
contentsView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[window.contentView addSubview:contentsView];
[window makeFirstResponder:contentsView];
[window makeKeyAndOrderFront:nil];
contents->GetWebContents()->GetController().LoadURL(
GURL("http://adam.roben.org/brightray_example/start.html"),
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
}
} // namespace atom

14
browser/mac/Info.plist Normal file
Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.github.atom</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>BRYApplication</string>
</dict>
</plist>

3148
browser/mac/MainMenu.xib Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "renderer/atom_render_view_observer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "v8/include/v8.h"
namespace atom {
AtomRenderViewObserver::AtomRenderViewObserver(
content::RenderView *render_view)
: content::RenderViewObserver(render_view) {
}
AtomRenderViewObserver::~AtomRenderViewObserver() {
}
void AtomRenderViewObserver::DidClearWindowObject(WebKit::WebFrame* frame) {
}
} // namespace atom

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_
#include "content/public/renderer/render_view_observer.h"
namespace atom {
class AtomRenderViewObserver : content::RenderViewObserver {
public:
explicit AtomRenderViewObserver(content::RenderView*);
private:
~AtomRenderViewObserver();
virtual void DidClearWindowObject(WebKit::WebFrame*) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
};
} // namespace atom
#endif // ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "renderer/atom_renderer_client.h"
#include "renderer/atom_render_view_observer.h"
namespace atom {
AtomRendererClient::AtomRendererClient() {
}
AtomRendererClient::~AtomRendererClient() {
}
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
new AtomRenderViewObserver(render_view);
}
} // namespace atom

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_ATOM_RENDERER_CLIENT_
#define ATOM_RENDERER_ATOM_RENDERER_CLIENT_
#include "content/public/renderer/content_renderer_client.h"
namespace atom {
class AtomRendererClient : public content::ContentRendererClient {
public:
AtomRendererClient();
~AtomRendererClient();
private:
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
};
} // namespace atom
#endif // ATOM_RENDERER_ATOM_RENDERER_CLIENT_

12
renderer/mac/Info.plist Normal file
Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.github.atom.helper</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>

28
script/bootstrap Executable file
Просмотреть файл

@ -0,0 +1,28 @@
#!/bin/sh
#/ Usage: bootstrap https://base.url.com/from/libchromiumcontent/script/upload
#/ Bootstrap this project.
set -e
usage() {
grep '^#/' <"$0"| cut -c4-
}
BASE_URL="${1}"
if [ -z "${BASE_URL}" ]; then
usage
exit 1
fi
cd "$(dirname "$0")/.."
SOURCE_ROOT=$(pwd -P)
VENDOR_DIR="${SOURCE_ROOT}/vendor"
BRIGHTRAY_DIR="${VENDOR_DIR}/brightray"
git submodule sync --quiet
git submodule update --init --recursive
"${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}"
"${SOURCE_ROOT}/script/update"

12
script/build Executable file
Просмотреть файл

@ -0,0 +1,12 @@
#!/bin/sh
set -e
MODE=Release
if [ ! -z $1 ]; then
MODE=$1
fi
cd "$(dirname "$0")/.."
xcodebuild -configuration ${MODE} -target atom

7
script/update Executable file
Просмотреть файл

@ -0,0 +1,7 @@
#!/bin/sh
set -e
cd "$(dirname "$0")/.."
gyp --depth . atom.gyp