2013-05-02 15:43:23 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-02 15:43:23 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_BROWSER_H_
|
|
|
|
#define ATOM_BROWSER_BROWSER_H_
|
|
|
|
|
2014-03-16 01:13:06 +00:00
|
|
|
#include <string>
|
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/compiler_specific.h"
|
2013-05-03 02:53:54 +00:00
|
|
|
#include "base/observer_list.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/browser_observer.h"
|
|
|
|
#include "atom/browser/window_list_observer.h"
|
2013-05-02 15:43:23 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2014-04-10 07:22:17 +00:00
|
|
|
// Cleanup everything and shutdown the application gracefully.
|
|
|
|
void Shutdown();
|
2013-05-02 15:43:23 +00:00
|
|
|
|
2013-05-30 11:24:47 +00:00
|
|
|
// Focus the application.
|
|
|
|
void Focus();
|
|
|
|
|
2013-06-19 05:41:54 +00:00
|
|
|
// Returns the version of the executable (or bundle).
|
2013-12-05 02:26:01 +00:00
|
|
|
std::string GetVersion() const;
|
|
|
|
|
|
|
|
// Overrides the application version.
|
|
|
|
void SetVersion(const std::string& version);
|
2013-06-19 05:41:54 +00:00
|
|
|
|
2013-12-05 02:32:58 +00:00
|
|
|
// Returns the application's name, default is just Atom-Shell.
|
|
|
|
std::string GetName() const;
|
|
|
|
|
|
|
|
// Overrides the application name.
|
|
|
|
void SetName(const std::string& name);
|
|
|
|
|
2013-08-06 08:19:56 +00:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
// Bounce the dock icon.
|
|
|
|
enum BounceType {
|
|
|
|
BOUNCE_CRITICAL = 0,
|
|
|
|
BOUNCE_INFORMATIONAL = 10,
|
|
|
|
};
|
|
|
|
int DockBounce(BounceType type);
|
|
|
|
void DockCancelBounce(int request_id);
|
|
|
|
|
2013-08-06 08:39:31 +00:00
|
|
|
// Set/Get dock's badge text.
|
2013-08-06 08:19:56 +00:00
|
|
|
void DockSetBadgeText(const std::string& label);
|
2013-08-06 08:39:31 +00:00
|
|
|
std::string DockGetBadgeText();
|
2014-06-25 03:55:33 +00:00
|
|
|
|
|
|
|
// Hide/Show dock.
|
|
|
|
void DockHide();
|
|
|
|
void DockShow();
|
2013-08-06 08:19:56 +00:00
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2013-05-30 08:03:10 +00:00
|
|
|
// Tell the application to open a file.
|
|
|
|
bool OpenFile(const std::string& file_path);
|
|
|
|
|
2013-07-10 08:10:38 +00:00
|
|
|
// Tell the application to open a url.
|
|
|
|
void OpenURL(const std::string& url);
|
|
|
|
|
2014-03-05 10:09:44 +00:00
|
|
|
// Tell the application that application is activated with no open windows.
|
|
|
|
void ActivateWithNoOpenWindows();
|
|
|
|
|
2013-05-30 11:12:14 +00:00
|
|
|
// Tell the application the loading has been done.
|
2013-06-03 07:31:46 +00:00
|
|
|
void WillFinishLaunching();
|
2013-05-30 11:12:14 +00:00
|
|
|
void DidFinishLaunching();
|
|
|
|
|
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
|
|
|
|
2013-06-26 09:22:24 +00:00
|
|
|
bool is_quiting() const { return is_quiting_; }
|
2014-10-30 13:32:35 +00:00
|
|
|
bool is_ready() const { return is_ready_; }
|
2013-06-26 09:22:24 +00:00
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
protected:
|
2013-12-05 02:26:01 +00:00
|
|
|
// Returns the version of application bundle or executable file.
|
|
|
|
std::string GetExecutableFileVersion() const;
|
|
|
|
|
2013-12-05 02:42:04 +00:00
|
|
|
// Returns the name of application bundle or executable file.
|
|
|
|
std::string GetExecutableFileProductName() const;
|
|
|
|
|
2014-04-10 07:22:17 +00:00
|
|
|
// Send the will-quit message and then shutdown the application.
|
|
|
|
void NotifyAndShutdown();
|
2013-05-03 02:53:54 +00:00
|
|
|
|
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_;
|
|
|
|
|
2014-10-30 13:32:35 +00:00
|
|
|
// Whether "ready" event has been emitted.
|
|
|
|
bool is_ready_;
|
|
|
|
|
2013-12-05 02:26:01 +00:00
|
|
|
std::string version_override_;
|
2013-12-05 02:32:58 +00:00
|
|
|
std::string name_override_;
|
2013-12-05 02:26:01 +00:00
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(Browser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_BROWSER_H_
|