Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / opaque_browser_frame_view_linux.cc
blobf0def59e991f76fb430da6f6e6536934e2334ce6
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)
17 : view_(view),
18 layout_(layout) {
19 views::LinuxUI* ui = views::LinuxUI::instance();
20 if (ui)
21 ui->AddWindowButtonOrderObserver(this);
24 OpaqueBrowserFrameViewLinux::~OpaqueBrowserFrameViewLinux() {
25 views::LinuxUI* ui = views::LinuxUI::instance();
26 if (ui)
27 ui->RemoveWindowButtonOrderObserver(this);
30 ///////////////////////////////////////////////////////////////////////////////
31 // OpaqueBrowserFrameViewLinux,
32 // OpaqueBrowserFrameViewPlatformSpecific implementation:
34 bool OpaqueBrowserFrameViewLinux::ShouldShowCaptionButtons() const {
35 // On Ubuntu Unity, if the window is maximized, the system will provide
36 // caption buttons, so Chrome should not add its own.
37 views::LinuxUI* ui = views::LinuxUI::instance();
38 return !(view_->IsMaximized() && ui && ui->UnityIsRunning());
41 bool OpaqueBrowserFrameViewLinux::ShouldShowTitleBar() const {
42 // On Ubuntu Unity, if the window is maximized, the system will provide
43 // a title bar, so Chrome should not add its own.
44 views::LinuxUI* ui = views::LinuxUI::instance();
45 return !(view_->IsMaximized() && ui && ui->UnityIsRunning());
48 ///////////////////////////////////////////////////////////////////////////////
49 // OpaqueBrowserFrameViewLinux,
50 // views::WindowButtonOrderObserver implementation:
52 void OpaqueBrowserFrameViewLinux::OnWindowButtonOrderingChange(
53 const std::vector<views::FrameButton>& leading_buttons,
54 const std::vector<views::FrameButton>& trailing_buttons) {
55 layout_->SetButtonOrdering(leading_buttons, trailing_buttons);
57 // We can receive OnWindowButtonOrderingChange events before we've been added
58 // to a Widget. We need a Widget because layout crashes due to dependencies
59 // on a ui::ThemeProvider().
60 if (view_->GetWidget()) {
61 view_->Layout();
62 view_->SchedulePaint();
66 ///////////////////////////////////////////////////////////////////////////////
67 // OpaqueBrowserFrameViewObserver:
69 // static
70 OpaqueBrowserFrameViewPlatformSpecific*
71 OpaqueBrowserFrameViewPlatformSpecific::Create(
72 OpaqueBrowserFrameView* view,
73 OpaqueBrowserFrameViewLayout* layout) {
74 return new OpaqueBrowserFrameViewLinux(view, layout);