2014-07-03 08:44:58 +00:00
|
|
|
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_ELECTRON_VIEWS_DELEGATE_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_ELECTRON_VIEWS_DELEGATE_H_
|
2014-07-03 08:44:58 +00:00
|
|
|
|
2019-11-19 14:07:10 +00:00
|
|
|
#include <map>
|
2020-07-14 01:13:34 +00:00
|
|
|
#include <memory>
|
2017-05-18 22:06:57 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-07-03 08:44:58 +00:00
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "ui/views/views_delegate.h"
|
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
namespace electron {
|
2014-07-03 08:44:58 +00:00
|
|
|
|
|
|
|
class ViewsDelegate : public views::ViewsDelegate {
|
|
|
|
public:
|
|
|
|
ViewsDelegate();
|
2018-04-17 23:03:51 +00:00
|
|
|
~ViewsDelegate() override;
|
2014-07-03 08:44:58 +00:00
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
ViewsDelegate(const ViewsDelegate&) = delete;
|
|
|
|
ViewsDelegate& operator=(const ViewsDelegate&) = delete;
|
|
|
|
|
2014-07-03 08:44:58 +00:00
|
|
|
protected:
|
|
|
|
// views::ViewsDelegate:
|
2015-06-05 04:07:27 +00:00
|
|
|
void SaveWindowPlacement(const views::Widget* window,
|
|
|
|
const std::string& window_name,
|
|
|
|
const gfx::Rect& bounds,
|
|
|
|
ui::WindowShowState show_state) override;
|
2018-04-18 01:46:27 +00:00
|
|
|
bool GetSavedWindowPlacement(const views::Widget* widget,
|
|
|
|
const std::string& window_name,
|
|
|
|
gfx::Rect* bounds,
|
|
|
|
ui::WindowShowState* show_state) const override;
|
2021-03-16 16:18:45 +00:00
|
|
|
void NotifyMenuItemFocused(const std::u16string& menu_name,
|
|
|
|
const std::u16string& menu_item_name,
|
2015-06-05 04:07:27 +00:00
|
|
|
int item_index,
|
|
|
|
int item_count,
|
|
|
|
bool has_submenu) override;
|
2014-07-03 08:44:58 +00:00
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2015-06-05 04:07:27 +00:00
|
|
|
HICON GetDefaultWindowIcon() const override;
|
|
|
|
HICON GetSmallWindowIcon() const override;
|
2019-11-19 14:07:10 +00:00
|
|
|
int GetAppbarAutohideEdges(HMONITOR monitor,
|
|
|
|
base::OnceClosure callback) override;
|
2022-02-10 02:58:52 +00:00
|
|
|
#elif BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS)
|
2015-06-05 04:07:27 +00:00
|
|
|
gfx::ImageSkia* GetDefaultWindowIcon() const override;
|
2014-07-03 08:44:58 +00:00
|
|
|
#endif
|
2020-07-14 01:13:34 +00:00
|
|
|
std::unique_ptr<views::NonClientFrameView> CreateDefaultNonClientFrameView(
|
2014-10-23 03:10:39 +00:00
|
|
|
views::Widget* widget) override;
|
2015-06-05 04:07:27 +00:00
|
|
|
void AddRef() override;
|
|
|
|
void ReleaseRef() override;
|
|
|
|
void OnBeforeWidgetInit(
|
2014-07-03 08:44:58 +00:00
|
|
|
views::Widget::InitParams* params,
|
2014-10-23 03:10:39 +00:00
|
|
|
views::internal::NativeWidgetDelegate* delegate) override;
|
2015-06-05 04:07:27 +00:00
|
|
|
bool WindowManagerProvidesTitleBar(bool maximized) override;
|
2014-07-03 08:44:58 +00:00
|
|
|
|
|
|
|
private:
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2019-11-19 14:07:10 +00:00
|
|
|
using AppbarAutohideEdgeMap = std::map<HMONITOR, int>;
|
|
|
|
|
|
|
|
// Callback on main thread with the edges. |returned_edges| is the value that
|
|
|
|
// was returned from the call to GetAutohideEdges() that initiated the lookup.
|
|
|
|
void OnGotAppbarAutohideEdges(base::OnceClosure callback,
|
|
|
|
HMONITOR monitor,
|
|
|
|
int returned_edges,
|
|
|
|
int edges);
|
|
|
|
|
|
|
|
AppbarAutohideEdgeMap appbar_autohide_edge_map_;
|
|
|
|
// If true we're in the process of notifying a callback from
|
|
|
|
// GetAutohideEdges().start a new query.
|
|
|
|
bool in_autohide_edges_callback_ = false;
|
|
|
|
|
|
|
|
base::WeakPtrFactory<ViewsDelegate> weak_factory_{this};
|
|
|
|
#endif
|
2014-07-03 08:44:58 +00:00
|
|
|
};
|
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
} // namespace electron
|
2014-07-03 08:44:58 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_ELECTRON_VIEWS_DELEGATE_H_
|