1 // Copyright (c) 2013 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 "chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h"
7 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
8 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
9 #include "ui/views/linux_ui/linux_ui.h"
11 ///////////////////////////////////////////////////////////////////////////////
12 // OpaqueBrowserFrameViewLinux, public:
14 OpaqueBrowserFrameViewLinux::OpaqueBrowserFrameViewLinux(
15 OpaqueBrowserFrameView* view,
16 OpaqueBrowserFrameViewLayout* layout)
19 views::LinuxUI* ui = views::LinuxUI::instance();
21 ui->AddWindowButtonOrderObserver(this);
24 OpaqueBrowserFrameViewLinux::~OpaqueBrowserFrameViewLinux() {
25 views::LinuxUI* ui = views::LinuxUI::instance();
27 ui->RemoveWindowButtonOrderObserver(this);
30 ///////////////////////////////////////////////////////////////////////////////
31 // OpaqueBrowserFrameViewLinux,
32 // views::WindowButtonOrderObserver implementation:
34 void OpaqueBrowserFrameViewLinux::OnWindowButtonOrderingChange(
35 const std::vector<views::FrameButton>& leading_buttons,
36 const std::vector<views::FrameButton>& trailing_buttons) {
37 layout_->SetButtonOrdering(leading_buttons, trailing_buttons);
39 // We can receive OnWindowButtonOrderingChange events before we've been added
40 // to a Widget. We need a Widget because layout crashes due to dependencies
41 // on a ui::ThemeProvider().
42 if (view_->GetWidget()) {
44 view_->SchedulePaint();
48 ///////////////////////////////////////////////////////////////////////////////
49 // OpaqueBrowserFrameViewObserver:
52 OpaqueBrowserFrameViewPlatformSpecific*
53 OpaqueBrowserFrameViewPlatformSpecific::Create(
54 OpaqueBrowserFrameView* view,
55 OpaqueBrowserFrameViewLayout* layout) {
56 return new OpaqueBrowserFrameViewLinux(view, layout);