[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / panels / panel_stack_window_cocoa.h
blob442044c9a14528d65e40bde4772e30903604367c
1 // Copyright (c) 2013 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_STACK_WINDOW_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_PANELS_PANEL_STACK_WINDOW_COCOA_H_
8 #import <Cocoa/Cocoa.h>
10 #include <list>
11 #include <map>
13 #include "base/basictypes.h"
14 #include "base/mac/scoped_nsobject.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "chrome/browser/ui/panels/native_panel_stack_window.h"
17 #include "ui/gfx/rect.h"
19 @class BatchBoundsAnimationDelegate;
20 class Panel;
21 class PanelStackWindowCocoa;
23 // A native window that acts as the owner of all/partial panels in the stack,
24 // in order to make these panels appear as a single window.
25 class PanelStackWindowCocoa : public NativePanelStackWindow {
26 public:
27 explicit PanelStackWindowCocoa(NativePanelStackWindowDelegate* delegate);
28 virtual ~PanelStackWindowCocoa();
30 // Notified by BatchBoundsAnimationDelegate about the ending of the bounds
31 // animation.
32 void BoundsUpdateAnimationEnded();
34 protected:
35 // Overridden from NativePanelStackWindow:
36 virtual void Close() OVERRIDE;
37 virtual void AddPanel(Panel* panel) OVERRIDE;
38 virtual void RemovePanel(Panel* panel) OVERRIDE;
39 virtual void MergeWith(NativePanelStackWindow* another) OVERRIDE;
40 virtual bool IsEmpty() const OVERRIDE;
41 virtual bool HasPanel(Panel* panel) const OVERRIDE;
42 virtual void MovePanelsBy(const gfx::Vector2d& delta) OVERRIDE;
43 virtual void BeginBatchUpdatePanelBounds(bool animate) OVERRIDE;
44 virtual void AddPanelBoundsForBatchUpdate(Panel* panel,
45 const gfx::Rect& bounds) OVERRIDE;
46 virtual void EndBatchUpdatePanelBounds() OVERRIDE;
47 virtual bool IsAnimatingPanelBounds() const OVERRIDE;
48 virtual void Minimize() OVERRIDE;
49 virtual bool IsMinimized() const OVERRIDE;
50 virtual void DrawSystemAttention(bool draw_attention) OVERRIDE;
51 virtual void OnPanelActivated(Panel* panel) OVERRIDE;
53 private:
54 typedef std::list<Panel*> Panels;
56 // The map value is old bounds of the panel.
57 typedef std::map<Panel*, gfx::Rect> BoundsUpdates;
59 // Terminates current bounds animation, if any.
60 void TerminateBoundsAnimation();
62 // Computes/updates the minimum bounds that could fit all panels.
63 gfx::Rect GetStackWindowBounds() const;
64 void UpdateStackWindowBounds();
66 // Ensures that the background window is created.
67 void EnsureWindowCreated();
69 // Weak pointer. Owned by PanelManager.
70 NativePanelStackWindowDelegate* delegate_;
72 // The underlying window.
73 base::scoped_nsobject<NSWindow> window_;
75 Panels panels_;
77 // Identifier from requestUserAttention.
78 NSInteger attention_request_id_;
80 // For batch bounds update.
81 bool bounds_updates_started_;
82 bool animate_bounds_updates_;
83 BoundsUpdates bounds_updates_;
85 // Used to animate the bounds changes at a synchronized pace.
86 // Lifetime controlled manually, needs more than just |release| to terminate.
87 NSViewAnimation* bounds_animation_;
88 base::scoped_nsobject<BatchBoundsAnimationDelegate>
89 bounds_animation_delegate_;
91 DISALLOW_COPY_AND_ASSIGN(PanelStackWindowCocoa);
94 #endif // CHROME_BROWSER_UI_COCOA_PANELS_PANEL_STACK_WINDOW_COCOA_H_