| 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_WINDOW_COCOA_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_COCOA_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 #include "base/gtest_prod_util.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "chrome/browser/ui/panels/native_panel_cocoa.h" | |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "ui/gfx/rect.h" | |
| 16 | |
| 17 class Browser; | |
| 18 class Panel; | |
| 19 @class PanelWindowControllerCocoa; | |
| 20 | |
| 21 // An implementation of BrowserWindow for native Panel in Cocoa. | |
| 22 // Bridges between C++ and the Cocoa NSWindow. Cross-platform code will | |
| 23 // interact with this object when it needs to manipulate the window. | |
| 24 | |
| 25 class PanelBrowserWindowCocoa : public NativePanelCocoa, | |
| 26 public TabStripModelObserver, | |
| 27 public content::NotificationObserver { | |
| 28 public: | |
| 29 PanelBrowserWindowCocoa(Browser* browser, Panel* panel, | |
| 30 const gfx::Rect& bounds); | |
| 31 virtual ~PanelBrowserWindowCocoa(); | |
| 32 | |
| 33 // Overridden from NativePanel | |
| 34 virtual void ShowPanel() OVERRIDE; | |
| 35 virtual void ShowPanelInactive() OVERRIDE; | |
| 36 virtual gfx::Rect GetPanelBounds() const OVERRIDE; | |
| 37 virtual void SetPanelBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 38 virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) OVERRIDE; | |
| 39 virtual void ClosePanel() OVERRIDE; | |
| 40 virtual void ActivatePanel() OVERRIDE; | |
| 41 virtual void DeactivatePanel() OVERRIDE; | |
| 42 virtual bool IsPanelActive() const OVERRIDE; | |
| 43 virtual void PreventActivationByOS(bool prevent_activation) OVERRIDE; | |
| 44 virtual gfx::NativeWindow GetNativePanelHandle() OVERRIDE; | |
| 45 virtual void UpdatePanelTitleBar() OVERRIDE; | |
| 46 virtual void UpdatePanelLoadingAnimations(bool should_animate) OVERRIDE; | |
| 47 virtual void ShowTaskManagerForPanel() OVERRIDE; | |
| 48 virtual FindBar* CreatePanelFindBar() OVERRIDE; | |
| 49 virtual void NotifyPanelOnUserChangedTheme() OVERRIDE; | |
| 50 virtual void PanelWebContentsFocused(content::WebContents* contents) OVERRIDE; | |
| 51 virtual void PanelCut() OVERRIDE; | |
| 52 virtual void PanelCopy() OVERRIDE; | |
| 53 virtual void PanelPaste() OVERRIDE; | |
| 54 virtual void DrawAttention(bool draw_attention) OVERRIDE; | |
| 55 virtual bool IsDrawingAttention() const OVERRIDE; | |
| 56 virtual bool PreHandlePanelKeyboardEvent( | |
| 57 const content::NativeWebKeyboardEvent& event, | |
| 58 bool* is_keyboard_shortcut) OVERRIDE; | |
| 59 virtual void HandlePanelKeyboardEvent( | |
| 60 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
| 61 virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE; | |
| 62 virtual Browser* GetPanelBrowser() const OVERRIDE; | |
| 63 virtual void DestroyPanelBrowser() OVERRIDE; | |
| 64 virtual void EnsurePanelFullyVisible() OVERRIDE; | |
| 65 virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE; | |
| 66 virtual void EnableResizeByMouse(bool enable) OVERRIDE; | |
| 67 virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE; | |
| 68 virtual void PanelExpansionStateChanging( | |
| 69 Panel::ExpansionState old_state, | |
| 70 Panel::ExpansionState new_state) OVERRIDE; | |
| 71 virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; | |
| 72 | |
| 73 // These sizes are in screen coordinates. | |
| 74 virtual gfx::Size WindowSizeFromContentSize( | |
| 75 const gfx::Size& content_size) const OVERRIDE; | |
| 76 virtual gfx::Size ContentSizeFromWindowSize( | |
| 77 const gfx::Size& window_size) const OVERRIDE; | |
| 78 virtual int TitleOnlyHeight() const OVERRIDE; | |
| 79 | |
| 80 // Overridden from TabStripModelObserver. | |
| 81 virtual void TabInsertedAt(TabContents* contents, | |
| 82 int index, | |
| 83 bool foreground) OVERRIDE; | |
| 84 virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE; | |
| 85 | |
| 86 // Overridden from NotificationObserver. | |
| 87 virtual void Observe(int type, | |
| 88 const content::NotificationSource& source, | |
| 89 const content::NotificationDetails& details) OVERRIDE; | |
| 90 | |
| 91 // Overridden from NativePanelCocoa. | |
| 92 virtual Panel* panel() const OVERRIDE; | |
| 93 virtual void DidCloseNativeWindow() OVERRIDE; | |
| 94 | |
| 95 private: | |
| 96 friend class PanelBrowserWindowCocoaTest; | |
| 97 friend class NativePanelTestingCocoa; | |
| 98 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, CreateClose); | |
| 99 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, NativeBounds); | |
| 100 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, TitlebarViewCreate); | |
| 101 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, TitlebarViewSizing); | |
| 102 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, TitlebarViewClose); | |
| 103 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, MenuItems); | |
| 104 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, KeyEvent); | |
| 105 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, ThemeProvider); | |
| 106 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, SetTitle); | |
| 107 FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, ActivatePanel); | |
| 108 | |
| 109 bool isClosed(); | |
| 110 | |
| 111 void setBoundsInternal(const gfx::Rect& bounds, bool animate); | |
| 112 | |
| 113 scoped_ptr<Browser> browser_; | |
| 114 scoped_ptr<Panel> panel_; | |
| 115 | |
| 116 // These use platform-independent screen coordinates, with (0,0) at | |
| 117 // top-left of the primary screen. They have to be converted to Cocoa | |
| 118 // screen coordinates before calling Cocoa API. | |
| 119 gfx::Rect bounds_; | |
| 120 | |
| 121 PanelWindowControllerCocoa* controller_; // Weak, owns us. | |
| 122 bool is_shown_; // Panel is hidden on creation, Show() changes that forever. | |
| 123 bool has_find_bar_; // Find bar should only be created once per panel. | |
| 124 NSInteger attention_request_id_; // identifier from requestUserAttention. | |
| 125 | |
| 126 content::NotificationRegistrar registrar_; | |
| 127 | |
| 128 DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowCocoa); | |
| 129 }; | |
| 130 | |
| 131 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_COCOA_H_ | |
| OLD | NEW |