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 /////////////////////////////////////////////////////////////////////////////// |
| 65 // WindowButtonOrderProvider, protected: |
| 66 |
| 67 WindowButtonOrderProvider::WindowButtonOrderProvider() { |
| 68 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); |
| 69 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); |
| 70 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); |
| 71 } |
| 72 |
| 73 WindowButtonOrderProvider::~WindowButtonOrderProvider() { |
| 74 } |
| 75 |
| 76 void WindowButtonOrderProvider::SetWindowButtonOrder( |
| 77 const std::vector<views::FrameButton>& leading_buttons, |
| 78 const std::vector<views::FrameButton>& trailing_buttons) { |
| 79 leading_buttons_ = leading_buttons; |
| 80 trailing_buttons_ = trailing_buttons; |
| 81 } |
| 82 |
| 83 } // namespace views |
OLD | NEW |