Add API to get and override application name.
This commit is contained in:
parent
420ae1a2cc
commit
5670ee7693
4 changed files with 41 additions and 0 deletions
|
@ -121,6 +121,28 @@ v8::Handle<v8::Value> App::SetVersion(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::GetName(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
std::string name(Browser::Get()->GetName());
|
||||
|
||||
return v8::String::New(name.data(), version.size());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::SetName(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
std::string name;
|
||||
if (!FromV8Arguments(args, &name))
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
Browser::Get()->SetName(name);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
@ -204,6 +226,8 @@ void App::Initialize(v8::Handle<v8::Object> target) {
|
|||
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getName", GetName);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setName", SetName);
|
||||
|
||||
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ class App : public EventEmitter,
|
|||
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetVersion(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetVersion(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetName(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetName(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
|
||||
|
||||
|
|
|
@ -47,6 +47,14 @@ void Browser::SetVersion(const std::string& version) {
|
|||
version_override_ = version;
|
||||
}
|
||||
|
||||
std::string Browser::GetName() const {
|
||||
return name_override_.empty() ? "Atom-Shell" : name_override_;
|
||||
}
|
||||
|
||||
void Browser::SetName(const std::string& name) {
|
||||
name_override_ = name;
|
||||
}
|
||||
|
||||
bool Browser::OpenFile(const std::string& file_path) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
|
|
|
@ -36,6 +36,12 @@ class Browser : public WindowListObserver {
|
|||
// Overrides the application version.
|
||||
void SetVersion(const std::string& version);
|
||||
|
||||
// Returns the application's name, default is just Atom-Shell.
|
||||
std::string GetName() const;
|
||||
|
||||
// Overrides the application name.
|
||||
void SetName(const std::string& name);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Bounce the dock icon.
|
||||
enum BounceType {
|
||||
|
@ -91,6 +97,7 @@ class Browser : public WindowListObserver {
|
|||
ObserverList<BrowserObserver> observers_;
|
||||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Browser);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue