| 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_PANEL_BROWSER_VIEW_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_VIEW_H_ | |
| 7 | |
| 8 #include "base/gtest_prod_util.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "chrome/browser/ui/panels/native_panel.h" | |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "ui/base/animation/animation_delegate.h" | |
| 15 | |
| 16 class Browser; | |
| 17 class NativePanelTestingWin; | |
| 18 class Panel; | |
| 19 class PanelBoundsAnimation; | |
| 20 class PanelBrowserFrameView; | |
| 21 class TaskbarWindowThumbnailerWin; | |
| 22 | |
| 23 // A browser view that implements Panel specific behavior. | |
| 24 class PanelBrowserView : public BrowserView, | |
| 25 public content::NotificationObserver, | |
| 26 public NativePanel, | |
| 27 public ui::AnimationDelegate { | |
| 28 public: | |
| 29 PanelBrowserView(Browser* browser, Panel* panel, const gfx::Rect& bounds); | |
| 30 virtual ~PanelBrowserView(); | |
| 31 | |
| 32 Panel* panel() const { return panel_.get(); } | |
| 33 bool closed() const { return closed_; } | |
| 34 bool focused() const { return focused_; } | |
| 35 bool force_to_paint_as_inactive() const { | |
| 36 return force_to_paint_as_inactive_; | |
| 37 } | |
| 38 | |
| 39 PanelBrowserFrameView* GetFrameView() const; | |
| 40 | |
| 41 // Called from frame view when titlebar receives a mouse event. | |
| 42 // Return true if the event is handled. | |
| 43 // |mouse_location| is in screen coordinates. | |
| 44 bool OnTitlebarMousePressed(const gfx::Point& mouse_location); | |
| 45 bool OnTitlebarMouseDragged(const gfx::Point& mouse_location); | |
| 46 bool OnTitlebarMouseReleased(panel::ClickModifier modifier); | |
| 47 bool OnTitlebarMouseCaptureLost(); | |
| 48 | |
| 49 private: | |
| 50 friend class NativePanelTestingWin; | |
| 51 friend class PanelBrowserViewTest; | |
| 52 | |
| 53 enum MouseDraggingState { | |
| 54 NO_DRAGGING, | |
| 55 DRAGGING_STARTED, | |
| 56 DRAGGING_ENDED | |
| 57 }; | |
| 58 | |
| 59 // Overridden from BrowserView: | |
| 60 virtual void Init() OVERRIDE; | |
| 61 virtual void Show() OVERRIDE; | |
| 62 virtual void ShowInactive() OVERRIDE; | |
| 63 virtual void Close() OVERRIDE; | |
| 64 virtual void Deactivate() OVERRIDE; | |
| 65 virtual bool CanResize() const OVERRIDE; | |
| 66 virtual bool CanMaximize() const OVERRIDE; | |
| 67 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 68 virtual void UpdateTitleBar() OVERRIDE; | |
| 69 virtual bool IsPanel() const OVERRIDE; | |
| 70 virtual bool GetSavedWindowPlacement( | |
| 71 gfx::Rect* bounds, | |
| 72 ui::WindowShowState* show_state) const OVERRIDE; | |
| 73 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 74 | |
| 75 // Overridden from NotificationObserver: | |
| 76 virtual void Observe(int type, | |
| 77 const content::NotificationSource& source, | |
| 78 const content::NotificationDetails& details) OVERRIDE; | |
| 79 | |
| 80 // Overridden from views::WidgetDelegate: | |
| 81 virtual void OnDisplayChanged() OVERRIDE; | |
| 82 virtual void OnWorkAreaChanged() OVERRIDE; | |
| 83 virtual bool WillProcessWorkAreaChange() const OVERRIDE; | |
| 84 virtual void OnWindowBeginUserBoundsChange() OVERRIDE; | |
| 85 virtual void OnWindowEndUserBoundsChange() OVERRIDE; | |
| 86 | |
| 87 // Overridden from views::WidgetObserver: | |
| 88 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
| 89 bool active) OVERRIDE; | |
| 90 | |
| 91 // Overridden from NativePanel: | |
| 92 virtual void ShowPanel() OVERRIDE; | |
| 93 virtual void ShowPanelInactive() OVERRIDE; | |
| 94 virtual gfx::Rect GetPanelBounds() const OVERRIDE; | |
| 95 virtual void SetPanelBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 96 virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) OVERRIDE; | |
| 97 virtual void ClosePanel() OVERRIDE; | |
| 98 virtual void ActivatePanel() OVERRIDE; | |
| 99 virtual void DeactivatePanel() OVERRIDE; | |
| 100 virtual bool IsPanelActive() const OVERRIDE; | |
| 101 virtual void PreventActivationByOS(bool prevent_activation) OVERRIDE; | |
| 102 virtual gfx::NativeWindow GetNativePanelHandle() OVERRIDE; | |
| 103 virtual void UpdatePanelTitleBar() OVERRIDE; | |
| 104 virtual void UpdatePanelLoadingAnimations(bool should_animate) OVERRIDE; | |
| 105 virtual void ShowTaskManagerForPanel() OVERRIDE; | |
| 106 virtual FindBar* CreatePanelFindBar() OVERRIDE; | |
| 107 virtual void NotifyPanelOnUserChangedTheme() OVERRIDE; | |
| 108 virtual void PanelWebContentsFocused(content::WebContents* contents) OVERRIDE; | |
| 109 virtual void PanelCut() OVERRIDE; | |
| 110 virtual void PanelCopy() OVERRIDE; | |
| 111 virtual void PanelPaste() OVERRIDE; | |
| 112 virtual void DrawAttention(bool draw_attention) OVERRIDE; | |
| 113 virtual bool IsDrawingAttention() const OVERRIDE; | |
| 114 virtual bool PreHandlePanelKeyboardEvent( | |
| 115 const content::NativeWebKeyboardEvent& event, | |
| 116 bool* is_keyboard_shortcut) OVERRIDE; | |
| 117 virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE; | |
| 118 virtual void HandlePanelKeyboardEvent( | |
| 119 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
| 120 virtual gfx::Size WindowSizeFromContentSize( | |
| 121 const gfx::Size& content_size) const OVERRIDE; | |
| 122 virtual gfx::Size ContentSizeFromWindowSize( | |
| 123 const gfx::Size& window_size) const OVERRIDE; | |
| 124 virtual int TitleOnlyHeight() const OVERRIDE; | |
| 125 virtual Browser* GetPanelBrowser() const OVERRIDE; | |
| 126 virtual void DestroyPanelBrowser() OVERRIDE; | |
| 127 virtual void EnsurePanelFullyVisible() OVERRIDE; | |
| 128 virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE; | |
| 129 virtual void EnableResizeByMouse(bool enable) OVERRIDE; | |
| 130 virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE; | |
| 131 virtual void PanelExpansionStateChanging( | |
| 132 Panel::ExpansionState old_state, | |
| 133 Panel::ExpansionState new_state) OVERRIDE; | |
| 134 virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; | |
| 135 | |
| 136 // Overridden from AnimationDelegate: | |
| 137 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
| 138 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
| 139 | |
| 140 bool EndDragging(bool cancelled); | |
| 141 | |
| 142 void SetBoundsInternal(const gfx::Rect& bounds, bool animate); | |
| 143 | |
| 144 void ShowOrHidePanelAppIcon(bool show); | |
| 145 | |
| 146 bool IsAnimatingBounds() const; | |
| 147 | |
| 148 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 149 // Sets or clears the bitwise |attribute_value| for the attibute denoted by | |
| 150 // |attribute_index|. This is used to update the style or extended style | |
| 151 // for the native window. | |
| 152 void UpdateWindowAttribute(int attribute_index, | |
| 153 int attribute_value, | |
| 154 bool to_set); | |
| 155 #endif | |
| 156 | |
| 157 scoped_ptr<Panel> panel_; | |
| 158 gfx::Rect bounds_; | |
| 159 | |
| 160 // Is the panel being closed? Do not use it when it is closed. | |
| 161 bool closed_; | |
| 162 | |
| 163 // Is the panel receiving the focus? | |
| 164 bool focused_; | |
| 165 | |
| 166 // Is the mouse button currently down? | |
| 167 bool mouse_pressed_; | |
| 168 | |
| 169 // Location the mouse was pressed at or dragged to last time when we process | |
| 170 // the mouse event. Used in drag-and-drop. | |
| 171 // This point is represented in the screen coordinate system. | |
| 172 gfx::Point last_mouse_location_; | |
| 173 | |
| 174 // Is the titlebar currently being dragged? That is, has the cursor | |
| 175 // moved more than kDragThreshold away from its starting position? | |
| 176 MouseDraggingState mouse_dragging_state_; | |
| 177 | |
| 178 // Used to animate the bounds change. | |
| 179 scoped_ptr<PanelBoundsAnimation> bounds_animator_; | |
| 180 gfx::Rect animation_start_bounds_; | |
| 181 | |
| 182 // Is the panel in highlighted state to draw people's attention? | |
| 183 bool is_drawing_attention_; | |
| 184 | |
| 185 // Should we force to paint the panel as inactive? This is needed when we need | |
| 186 // to capture the screenshot before an active panel goes minimized. | |
| 187 bool force_to_paint_as_inactive_; | |
| 188 | |
| 189 // The last view that had focus in the panel. This is saved so that focus can | |
| 190 // be restored properly when a drag ends. | |
| 191 views::View* old_focused_view_; | |
| 192 | |
| 193 content::NotificationRegistrar registrar_; | |
| 194 | |
| 195 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) | |
| 196 // Used to provide custom taskbar thumbnail for Windows 7 and later. | |
| 197 scoped_ptr<TaskbarWindowThumbnailerWin> thumbnailer_; | |
| 198 #endif | |
| 199 | |
| 200 DISALLOW_COPY_AND_ASSIGN(PanelBrowserView); | |
| 201 }; | |
| 202 | |
| 203 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_VIEW_H_ | |
| OLD | NEW |