More fixes after code review.

This commit is contained in:
Haojian Wu 2015-09-14 19:05:53 -07:00
parent 40d93ce55a
commit 9652ed6508
7 changed files with 11 additions and 30 deletions

View file

@ -167,12 +167,8 @@ void App::OnOpenURL(const std::string& url) {
Emit("open-url", url); Emit("open-url", url);
} }
void App::OnActivateWithNoOpenWindows() { void App::OnActivate(bool has_visible_windows) {
Emit("activate-with-no-open-windows"); Emit("activate", has_visible_windows);
}
void App::OnActivate(bool hasVisibleWindows) {
Emit("activate", hasVisibleWindows);
} }
void App::OnWillFinishLaunching() { void App::OnWillFinishLaunching() {

View file

@ -41,8 +41,7 @@ class App : public mate::EventEmitter,
void OnQuit() override; void OnQuit() override;
void OnOpenFile(bool* prevent_default, const std::string& file_path) override; void OnOpenFile(bool* prevent_default, const std::string& file_path) override;
void OnOpenURL(const std::string& url) override; void OnOpenURL(const std::string& url) override;
void OnActivateWithNoOpenWindows() override; void OnActivate(bool has_visible_windows) override;
void OnActivate(bool hasVisibleWindows) override;
void OnWillFinishLaunching() override; void OnWillFinishLaunching() override;
void OnFinishLaunching() override; void OnFinishLaunching() override;
void OnSelectCertificate( void OnSelectCertificate(

View file

@ -45,6 +45,7 @@ app.getHomeDir = -> @getPath 'home'
app.getDataPath = -> @getPath 'userData' app.getDataPath = -> @getPath 'userData'
app.setDataPath = (path) -> @setPath 'userData', path app.setDataPath = (path) -> @setPath 'userData', path
app.resolveProxy = -> @defaultSession.resolveProxy.apply @defaultSession, arguments app.resolveProxy = -> @defaultSession.resolveProxy.apply @defaultSession, arguments
app.on 'activate', (event, hasVisibleWindows) -> @emit 'activate-with-no-open-windows' if hasVisibleWindows
# Session wrapper. # Session wrapper.
sessionBindings._setWrapSession wrapSession sessionBindings._setWrapSession wrapSession

View file

@ -94,12 +94,10 @@ void Browser::OpenURL(const std::string& url) {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url)); FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url));
} }
void Browser::ActivateWithNoOpenWindows() { void Browser::Activate(bool has_visible_windows) {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows()); FOR_EACH_OBSERVER(BrowserObserver,
} observers_,
OnActivate(has_visible_windows));
void Browser::Activate(bool hasVisibleWindows) {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivate(hasVisibleWindows));
} }
void Browser::WillFinishLaunching() { void Browser::WillFinishLaunching() {

View file

@ -108,12 +108,9 @@ class Browser : public WindowListObserver {
// Tell the application to open a url. // Tell the application to open a url.
void OpenURL(const std::string& url); void OpenURL(const std::string& url);
// Tell the application that application is activated with no open windows.
void ActivateWithNoOpenWindows();
// Tell the application that application is activated with visible/invisible // Tell the application that application is activated with visible/invisible
// windows. // windows.
void Activate(bool hasVisibleWindows); void Activate(bool has_visible_windows);
// Tell the application the loading has been done. // Tell the application the loading has been done.
void WillFinishLaunching(); void WillFinishLaunching();

View file

@ -43,13 +43,9 @@ class BrowserObserver {
// Browser is used to open a url. // Browser is used to open a url.
virtual void OnOpenURL(const std::string& url) {} virtual void OnOpenURL(const std::string& url) {}
// The browser is activated with no open windows (usually by clicking on the
// dock icon).
virtual void OnActivateWithNoOpenWindows() {}
// The browser is activated with visible/invisible windows (usually by // The browser is activated with visible/invisible windows (usually by
// clicking on the dock icon). // clicking on the dock icon).
virtual void OnActivate(bool hasVisibleWindows) {} virtual void OnActivate(bool has_visible_windows) {}
// The browser has finished loading. // The browser has finished loading.
virtual void OnWillFinishLaunching() {} virtual void OnWillFinishLaunching() {}

View file

@ -53,13 +53,7 @@
hasVisibleWindows:(BOOL)flag { hasVisibleWindows:(BOOL)flag {
atom::Browser* browser = atom::Browser::Get(); atom::Browser* browser = atom::Browser::Get();
browser->Activate(static_cast<bool>(flag)); browser->Activate(static_cast<bool>(flag));
if (flag) { return flag;
return YES;
} else {
// Deprecated API, for compatibility.
browser->ActivateWithNoOpenWindows();
return NO;
}
} }
@end @end