2014-10-31 21:17:05 +03:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 13:49:37 +04:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-02 18:54:09 +04:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 23:56:58 +03:00
|
|
|
#ifndef SHELL_BROWSER_WINDOW_LIST_H_
|
|
|
|
#define SHELL_BROWSER_WINDOW_LIST_H_
|
2013-05-02 18:54:09 +04:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/lazy_instance.h"
|
2016-08-27 01:30:02 +03:00
|
|
|
#include "base/macros.h"
|
2013-05-02 18:54:09 +04:00
|
|
|
#include "base/observer_list.h"
|
|
|
|
|
2019-06-20 00:23:04 +03:00
|
|
|
namespace electron {
|
2013-05-02 18:54:09 +04:00
|
|
|
|
|
|
|
class NativeWindow;
|
|
|
|
class WindowListObserver;
|
|
|
|
|
|
|
|
class WindowList {
|
|
|
|
public:
|
|
|
|
typedef std::vector<NativeWindow*> WindowVector;
|
2014-01-02 18:47:54 +04:00
|
|
|
|
2017-04-07 00:43:37 +03:00
|
|
|
static WindowVector GetWindows();
|
2017-04-07 00:48:58 +03:00
|
|
|
static bool IsEmpty();
|
2017-04-07 00:43:37 +03:00
|
|
|
|
2013-05-02 18:54:09 +04:00
|
|
|
// Adds or removes |window| from the list it is associated with.
|
|
|
|
static void AddWindow(NativeWindow* window);
|
|
|
|
static void RemoveWindow(NativeWindow* window);
|
|
|
|
|
2013-05-02 19:43:23 +04:00
|
|
|
// Called by window when a close is cancelled by beforeunload handler.
|
|
|
|
static void WindowCloseCancelled(NativeWindow* window);
|
|
|
|
|
2013-05-02 18:54:09 +04:00
|
|
|
// Adds and removes |observer| from the observer list.
|
|
|
|
static void AddObserver(WindowListObserver* observer);
|
|
|
|
static void RemoveObserver(WindowListObserver* observer);
|
|
|
|
|
|
|
|
// Closes all windows.
|
|
|
|
static void CloseAllWindows();
|
|
|
|
|
2017-04-07 00:25:22 +03:00
|
|
|
// Destroy all windows.
|
|
|
|
static void DestroyAllWindows();
|
|
|
|
|
2013-05-02 18:54:09 +04:00
|
|
|
private:
|
2017-04-07 00:48:58 +03:00
|
|
|
static WindowList* GetInstance();
|
|
|
|
|
2013-05-02 18:54:09 +04:00
|
|
|
WindowList();
|
|
|
|
~WindowList();
|
|
|
|
|
|
|
|
// A vector of the windows in this list, in the order they were added.
|
|
|
|
WindowVector windows_;
|
|
|
|
|
|
|
|
// A list of observers which will be notified of every window addition and
|
|
|
|
// removal across all WindowLists.
|
2015-09-02 10:16:49 +03:00
|
|
|
static base::LazyInstance<base::ObserverList<WindowListObserver>>::Leaky
|
|
|
|
observers_;
|
2013-05-02 18:54:09 +04:00
|
|
|
|
|
|
|
static WindowList* instance_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(WindowList);
|
|
|
|
};
|
|
|
|
|
2019-06-20 00:23:04 +03:00
|
|
|
} // namespace electron
|
2013-05-02 18:54:09 +04:00
|
|
|
|
2019-06-19 23:56:58 +03:00
|
|
|
#endif // SHELL_BROWSER_WINDOW_LIST_H_
|