summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/frame/layout_mode_button.h
blob: 0d26c623ededd5f174150076c97a7a1bf6dbc9d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_
#define CHROME_BROWSER_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_
#pragma once

#include "base/basictypes.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "views/controls/button/button.h"
#include "views/controls/button/image_button.h"

namespace chromeos {

// Maximize/restore button in the corner of each browser window.
class LayoutModeButton : public views::ImageButton,
                         public views::ButtonListener,
                         public content::NotificationObserver {
 public:
  LayoutModeButton();
  virtual ~LayoutModeButton();

  // views::* override.
  virtual gfx::Size GetPreferredSize() OVERRIDE;
  virtual bool HitTest(const gfx::Point& l) const OVERRIDE;

  // content::NotificationObserver implementation.
  virtual void Observe(int type,
                       const content::NotificationSource& source,
                       const content::NotificationDetails& details) OVERRIDE;

  void Init();

 private:
  // views::ButtonListener implementation.
  virtual void ButtonPressed(views::Button* sender, const views::Event& event)
      OVERRIDE;

  // Update our icon and tooltip appropriately for the current layout mode.
  void UpdateForCurrentLayoutMode();

  // A registrar for subscribing to LAYOUT_MODE_CHANGED notifications.
  content::NotificationRegistrar registrar_;

  DISALLOW_COPY_AND_ASSIGN(LayoutModeButton);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_