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);
}
void App::OnActivateWithNoOpenWindows() {
Emit("activate-with-no-open-windows");
}
void App::OnActivate(bool hasVisibleWindows) {
Emit("activate", hasVisibleWindows);
void App::OnActivate(bool has_visible_windows) {
Emit("activate", has_visible_windows);
}
void App::OnWillFinishLaunching() {

View file

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

View file

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

View file

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

View file

@ -108,12 +108,9 @@ class Browser : public WindowListObserver {
// Tell the application to open a 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
// windows.
void Activate(bool hasVisibleWindows);
void Activate(bool has_visible_windows);
// Tell the application the loading has been done.
void WillFinishLaunching();

View file

@ -43,13 +43,9 @@ class BrowserObserver {
// Browser is used to open a 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
// clicking on the dock icon).
virtual void OnActivate(bool hasVisibleWindows) {}
virtual void OnActivate(bool has_visible_windows) {}
// The browser has finished loading.
virtual void OnWillFinishLaunching() {}

View file

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