Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / opaque_browser_frame_view_linux.cc
blob043b55f526c1c25540a927072e7d374ee6264c4c
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/themes/theme_service.h"
8 #include "chrome/browser/themes/theme_service_factory.h"
9 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
10 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
11 #include "ui/views/linux_ui/linux_ui.h"
13 ///////////////////////////////////////////////////////////////////////////////
14 // OpaqueBrowserFrameViewLinux, public:
16 OpaqueBrowserFrameViewLinux::OpaqueBrowserFrameViewLinux(
17 OpaqueBrowserFrameView* view,
18 OpaqueBrowserFrameViewLayout* layout,
19 Profile* profile)
20 : view_(view),
21 layout_(layout),
22 theme_service_(ThemeServiceFactory::GetForProfile(profile)) {
23 views::LinuxUI* ui = views::LinuxUI::instance();
24 if (ui)
25 ui->AddWindowButtonOrderObserver(this);
28 OpaqueBrowserFrameViewLinux::~OpaqueBrowserFrameViewLinux() {
29 views::LinuxUI* ui = views::LinuxUI::instance();
30 if (ui)
31 ui->RemoveWindowButtonOrderObserver(this);
34 bool OpaqueBrowserFrameViewLinux::IsUsingSystemTheme() {
35 // On X11, this does the correct thing. On Windows, UsingSystemTheme() will
36 // return true when using the default blue theme too.
37 return theme_service_->UsingSystemTheme();
40 ///////////////////////////////////////////////////////////////////////////////
41 // OpaqueBrowserFrameViewLinux,
42 // views::WindowButtonOrderObserver implementation:
44 void OpaqueBrowserFrameViewLinux::OnWindowButtonOrderingChange(
45 const std::vector<views::FrameButton>& leading_buttons,
46 const std::vector<views::FrameButton>& trailing_buttons) {
47 layout_->SetButtonOrdering(leading_buttons, trailing_buttons);
49 // We can receive OnWindowButtonOrderingChange events before we've been added
50 // to a Widget. We need a Widget because layout crashes due to dependencies
51 // on a ui::ThemeProvider().
52 if (view_->GetWidget()) {
53 view_->Layout();
54 view_->SchedulePaint();
58 ///////////////////////////////////////////////////////////////////////////////
59 // OpaqueBrowserFrameViewObserver:
61 // static
62 OpaqueBrowserFrameViewPlatformSpecific*
63 OpaqueBrowserFrameViewPlatformSpecific::Create(
64 OpaqueBrowserFrameView* view,
65 OpaqueBrowserFrameViewLayout* layout,
66 Profile* profile) {
67 return new OpaqueBrowserFrameViewLinux(view, layout, profile);