| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ui/views/window/window_button_order_provider.h" | |
| 6 | |
| 7 #include "ui/views/linux_ui/linux_ui.h" | |
| 8 #include "ui/views/linux_ui/window_button_order_observer.h" | |
| 9 | |
| 10 namespace views { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 class WindowButtonOrderObserverDelegate : public WindowButtonOrderProvider, | |
| 15 public WindowButtonOrderObserver { | |
| 16 public: | |
| 17 WindowButtonOrderObserverDelegate(); | |
| 18 virtual ~WindowButtonOrderObserverDelegate(); | |
| 19 | |
| 20 // WindowButtonOrderObserver: | |
| 21 virtual void OnWindowButtonOrderingChange( | |
| 22 const std::vector<views::FrameButton>& leading_buttons, | |
| 23 const std::vector<views::FrameButton>& trailing_buttons) OVERRIDE; | |
| 24 private: | |
| 25 DISALLOW_COPY_AND_ASSIGN(WindowButtonOrderObserverDelegate); | |
| 26 }; | |
| 27 | |
| 28 /////////////////////////////////////////////////////////////////////////////// | |
| 29 // WindowButtonOrderObserverDelegate, public: | |
| 30 | |
| 31 WindowButtonOrderObserverDelegate::WindowButtonOrderObserverDelegate() { | |
| 32 views::LinuxUI* ui = views::LinuxUI::instance(); | |
| 33 if (ui) | |
| 34 ui->AddWindowButtonOrderObserver(this); | |
| 35 } | |
| 36 | |
| 37 WindowButtonOrderObserverDelegate::~WindowButtonOrderObserverDelegate() { | |
| 38 views::LinuxUI* ui = views::LinuxUI::instance(); | |
| 39 if (ui) | |
| 40 ui->RemoveWindowButtonOrderObserver(this); | |
| 41 } | |
| 42 | |
| 43 void WindowButtonOrderObserverDelegate::OnWindowButtonOrderingChange( | |
| 44 const std::vector<views::FrameButton>& leading_buttons, | |
| 45 const std::vector<views::FrameButton>& trailing_buttons) { | |
| 46 SetWindowButtonOrder(leading_buttons, trailing_buttons); | |
| 47 } | |
| 48 | |
| 49 } // namespace | |
| 50 | |
| 51 // static | |
| 52 WindowButtonOrderProvider* WindowButtonOrderProvider::instance_ = NULL; | |
| 53 | |
| 54 /////////////////////////////////////////////////////////////////////////////// | |
| 55 // WindowButtonOrderProvider, public: | |
| 56 | |
| 57 // static | |
| 58 WindowButtonOrderProvider* WindowButtonOrderProvider::GetInstance() { | |
| 59 if (!instance_) | |
| 60 instance_ = new WindowButtonOrderObserverDelegate; | |
| 61 return instance_; | |
| 62 } | |
| 63 | |
| 64 std::vector<views::FrameButton> const | |
| 65 WindowButtonOrderProvider::GetLeadingButtons() const { | |
| 66 return leading_buttons_; | |
| 67 } | |
| 68 | |
| 69 std::vector<views::FrameButton> const | |
| 70 WindowButtonOrderProvider::GetTrailingButtons() const { | |
| 71 return trailing_buttons_; | |
| 72 } | |
| 73 | |
| 74 /////////////////////////////////////////////////////////////////////////////// | |
| 75 // WindowButtonOrderProvider, protected: | |
| 76 | |
| 77 WindowButtonOrderProvider::WindowButtonOrderProvider() { | |
| 78 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); | |
| 79 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); | |
| 80 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); | |
| 81 } | |
| 82 | |
| 83 WindowButtonOrderProvider::~WindowButtonOrderProvider() { | |
| 84 } | |
| 85 | |
| 86 void WindowButtonOrderProvider::SetWindowButtonOrder( | |
| 87 const std::vector<views::FrameButton>& leading_buttons, | |
| 88 const std::vector<views::FrameButton>& trailing_buttons) { | |
| 89 leading_buttons_ = leading_buttons; | |
| 90 trailing_buttons_ = trailing_buttons; | |
| 91 } | |
| 92 | |
| 93 } // namespace views | |
| OLD | NEW |