| OLD | NEW |
| (Empty) |
| 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: | |
| 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 PanelCut() = 0; | |
| 49 virtual void PanelCopy() = 0; | |
| 50 virtual void PanelPaste() = 0; | |
| 51 virtual void DrawAttention(bool draw_attention) = 0; | |
| 52 virtual bool IsDrawingAttention() const = 0; | |
| 53 virtual void HandlePanelKeyboardEvent( | |
| 54 const content::NativeWebKeyboardEvent& event) = 0; | |
| 55 virtual void FullScreenModeChanged(bool is_full_screen) = 0; | |
| 56 virtual void PanelExpansionStateChanging(Panel::ExpansionState old_state, | |
| 57 Panel::ExpansionState new_state) = 0; | |
| 58 virtual void AttachWebContents(content::WebContents* contents) = 0; | |
| 59 virtual void DetachWebContents(content::WebContents* contents) = 0; | |
| 60 | |
| 61 // Returns the exterior size of the panel window given the client content | |
| 62 // size and vice versa. | |
| 63 virtual gfx::Size WindowSizeFromContentSize( | |
| 64 const gfx::Size& content_size) const = 0; | |
| 65 virtual gfx::Size ContentSizeFromWindowSize( | |
| 66 const gfx::Size& window_size) const = 0; | |
| 67 | |
| 68 virtual int TitleOnlyHeight() const = 0; | |
| 69 | |
| 70 // Gets or sets whether the panel window is always on top. | |
| 71 virtual bool IsPanelAlwaysOnTop() const = 0; | |
| 72 virtual void SetPanelAlwaysOnTop(bool on_top) = 0; | |
| 73 | |
| 74 // Updates the visibility of the minimize and restore buttons. | |
| 75 virtual void UpdatePanelMinimizeRestoreButtonVisibility() = 0; | |
| 76 | |
| 77 // Sets how the panel window displays its 4 corners, rounded or not. | |
| 78 virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) = 0; | |
| 79 | |
| 80 // Performs the system minimize for the panel, i.e. becoming iconic. | |
| 81 virtual void MinimizePanelBySystem() = 0; | |
| 82 | |
| 83 // Returns true if the panel has been minimized by the system, i.e. becoming | |
| 84 // iconic. | |
| 85 virtual bool IsPanelMinimizedBySystem() const = 0; | |
| 86 | |
| 87 // Returns true if the panel is shown in the active desktop. The user could | |
| 88 // create and use multiple virtual desktops or workspaces. | |
| 89 virtual bool IsPanelShownOnActiveDesktop() const = 0; | |
| 90 | |
| 91 // Turns on/off the shadow effect around the window shape. | |
| 92 virtual void ShowShadow(bool show) = 0; | |
| 93 | |
| 94 // Create testing interface for native panel. (Keep this last to separate | |
| 95 // it from regular API.) | |
| 96 virtual NativePanelTesting* CreateNativePanelTesting() = 0; | |
| 97 }; | |
| 98 | |
| 99 // A NativePanel utility interface used for accessing elements of the | |
| 100 // native panel used only by test automation. | |
| 101 class NativePanelTesting { | |
| 102 public: | |
| 103 virtual ~NativePanelTesting() {} | |
| 104 | |
| 105 // Wrappers for the common cases when no modifier is needed. | |
| 106 void PressLeftMouseButtonTitlebar(const gfx::Point& mouse_location) { | |
| 107 PressLeftMouseButtonTitlebar(mouse_location, panel::NO_MODIFIER); | |
| 108 } | |
| 109 void ReleaseMouseButtonTitlebar() { | |
| 110 ReleaseMouseButtonTitlebar(panel::NO_MODIFIER); | |
| 111 } | |
| 112 | |
| 113 // |mouse_location| is in screen coordinates. | |
| 114 virtual void PressLeftMouseButtonTitlebar( | |
| 115 const gfx::Point& mouse_location, panel::ClickModifier modifier) = 0; | |
| 116 virtual void ReleaseMouseButtonTitlebar(panel::ClickModifier modifier) = 0; | |
| 117 virtual void DragTitlebar(const gfx::Point& mouse_location) = 0; | |
| 118 virtual void CancelDragTitlebar() = 0; | |
| 119 virtual void FinishDragTitlebar() = 0; | |
| 120 | |
| 121 // Verifies, on a deepest possible level, if the Panel is showing the "Draw | |
| 122 // Attention" effects to the user. May include checking colors etc. | |
| 123 virtual bool VerifyDrawingAttention() const = 0; | |
| 124 // Verifies, on a deepest possible level, if the native panel is really | |
| 125 // active, i.e. the titlebar is painted per its active state. | |
| 126 virtual bool VerifyActiveState(bool is_active) = 0; | |
| 127 // Verifies, on a deepest possible level, if the native panel is really | |
| 128 // showing a correct app icon (taskbar icon). | |
| 129 virtual bool VerifyAppIcon() const = 0; | |
| 130 // Verifies, on a deepest possible level, if the native panel is really | |
| 131 // minimized by the system. | |
| 132 virtual bool VerifySystemMinimizeState() const = 0; | |
| 133 | |
| 134 virtual bool IsWindowVisible() const = 0; | |
| 135 virtual bool IsWindowSizeKnown() const = 0; | |
| 136 virtual bool IsAnimatingBounds() const = 0; | |
| 137 virtual bool IsButtonVisible(panel::TitlebarButtonType button_type) const = 0; | |
| 138 | |
| 139 virtual panel::CornerStyle GetWindowCornerStyle() const = 0; | |
| 140 | |
| 141 // Makes sure that the application is running on foreground. Returns false | |
| 142 // if the effort fails. | |
| 143 virtual bool EnsureApplicationRunOnForeground() = 0; | |
| 144 }; | |
| 145 | |
| 146 #endif // CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_H_ | |
| OLD | NEW |