• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UI_PANELS_PANEL_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_H_
7 #pragma once
8 
9 #include "chrome/browser/ui/browser_window.h"
10 
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/rect.h"
13 
14 class PanelManager;
15 
16 // A platform independent implementation of BrowserWindow for Panels.  This
17 // class would get the first crack at all the BrowserWindow calls for Panels and
18 // do one or more of the following:
19 // - Do nothing.  The function is not relevant to Panels.
20 // - Throw an exceptions.  The function shouldn't be called for Panels.
21 // - Do Panel specific platform independent processing and then invoke the
22 //   function on the platform specific BrowserWindow member.  For example,
23 //   Panel size is restricted to certain limits.
24 // - Invoke an appropriate PanelManager function to do stuff that might affect
25 //   other Panels.  For example deleting a panel would rearrange other panels.
26 class Panel : public BrowserWindow {
27  public:
28   virtual ~Panel();
29 
30   // Returns the PanelManager associated with this panel.
31   PanelManager* manager() const;
32 
33   void Minimize();
34 
35   void Restore();
36 
bounds()37   const gfx::Rect& bounds() const { return bounds_; }
38 
minimized()39   bool minimized() const { return minimized_; }
40 
41   // BrowserWindow overrides.
42   virtual void Show();
43   virtual void ShowInactive();
44   virtual void SetBounds(const gfx::Rect& bounds);
45   virtual void Close();
46   virtual void Activate();
47   virtual void Deactivate();
48   virtual bool IsActive() const;
49   virtual void FlashFrame();
50   virtual gfx::NativeWindow GetNativeHandle();
51   virtual BrowserWindowTesting* GetBrowserWindowTesting();
52   virtual StatusBubble* GetStatusBubble();
53   virtual void ToolbarSizeChanged(bool is_animating);
54   virtual void UpdateTitleBar();
55   virtual void ShelfVisibilityChanged();
56   virtual void UpdateDevTools();
57   virtual void UpdateLoadingAnimations(bool should_animate);
58   virtual void SetStarredState(bool is_starred);
59   virtual gfx::Rect GetRestoredBounds() const;
60   virtual gfx::Rect GetBounds() const;
61   virtual bool IsMaximized() const;
62   virtual void SetFullscreen(bool fullscreen);
63   virtual bool IsFullscreen() const;
64   virtual bool IsFullscreenBubbleVisible() const;
65   virtual LocationBar* GetLocationBar() const;
66   virtual void SetFocusToLocationBar(bool select_all);
67   virtual void UpdateReloadStopState(bool is_loading, bool force);
68   virtual void UpdateToolbar(TabContentsWrapper* contents,
69                              bool should_restore_state);
70   virtual void FocusToolbar();
71   virtual void FocusAppMenu();
72   virtual void FocusBookmarksToolbar();
73   virtual void FocusChromeOSStatus();
74   virtual void RotatePaneFocus(bool forwards);
75   virtual bool IsBookmarkBarVisible() const;
76   virtual bool IsBookmarkBarAnimating() const;
77   virtual bool IsTabStripEditable() const;
78   virtual bool IsToolbarVisible() const;
79   virtual void DisableInactiveFrame();
80   virtual void ConfirmSetDefaultSearchProvider(
81       TabContents* tab_contents,
82       TemplateURL* template_url,
83       TemplateURLModel* template_url_model);
84   virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
85                                         Profile* profile);
86   virtual void ToggleBookmarkBar();
87   virtual void ShowAboutChromeDialog();
88   virtual void ShowUpdateChromeDialog();
89   virtual void ShowTaskManager();
90   virtual void ShowBackgroundPages();
91   virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked);
92   virtual bool IsDownloadShelfVisible() const;
93   virtual DownloadShelf* GetDownloadShelf();
94   virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
95   virtual void ShowCollectedCookiesDialog(TabContents* tab_contents);
96   virtual void ShowThemeInstallBubble();
97   virtual void ConfirmBrowserCloseWithPendingDownloads();
98   virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
99                               gfx::NativeWindow parent_window);
100   virtual void UserChangedTheme();
101   virtual int GetExtraRenderViewHeight() const;
102   virtual void TabContentsFocused(TabContents* tab_contents);
103   virtual void ShowPageInfo(Profile* profile,
104                             const GURL& url,
105                             const NavigationEntry::SSLStatus& ssl,
106                             bool show_history);
107   virtual void ShowAppMenu();
108   virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
109                                       bool* is_keyboard_shortcut);
110   virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
111   virtual void ShowCreateWebAppShortcutsDialog(
112       TabContentsWrapper* tab_contents);
113   virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
114                                                   const Extension* app);
115   virtual void Cut();
116   virtual void Copy();
117   virtual void Paste();
118   virtual void ToggleTabStripMode();
119 #if defined(OS_MACOSX)
120   virtual void OpenTabpose();
121 #endif
122   virtual void PrepareForInstant();
123   virtual void ShowInstant(TabContentsWrapper* preview);
124   virtual void HideInstant(bool instant_is_active);
125   virtual gfx::Rect GetInstantBounds();
126 #if defined(OS_CHROMEOS)
127   virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window);
128 #endif
129 
130   // Construct a native panel BrowserWindow implementation for the specified
131   // |browser|.
132   static BrowserWindow* CreateNativePanel(Browser* browser, Panel* panel);
133 
134  protected:
135   virtual void DestroyBrowser();
136 
137  private:
138   friend class PanelManager;
139 
140   // Panel can only be created using PanelManager::CreatePanel().
141   Panel(Browser* browser, const gfx::Rect& bounds);
142 
143   // Platform specifc BrowserWindow implementation for panels.  It'd be one of
144   // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa.
145   scoped_ptr<BrowserWindow> browser_window_;
146 
147   gfx::Rect bounds_;
148 
149   // Is the panel minimized?
150   bool minimized_;
151 
152   DISALLOW_COPY_AND_ASSIGN(Panel);
153 };
154 
155 #endif  // CHROME_BROWSER_UI_PANELS_PANEL_H_
156