1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/window/window_button_order_provider.h"
7 #include "ui/views/linux_ui/linux_ui.h"
8 #include "ui/views/linux_ui/window_button_order_observer.h"
14 class WindowButtonOrderObserverDelegate
: public WindowButtonOrderProvider
,
15 public WindowButtonOrderObserver
{
17 WindowButtonOrderObserverDelegate();
18 ~WindowButtonOrderObserverDelegate() override
;
20 // WindowButtonOrderObserver:
21 void OnWindowButtonOrderingChange(
22 const std::vector
<views::FrameButton
>& leading_buttons
,
23 const std::vector
<views::FrameButton
>& trailing_buttons
) override
;
26 DISALLOW_COPY_AND_ASSIGN(WindowButtonOrderObserverDelegate
);
29 ///////////////////////////////////////////////////////////////////////////////
30 // WindowButtonOrderObserverDelegate, public:
32 WindowButtonOrderObserverDelegate::WindowButtonOrderObserverDelegate() {
33 views::LinuxUI
* ui
= views::LinuxUI::instance();
35 ui
->AddWindowButtonOrderObserver(this);
38 WindowButtonOrderObserverDelegate::~WindowButtonOrderObserverDelegate() {
39 views::LinuxUI
* ui
= views::LinuxUI::instance();
41 ui
->RemoveWindowButtonOrderObserver(this);
44 void WindowButtonOrderObserverDelegate::OnWindowButtonOrderingChange(
45 const std::vector
<views::FrameButton
>& leading_buttons
,
46 const std::vector
<views::FrameButton
>& trailing_buttons
) {
47 SetWindowButtonOrder(leading_buttons
, trailing_buttons
);
53 WindowButtonOrderProvider
* WindowButtonOrderProvider::instance_
= NULL
;
55 ///////////////////////////////////////////////////////////////////////////////
56 // WindowButtonOrderProvider, public:
59 WindowButtonOrderProvider
* WindowButtonOrderProvider::GetInstance() {
61 instance_
= new WindowButtonOrderObserverDelegate
;
65 ///////////////////////////////////////////////////////////////////////////////
66 // WindowButtonOrderProvider, protected:
68 WindowButtonOrderProvider::WindowButtonOrderProvider() {
69 trailing_buttons_
.push_back(views::FRAME_BUTTON_MINIMIZE
);
70 trailing_buttons_
.push_back(views::FRAME_BUTTON_MAXIMIZE
);
71 trailing_buttons_
.push_back(views::FRAME_BUTTON_CLOSE
);
74 WindowButtonOrderProvider::~WindowButtonOrderProvider() {
77 void WindowButtonOrderProvider::SetWindowButtonOrder(
78 const std::vector
<views::FrameButton
>& leading_buttons
,
79 const std::vector
<views::FrameButton
>& trailing_buttons
) {
80 leading_buttons_
= leading_buttons
;
81 trailing_buttons_
= trailing_buttons
;