summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/browser_view.h
blob: a8d0470f7653e33532223071dfb93f94900aac74 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (c) 2010 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_BROWSER_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_BROWSER_VIEW_H_

#include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "views/controls/button/button.h"

class TabStripModel;

namespace menus {
class SimpleMenuModel;
}  // namespace menus

namespace views {
class ImageButton;
class Menu2;
}  // namespace views

namespace chromeos {

class BrowserStatusAreaView;
class CompactLocationBar;
class CompactLocationBarHost;
class CompactNavigationBar;
class StatusAreaButton;

// chromeos::BrowserView adds ChromeOS specific controls and menus to a
// BrowserView created with Browser::TYPE_NORMAL. This extender adds controls
// to the title bar as follows:
//                  ____  __ __
//      [MainMenu] /    \   \  \     [StatusArea]
//
// and adds the system context menu to the remaining arae of the titlebar.
class BrowserView : public ::BrowserView,
                    public views::ButtonListener,
                    public views::ContextMenuController,
                    public StatusAreaHost {
 public:
  // There are 3 ui styles, standard, compact and sidebar.
  // Standard uses the same layout as chromium/chrome browser.
  // Compact mode hides the omnibox/toolbar to save the vertical real estate,
  // and uses QSB (compact nav bar) to launch/switch url. In sidebar mode,
  // the tabstrip is moved to the side and the omnibox is moved on top of
  // the tabstrip.
  enum UIStyle {
    StandardStyle,
    CompactStyle,
    SidebarStyle,
  };

  explicit BrowserView(Browser* browser);
  virtual ~BrowserView();

  // BrowserView overrides.
  virtual void Init();
  virtual void Show();
  virtual bool IsToolbarVisible() const;
  virtual void SetFocusToLocationBar();
  virtual void ToggleCompactNavigationBar();
  virtual views::LayoutManager* CreateLayoutManager() const;
  virtual BaseTabStrip* CreateTabStrip(TabStripModel* tab_strip_model);
  virtual void SetStarredState(bool is_starred);
  virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked);

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

  // views::ContextMenuController overrides.
  virtual void ShowContextMenu(views::View* source,
                               int x,
                               int y,
                               bool is_mouse_gesture);

  // StatusAreaHost overrides.
  virtual gfx::NativeWindow GetNativeWindow() const;
  virtual bool ShouldOpenButtonOptions(
      const views::View* button_view) const;
  virtual void OpenButtonOptions(const views::View* button_view) const;
  virtual bool IsButtonVisible(const views::View* button_view) const;

  // Shows the compact location bar under the selected tab.
  void ShowCompactLocationBarUnderSelectedTab();

  // The following methods are temporarily defined for refactroing, and
  // will be removed soon. See BrowserExtender class for the description.
  bool ShouldForceMaximizedWindow() const;
  int GetMainMenuWidth() const;

  // Returns true if the ui style is in Compact mode.
  bool is_compact_style() const {
    return ui_style_ == CompactStyle;
  }

 private:
  void InitSystemMenu();

  // Main menu button.
  views::ImageButton* main_menu_;

  // Status Area view.
  BrowserStatusAreaView* status_area_;

  // System menus.
  scoped_ptr<menus::SimpleMenuModel> system_menu_contents_;
  scoped_ptr<views::Menu2> system_menu_menu_;

  // CompactNavigationBar view.
  chromeos::CompactNavigationBar* compact_navigation_bar_;

  // The current UI style of the browser.
  UIStyle ui_style_;

  // CompactLocationBarHost.
  scoped_ptr<chromeos::CompactLocationBarHost> compact_location_bar_host_;

  // A flag to specify if the browser window should be maximized.
  bool force_maximized_window_;

  // A spacer under the tap strip used when the compact navigation bar
  // is active.
  views::View* spacer_;

  // Menu button shown in status area when browser is in compact mode.
  StatusAreaButton* menu_view_;

  DISALLOW_COPY_AND_ASSIGN(BrowserView);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_BROWSER_VIEW_H_