BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / panels / panel_cocoa.h
blobdc530d41ad7b0ccc4b58fe2e7e5aa11830862c13
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.
5 #ifndef CHROME_BROWSER_UI_COCOA_PANELS_PANEL_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_PANELS_PANEL_COCOA_H_
8 #import <Foundation/Foundation.h>
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/ui/panels/native_panel.h"
11 #include "ui/gfx/geometry/rect.h"
13 class Panel;
14 @class PanelWindowControllerCocoa;
16 // An implememtation of the native panel in Cocoa.
17 // Bridges between C++ and the Cocoa NSWindow. Cross-platform code will
18 // interact with this object when it needs to manipulate the window.
19 class PanelCocoa : public NativePanel {
20 public:
21 PanelCocoa(Panel* panel, const gfx::Rect& bounds, bool always_on_top);
22 ~PanelCocoa() override;
24 // Overridden from NativePanel
25 void ShowPanel() override;
26 void ShowPanelInactive() override;
27 gfx::Rect GetPanelBounds() const override;
28 void SetPanelBounds(const gfx::Rect& bounds) override;
29 void SetPanelBoundsInstantly(const gfx::Rect& bounds) override;
30 void ClosePanel() override;
31 void ActivatePanel() override;
32 void DeactivatePanel() override;
33 bool IsPanelActive() const override;
34 void PreventActivationByOS(bool prevent_activation) override;
35 gfx::NativeWindow GetNativePanelWindow() override;
36 void UpdatePanelTitleBar() override;
37 void UpdatePanelLoadingAnimations(bool should_animate) override;
38 void PanelCut() override;
39 void PanelCopy() override;
40 void PanelPaste() override;
41 void DrawAttention(bool draw_attention) override;
42 bool IsDrawingAttention() const override;
43 void HandlePanelKeyboardEvent(
44 const content::NativeWebKeyboardEvent& event) override;
45 void FullScreenModeChanged(bool is_full_screen) override;
46 bool IsPanelAlwaysOnTop() const override;
47 void SetPanelAlwaysOnTop(bool on_top) override;
48 void UpdatePanelMinimizeRestoreButtonVisibility() override;
49 void SetWindowCornerStyle(panel::CornerStyle corner_style) override;
50 void PanelExpansionStateChanging(Panel::ExpansionState old_state,
51 Panel::ExpansionState new_state) override;
52 void AttachWebContents(content::WebContents* contents) override;
53 void DetachWebContents(content::WebContents* contents) override;
55 // These sizes are in screen coordinates.
56 gfx::Size WindowSizeFromContentSize(
57 const gfx::Size& content_size) const override;
58 gfx::Size ContentSizeFromWindowSize(
59 const gfx::Size& window_size) const override;
60 int TitleOnlyHeight() const override;
62 void MinimizePanelBySystem() override;
63 bool IsPanelMinimizedBySystem() const override;
64 bool IsPanelShownOnActiveDesktop() const override;
65 void ShowShadow(bool show) override;
66 NativePanelTesting* CreateNativePanelTesting() override;
68 Panel* panel() const;
69 void DidCloseNativeWindow();
71 bool IsClosed() const;
73 // PanelStackWindowCocoa might want to update the stored bounds directly since
74 // it has already taken care of updating the window bounds directly.
75 void set_cached_bounds_directly(const gfx::Rect& bounds) { bounds_ = bounds; }
77 private:
78 friend class CocoaNativePanelTesting;
79 friend class PanelCocoaTest;
80 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, CreateClose);
81 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, NativeBounds);
82 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewCreate);
83 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewSizing);
84 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewClose);
85 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, MenuItems);
86 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, KeyEvent);
87 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, ThemeProvider);
88 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, SetTitle);
89 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, ActivatePanel);
91 void setBoundsInternal(const gfx::Rect& bounds, bool animate);
93 scoped_ptr<Panel> panel_;
94 PanelWindowControllerCocoa* controller_; // Weak, owns us.
96 // These use platform-independent screen coordinates, with (0,0) at
97 // top-left of the primary screen. They have to be converted to Cocoa
98 // screen coordinates before calling Cocoa API.
99 gfx::Rect bounds_;
101 // True if the panel should always stay on top of other windows.
102 bool always_on_top_;
104 bool is_shown_; // Panel is hidden on creation, Show() changes that forever.
105 NSInteger attention_request_id_; // identifier from requestUserAttention.
107 // Indicates how the window corner should be rendered, rounded or not.
108 panel::CornerStyle corner_style_;
110 DISALLOW_COPY_AND_ASSIGN(PanelCocoa);
113 #endif // CHROME_BROWSER_UI_COCOA_PANELS_PANEL_COCOA_H_