[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / panels / panel_cocoa.h
bloba453341cff40d5ca747a2b0a7ece901dcf785974
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/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 virtual ~PanelCocoa();
24 // Overridden from NativePanel
25 virtual void ShowPanel() OVERRIDE;
26 virtual void ShowPanelInactive() OVERRIDE;
27 virtual gfx::Rect GetPanelBounds() const OVERRIDE;
28 virtual void SetPanelBounds(const gfx::Rect& bounds) OVERRIDE;
29 virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) OVERRIDE;
30 virtual void ClosePanel() OVERRIDE;
31 virtual void ActivatePanel() OVERRIDE;
32 virtual void DeactivatePanel() OVERRIDE;
33 virtual bool IsPanelActive() const OVERRIDE;
34 virtual void PreventActivationByOS(bool prevent_activation) OVERRIDE;
35 virtual gfx::NativeWindow GetNativePanelWindow() OVERRIDE;
36 virtual void UpdatePanelTitleBar() OVERRIDE;
37 virtual void UpdatePanelLoadingAnimations(bool should_animate) OVERRIDE;
38 virtual void PanelWebContentsFocused(content::WebContents* contents) OVERRIDE;
39 virtual void PanelCut() OVERRIDE;
40 virtual void PanelCopy() OVERRIDE;
41 virtual void PanelPaste() OVERRIDE;
42 virtual void DrawAttention(bool draw_attention) OVERRIDE;
43 virtual bool IsDrawingAttention() const OVERRIDE;
44 virtual void HandlePanelKeyboardEvent(
45 const content::NativeWebKeyboardEvent& event) OVERRIDE;
46 virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
47 virtual bool IsPanelAlwaysOnTop() const OVERRIDE;
48 virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE;
49 virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE;
50 virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE;
51 virtual void PanelExpansionStateChanging(
52 Panel::ExpansionState old_state,
53 Panel::ExpansionState new_state) OVERRIDE;
54 virtual void AttachWebContents(content::WebContents* contents) OVERRIDE;
55 virtual void DetachWebContents(content::WebContents* contents) OVERRIDE;
57 // These sizes are in screen coordinates.
58 virtual gfx::Size WindowSizeFromContentSize(
59 const gfx::Size& content_size) const OVERRIDE;
60 virtual gfx::Size ContentSizeFromWindowSize(
61 const gfx::Size& window_size) const OVERRIDE;
62 virtual int TitleOnlyHeight() const OVERRIDE;
64 virtual void MinimizePanelBySystem() OVERRIDE;
65 virtual bool IsPanelMinimizedBySystem() const OVERRIDE;
66 virtual bool IsPanelShownOnActiveDesktop() const OVERRIDE;
67 virtual void ShowShadow(bool show) OVERRIDE;
68 virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE;
70 Panel* panel() const;
71 void DidCloseNativeWindow();
73 bool IsClosed() const;
75 // PanelStackWindowCocoa might want to update the stored bounds directly since
76 // it has already taken care of updating the window bounds directly.
77 void set_cached_bounds_directly(const gfx::Rect& bounds) { bounds_ = bounds; }
79 private:
80 friend class CocoaNativePanelTesting;
81 friend class PanelCocoaTest;
82 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, CreateClose);
83 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, NativeBounds);
84 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewCreate);
85 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewSizing);
86 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, TitlebarViewClose);
87 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, MenuItems);
88 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, KeyEvent);
89 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, ThemeProvider);
90 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, SetTitle);
91 FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, ActivatePanel);
93 void setBoundsInternal(const gfx::Rect& bounds, bool animate);
95 scoped_ptr<Panel> panel_;
96 PanelWindowControllerCocoa* controller_; // Weak, owns us.
98 // These use platform-independent screen coordinates, with (0,0) at
99 // top-left of the primary screen. They have to be converted to Cocoa
100 // screen coordinates before calling Cocoa API.
101 gfx::Rect bounds_;
103 // True if the panel should always stay on top of other windows.
104 bool always_on_top_;
106 bool is_shown_; // Panel is hidden on creation, Show() changes that forever.
107 NSInteger attention_request_id_; // identifier from requestUserAttention.
109 // Indicates how the window corner should be rendered, rounded or not.
110 panel::CornerStyle corner_style_;
112 DISALLOW_COPY_AND_ASSIGN(PanelCocoa);
115 #endif // CHROME_BROWSER_UI_COCOA_PANELS_PANEL_COCOA_H_