#include "atom/browser/api/atom_api_window.h"
#include "atom/browser/api/atom_api_web_contents.h"
+#include "atom/browser/browser.h"
#include "atom/browser/native_window.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "content/public/browser/render_process_host.h"
}
// static
-mate::Wrappable* Window::New(const mate::Dictionary& options) {
- return new Window(options);
+mate::Wrappable* Window::New(v8::Isolate* isolate,
+ const mate::Dictionary& options) {
+ if (Browser::Get()->is_ready()) {
+ return new Window(options);
+ } else {
+ isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
+ isolate, "Can not create BrowserWindow before app is ready")));
+ return nullptr;
+ }
}
void Window::Destroy() {
class Window : public mate::EventEmitter,
public NativeWindowObserver {
public:
- static mate::Wrappable* New(const mate::Dictionary& options);
+ static mate::Wrappable* New(v8::Isolate* isolate,
+ const mate::Dictionary& options);
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
namespace atom {
Browser::Browser()
- : is_quiting_(false) {
+ : is_quiting_(false),
+ is_ready_(false) {
WindowList::AddObserver(this);
}
}
void Browser::DidFinishLaunching() {
+ is_ready_ = true;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
}
}
bool is_quiting() const { return is_quiting_; }
+ bool is_ready() const { return is_ready_; }
protected:
// Returns the version of application bundle or executable file.
// Observers of the browser.
ObserverList<BrowserObserver> observers_;
+ // Whether "ready" event has been emitted.
+ bool is_ready_;
+
std::string version_override_;
std::string name_override_;
-Subproject commit cc9d22292361e8b74e82a4e6a77407c17b4bfda7
+Subproject commit b1f7cfa9da1f53158a4992428b40a780c9617632