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_BROWSER_VIEW_H_ 6#define CHROME_BROWSER_CHROMEOS_FRAME_BROWSER_VIEW_H_ 7#pragma once 8 9#include <vector> 10 11#include "chrome/browser/chromeos/status/status_area_host.h" 12#include "chrome/browser/ui/views/frame/browser_view.h" 13#include "views/controls/menu/menu_wrapper.h" 14 15class AccessibleToolbarView; 16class Profile; 17class TabStripModel; 18 19namespace ui { 20class SimpleMenuModel; 21} // namespace ui 22 23namespace views { 24class ImageButton; 25class ImageView; 26class Menu2; 27} // namespace views 28 29namespace chromeos { 30 31class StatusAreaView; 32class StatusAreaButton; 33 34// chromeos::BrowserView adds ChromeOS specific controls and menus to a 35// BrowserView created with Browser::TYPE_NORMAL. This extender adds controls 36// to the title bar as follows: 37// ____ __ __ 38// / \ \ \ [StatusArea] 39// 40// and adds the system context menu to the remaining arae of the titlebar. 41class BrowserView : public ::BrowserView, 42 public views::ContextMenuController, 43 public views::MenuListener, 44 public StatusAreaHost { 45 public: 46 explicit BrowserView(Browser* browser); 47 virtual ~BrowserView(); 48 49 // BrowserView overrides. 50 virtual void Init() OVERRIDE; 51 virtual void Show() OVERRIDE; 52 virtual void ShowInactive() OVERRIDE; 53 virtual void FocusChromeOSStatus() OVERRIDE; 54 virtual views::LayoutManager* CreateLayoutManager() const OVERRIDE; 55 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 56 virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE; 57 virtual void Cut() OVERRIDE; 58 virtual void Copy() OVERRIDE; 59 virtual void Paste() OVERRIDE; 60 61 // views::ContextMenuController overrides. 62 virtual void ShowContextMenuForView(views::View* source, 63 const gfx::Point& p, 64 bool is_mouse_gesture) OVERRIDE; 65 66 // views::MenuListener implementation. 67 virtual void OnMenuOpened() OVERRIDE; 68 69 // StatusAreaHost overrides. 70 virtual Profile* GetProfile() const OVERRIDE; 71 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; 72 virtual bool ShouldOpenButtonOptions( 73 const views::View* button_view) const OVERRIDE; 74 virtual void ExecuteBrowserCommand(int id) const OVERRIDE; 75 virtual void OpenButtonOptions(const views::View* button_view) OVERRIDE; 76 virtual ScreenMode GetScreenMode() const OVERRIDE; 77 virtual TextStyle GetTextStyle() const OVERRIDE; 78 79 gfx::NativeView saved_focused_widget() const { 80 return saved_focused_widget_; 81 } 82 83 protected: 84 virtual void GetAccessiblePanes( 85 std::vector<AccessiblePaneView*>* panes); 86 87 private: 88 void InitSystemMenu(); 89 90 void ShowInternal(bool is_active); 91 92 // Status Area view. 93 StatusAreaView* status_area_; 94 95 // System menus. 96 scoped_ptr<ui::SimpleMenuModel> system_menu_contents_; 97 scoped_ptr<views::Menu2> system_menu_menu_; 98 99 // Focused native widget before wench menu shows up. We need this to properly 100 // perform cut, copy and paste. See http://crosbug.com/8496 101 gfx::NativeView saved_focused_widget_; 102 103 DISALLOW_COPY_AND_ASSIGN(BrowserView); 104}; 105 106} // namespace chromeos 107 108#endif // CHROME_BROWSER_CHROMEOS_FRAME_BROWSER_VIEW_H_ 109