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.
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#ifndef SHELL_BROWSER_UI_VIEWS_ELECTRON_VIEWS_DELEGATE_H_
|
|
|
|
#define 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"
|
|
|
|
|
2019-06-19 21:23:04 +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
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
2015-06-05 04:07:27 +00:00
|
|
|
HICON GetDefaultWindowIcon() const override;
|
|
|
|
HICON GetSmallWindowIcon() const override;
|
|
|
|
bool IsWindowInMetro(gfx::NativeWindow window) const override;
|
2019-11-19 14:07:10 +00:00
|
|
|
int GetAppbarAutohideEdges(HMONITOR monitor,
|
|
|
|
base::OnceClosure callback) override;
|
2014-07-03 08:44:58 +00:00
|
|
|
#elif defined(OS_LINUX) && !defined(OS_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:
|
2019-11-19 14:07:10 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2014-07-03 08:44:58 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#endif // SHELL_BROWSER_UI_VIEWS_ELECTRON_VIEWS_DELEGATE_H_
|