1 // Copyright (c) 2012 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_NATIVE_PANEL_H_ 6 #define CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_H_ 7 8 #include "chrome/browser/ui/panels/panel.h" 9 #include "chrome/browser/ui/panels/panel_constants.h" 10 #include "ui/gfx/native_widget_types.h" 11 12 class NativePanelTesting; 13 14 namespace content { 15 struct NativeWebKeyboardEvent; 16 class WebContents; 17 } 18 19 namespace gfx { 20 class Rect; 21 } // namespace gfx 22 23 // An interface for a class that implements platform-specific behavior for panel 24 // windows to provide additional methods not found in ui::BaseWindow. 25 class NativePanel { 26 friend class BasePanelBrowserTest; // for CreateNativePanelTesting 27 friend class Panel; 28 friend class PanelBrowserWindow; 29 friend class PanelBrowserTest; 30 friend class PanelExtensionBrowserTest; 31 32 protected: ~NativePanel()33 virtual ~NativePanel() {} 34 35 virtual void ShowPanel() = 0; 36 virtual void ShowPanelInactive() = 0; 37 virtual gfx::Rect GetPanelBounds() const = 0; 38 virtual void SetPanelBounds(const gfx::Rect& bounds) = 0; 39 virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) = 0; 40 virtual void ClosePanel() = 0; 41 virtual void ActivatePanel() = 0; 42 virtual void DeactivatePanel() = 0; 43 virtual bool IsPanelActive() const = 0; 44 virtual void PreventActivationByOS(bool prevent_activation) = 0; 45 virtual gfx::NativeWindow GetNativePanelWindow() = 0; 46 virtual void UpdatePanelTitleBar() = 0; 47 virtual void UpdatePanelLoadingAnimations(bool should_animate) = 0; 48 virtual void PanelWebContentsFocused(content::WebContents* contents) = 0; 49 virtual void PanelCut() = 0; 50 virtual void PanelCopy() = 0; 51 virtual void PanelPaste() = 0; 52 virtual void DrawAttention(bool draw_attention) = 0; 53 virtual bool IsDrawingAttention() const = 0; 54 virtual void HandlePanelKeyboardEvent( 55 const content::NativeWebKeyboardEvent& event) = 0; 56 virtual void FullScreenModeChanged(bool is_full_screen) = 0; 57 virtual void PanelExpansionStateChanging(Panel::ExpansionState old_state, 58 Panel::ExpansionState new_state) = 0; 59 virtual void AttachWebContents(content::WebContents* contents) = 0; 60 virtual void DetachWebContents(content::WebContents* contents) = 0; 61 62 // Returns the exterior size of the panel window given the client content 63 // size and vice versa. 64 virtual gfx::Size WindowSizeFromContentSize( 65 const gfx::Size& content_size) const = 0; 66 virtual gfx::Size ContentSizeFromWindowSize( 67 const gfx::Size& window_size) const = 0; 68 69 virtual int TitleOnlyHeight() const = 0; 70 71 // Gets or sets whether the panel window is always on top. 72 virtual bool IsPanelAlwaysOnTop() const = 0; 73 virtual void SetPanelAlwaysOnTop(bool on_top) = 0; 74 75 // Updates the visibility of the minimize and restore buttons. 76 virtual void UpdatePanelMinimizeRestoreButtonVisibility() = 0; 77 78 // Sets how the panel window displays its 4 corners, rounded or not. 79 virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) = 0; 80 81 // Performs the system minimize for the panel, i.e. becoming iconic. 82 virtual void MinimizePanelBySystem() = 0; 83 84 // Returns true if the panel has been minimized by the system, i.e. becoming 85 // iconic. 86 virtual bool IsPanelMinimizedBySystem() const = 0; 87 88 // Returns true if the panel is shown in the active desktop. The user could 89 // create and use multiple virtual desktops or workspaces. 90 virtual bool IsPanelShownOnActiveDesktop() const = 0; 91 92 // Turns on/off the shadow effect around the window shape. 93 virtual void ShowShadow(bool show) = 0; 94 95 // Create testing interface for native panel. (Keep this last to separate 96 // it from regular API.) 97 virtual NativePanelTesting* CreateNativePanelTesting() = 0; 98 }; 99 100 // A NativePanel utility interface used for accessing elements of the 101 // native panel used only by test automation. 102 class NativePanelTesting { 103 public: ~NativePanelTesting()104 virtual ~NativePanelTesting() {} 105 106 // Wrappers for the common cases when no modifier is needed. PressLeftMouseButtonTitlebar(const gfx::Point & mouse_location)107 void PressLeftMouseButtonTitlebar(const gfx::Point& mouse_location) { 108 PressLeftMouseButtonTitlebar(mouse_location, panel::NO_MODIFIER); 109 } ReleaseMouseButtonTitlebar()110 void ReleaseMouseButtonTitlebar() { 111 ReleaseMouseButtonTitlebar(panel::NO_MODIFIER); 112 } 113 114 // |mouse_location| is in screen coordinates. 115 virtual void PressLeftMouseButtonTitlebar( 116 const gfx::Point& mouse_location, panel::ClickModifier modifier) = 0; 117 virtual void ReleaseMouseButtonTitlebar(panel::ClickModifier modifier) = 0; 118 virtual void DragTitlebar(const gfx::Point& mouse_location) = 0; 119 virtual void CancelDragTitlebar() = 0; 120 virtual void FinishDragTitlebar() = 0; 121 122 // Verifies, on a deepest possible level, if the Panel is showing the "Draw 123 // Attention" effects to the user. May include checking colors etc. 124 virtual bool VerifyDrawingAttention() const = 0; 125 // Verifies, on a deepest possible level, if the native panel is really 126 // active, i.e. the titlebar is painted per its active state. 127 virtual bool VerifyActiveState(bool is_active) = 0; 128 // Verifies, on a deepest possible level, if the native panel is really 129 // showing a correct app icon (taskbar icon). 130 virtual bool VerifyAppIcon() const = 0; 131 // Verifies, on a deepest possible level, if the native panel is really 132 // minimized by the system. 133 virtual bool VerifySystemMinimizeState() const = 0; 134 135 virtual bool IsWindowVisible() const = 0; 136 virtual bool IsWindowSizeKnown() const = 0; 137 virtual bool IsAnimatingBounds() const = 0; 138 virtual bool IsButtonVisible(panel::TitlebarButtonType button_type) const = 0; 139 140 virtual panel::CornerStyle GetWindowCornerStyle() const = 0; 141 142 // Makes sure that the application is running on foreground. Returns false 143 // if the effort fails. 144 virtual bool EnsureApplicationRunOnForeground() = 0; 145 }; 146 147 #endif // CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_H_ 148