2013-04-12 01:46:58 +00:00
|
|
|
// 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"
|
|
|
|
|
2013-04-12 07:57:17 +00:00
|
|
|
#include "base/values.h"
|
2013-04-14 07:36:48 +00:00
|
|
|
#include "browser/api/atom_bindings.h"
|
2013-04-15 16:25:08 +00:00
|
|
|
#include "browser/atom_browser_context.h"
|
2013-04-12 07:57:17 +00:00
|
|
|
#include "browser/native_window.h"
|
|
|
|
#include "brightray/browser/browser_context.h"
|
|
|
|
#include "brightray/browser/inspectable_web_contents.h"
|
|
|
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
2013-04-13 10:39:09 +00:00
|
|
|
#include "common/node_bindings.h"
|
2013-04-14 07:36:48 +00:00
|
|
|
#include "vendor/node/src/node_internals.h"
|
2013-04-12 07:57:17 +00:00
|
|
|
|
2013-04-12 01:46:58 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2013-04-13 10:39:09 +00:00
|
|
|
AtomBrowserMainParts::AtomBrowserMainParts()
|
2013-04-14 07:36:48 +00:00
|
|
|
: atom_bindings_(new AtomBindings),
|
|
|
|
node_bindings_(NodeBindings::Create(true)) {
|
2013-04-12 01:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
|
|
|
}
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() {
|
|
|
|
return new AtomBrowserContext();
|
|
|
|
}
|
|
|
|
|
2013-04-13 10:39:09 +00:00
|
|
|
void AtomBrowserMainParts::PostEarlyInitialization() {
|
2013-04-13 15:05:13 +00:00
|
|
|
brightray::BrowserMainParts::PostEarlyInitialization();
|
|
|
|
|
2013-04-13 10:39:09 +00:00
|
|
|
node_bindings_->Initialize();
|
2013-04-14 07:36:48 +00:00
|
|
|
|
|
|
|
atom_bindings_->BindTo(node::process);
|
|
|
|
|
|
|
|
node_bindings_->Load();
|
2013-04-13 10:39:09 +00:00
|
|
|
}
|
|
|
|
|
2013-04-13 15:05:13 +00:00
|
|
|
void AtomBrowserMainParts::PreMainMessageLoopStart() {
|
|
|
|
brightray::BrowserMainParts::PreMainMessageLoopStart();
|
|
|
|
|
|
|
|
node_bindings_->PrepareMessageLoop();
|
|
|
|
}
|
|
|
|
|
2013-04-12 07:57:17 +00:00
|
|
|
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
|
|
|
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
|
|
|
|
2013-04-13 15:05:13 +00:00
|
|
|
node_bindings_->RunMessageLoop();
|
|
|
|
|
2013-04-12 07:57:17 +00:00
|
|
|
scoped_ptr<base::DictionaryValue> options(new base::DictionaryValue);
|
|
|
|
options->SetInteger("width", 800);
|
|
|
|
options->SetInteger("height", 600);
|
|
|
|
options->SetString("title", "Atom");
|
|
|
|
|
|
|
|
// FIXME: Leak object here.
|
|
|
|
NativeWindow* window = NativeWindow::Create(browser_context(), options.get());
|
|
|
|
window->InitFromOptions(options.get());
|
|
|
|
|
|
|
|
window->GetWebContents()->GetController().LoadURL(
|
2013-04-13 15:05:13 +00:00
|
|
|
GURL("http://localhost"),
|
2013-04-12 07:57:17 +00:00
|
|
|
content::Referrer(),
|
|
|
|
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
|
|
|
std::string());
|
|
|
|
}
|
|
|
|
|
2013-04-12 01:46:58 +00:00
|
|
|
} // namespace atom
|