2013-05-02 15:43:23 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_BROWSER_H_
|
|
|
|
#define ATOM_BROWSER_BROWSER_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/compiler_specific.h"
|
2013-05-03 02:53:54 +00:00
|
|
|
#include "base/observer_list.h"
|
|
|
|
#include "browser/browser_observer.h"
|
2013-05-02 15:43:23 +00:00
|
|
|
#include "browser/window_list_observer.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
// This class is used for control application-wide operations.
|
|
|
|
class Browser : public WindowListObserver {
|
|
|
|
public:
|
|
|
|
Browser();
|
|
|
|
~Browser();
|
|
|
|
|
|
|
|
static Browser* Get();
|
|
|
|
|
|
|
|
// Try to close all windows and quit the application.
|
|
|
|
void Quit();
|
|
|
|
|
|
|
|
// Quit the application immediately without cleanup work.
|
|
|
|
void Terminate();
|
|
|
|
|
2013-05-03 02:53:54 +00:00
|
|
|
void AddObserver(BrowserObserver* obs) {
|
|
|
|
observers_.AddObserver(obs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveObserver(BrowserObserver* obs) {
|
|
|
|
observers_.RemoveObserver(obs);
|
|
|
|
}
|
2013-05-02 15:43:23 +00:00
|
|
|
|
|
|
|
protected:
|
2013-05-03 02:53:54 +00:00
|
|
|
void NotifyAndTerminate();
|
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
bool is_quiting_;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// WindowListObserver implementations:
|
|
|
|
virtual void OnWindowCloseCancelled(NativeWindow* window) OVERRIDE;
|
|
|
|
virtual void OnWindowAllClosed() OVERRIDE;
|
|
|
|
|
2013-05-03 02:53:54 +00:00
|
|
|
// Observers of the browser.
|
|
|
|
ObserverList<BrowserObserver> observers_;
|
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(Browser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_BROWSER_H_
|