Warning of app not ready in screen module
This commit is contained in:
parent
e8f1f6819c
commit
c6fb645f6b
3 changed files with 12 additions and 6 deletions
|
@ -107,15 +107,21 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Screen> Screen::Create(v8::Isolate* isolate) {
|
v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||||
|
if (!Browser::Get()->is_ready()) {
|
||||||
|
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||||
|
isolate, "Can not initialize \"screen\" module before app is ready")));
|
||||||
|
return v8::Undefined(isolate);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||||
isolate, "Failed to get screen information")));
|
isolate, "Failed to get screen information")));
|
||||||
return mate::Handle<Screen>();
|
return v8::Undefined(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateHandle(isolate, new Screen(screen));
|
return mate::CreateHandle(isolate, new Screen(screen)).ToV8();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace api {
|
||||||
class Screen : public mate::EventEmitter,
|
class Screen : public mate::EventEmitter,
|
||||||
public gfx::DisplayObserver {
|
public gfx::DisplayObserver {
|
||||||
public:
|
public:
|
||||||
static mate::Handle<Screen> Create(v8::Isolate* isolate);
|
static v8::Handle<v8::Value> Create(v8::Isolate* isolate);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Screen(gfx::Screen* screen);
|
explicit Screen(gfx::Screen* screen);
|
||||||
|
|
|
@ -83,12 +83,12 @@ struct Converter<gfx::Display::TouchSupport> {
|
||||||
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
const gfx::Display::TouchSupport& val) {
|
const gfx::Display::TouchSupport& val) {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case gfx::Display::TOUCH_SUPPORT_UNKNOWN:
|
|
||||||
return StringToV8(isolate, "unknown");
|
|
||||||
case gfx::Display::TOUCH_SUPPORT_AVAILABLE:
|
case gfx::Display::TOUCH_SUPPORT_AVAILABLE:
|
||||||
return StringToV8(isolate, "available");
|
return StringToV8(isolate, "available");
|
||||||
case gfx::Display::TOUCH_SUPPORT_UNAVAILABLE:
|
case gfx::Display::TOUCH_SUPPORT_UNAVAILABLE:
|
||||||
return StringToV8(isolate, "unavailable");
|
return StringToV8(isolate, "unavailable");
|
||||||
|
default:
|
||||||
|
return StringToV8(isolate, "unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue