1// Copyright (c) 2011 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#ifndef CHROME_BROWSER_CHROMEOS_FRAME_PANEL_BROWSER_VIEW_H_
6#define CHROME_BROWSER_CHROMEOS_FRAME_PANEL_BROWSER_VIEW_H_
7#pragma once
8
9#include "base/memory/scoped_ptr.h"
10#include "chrome/browser/chromeos/frame/panel_controller.h"
11#include "chrome/browser/ui/views/frame/browser_view.h"
12#include "ui/base/x/x11_util.h"
13
14class Browser;
15
16namespace chromeos {
17
18class PanelController;
19
20// A browser view that implements Panel specific behavior.
21// NOTE: This inherits from ::BrowserView in chrome/browser/ui/views/frame/,
22// not chromeos::BrowserView in chrome/browser/chromeos/frame/.
23class PanelBrowserView : public ::BrowserView,
24                         public PanelController::Delegate {
25 public:
26  explicit PanelBrowserView(Browser* browser);
27
28  // BrowserView overrides.
29  virtual void Show();
30  virtual void ShowInactive();
31  virtual void SetBounds(const gfx::Rect& bounds);
32  virtual void Close();
33  virtual void UpdateTitleBar();
34  virtual void SetCreatorView(PanelBrowserView* creator);
35  virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const;
36  virtual void OnWindowActivationChanged(bool active);
37
38  // BrowserView : TabStripModelObserver overrides.
39  virtual void TabChangedAt(TabContentsWrapper* contents,
40                            int index,
41                            TabChangeType change_type);
42
43  // PanelController::Delegate overrides
44  virtual string16 GetPanelTitle();
45  virtual SkBitmap GetPanelIcon();
46  virtual bool CanClosePanel();
47  virtual void ClosePanel();
48  virtual void ActivatePanel();
49  virtual void OnPanelStateChanged(PanelController::State state) {}
50
51 private:
52  // Enforces the min, max, and default bounds.
53  void LimitBounds(gfx::Rect* bounds) const;
54
55  void InitPanelController(bool is_active);
56
57  // Controls interactions with the window manager for popup panels.
58  scoped_ptr<chromeos::PanelController> panel_controller_;
59
60  // X id for the content window of the panel that created this
61  // panel.  This tells ChromeOS that it should be created next to the
62  // content window of this panel.
63  XID creator_xid_;
64  DISALLOW_COPY_AND_ASSIGN(PanelBrowserView);
65};
66
67}  // namespace chromeos
68
69#endif  // CHROME_BROWSER_CHROMEOS_FRAME_PANEL_BROWSER_VIEW_H_
70