• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_
7 #pragma once
8 
9 #include "base/compiler_specific.h"
10 #include "content/browser/tab_contents/constrained_window.h"
11 #include "ui/gfx/native_widget_types.h"
12 #include "ui/gfx/rect.h"
13 
14 class ConstrainedTabContentsWindowDelegate;
15 class ConstrainedWindowAnimation;
16 class ConstrainedWindowFrameView;
17 namespace views {
18 class NativeWindow;
19 class NonClientFrameView;
20 class Window;
21 class WindowDelegate;
22 }
23 
24 class NativeConstrainedWindowDelegate {
25  public:
~NativeConstrainedWindowDelegate()26   virtual ~NativeConstrainedWindowDelegate() {}
27 
28   // Called after the NativeConstrainedWindow has been destroyed and is about to
29   // be deleted.
30   virtual void OnNativeConstrainedWindowDestroyed() = 0;
31 
32   // Called when the NativeConstrainedWindow is clicked on when inactive.
33   virtual void OnNativeConstrainedWindowMouseActivate() = 0;
34 
35   // Creates the frame view for the constrained window.
36   // TODO(beng): remove once ConstrainedWindowViews is-a views::Window.
37   virtual views::NonClientFrameView* CreateFrameViewForWindow() = 0;
38 };
39 
40 class NativeConstrainedWindow {
41  public:
~NativeConstrainedWindow()42   virtual ~NativeConstrainedWindow() {}
43 
44   // Creates a platform-specific implementation of NativeConstrainedWindow.
45   // TODO(beng): Remove WindowDelegate param once ConstrainedWindowViews is-a
46   //             views::Window.
47   static NativeConstrainedWindow* CreateNativeConstrainedWindow(
48       NativeConstrainedWindowDelegate* delegate,
49       views::WindowDelegate* window_delegate);
50 
51   virtual void InitNativeConstrainedWindow(gfx::NativeView parent) = 0;
52 
53   virtual views::NativeWindow* AsNativeWindow() = 0;
54 };
55 
56 ///////////////////////////////////////////////////////////////////////////////
57 // ConstrainedWindowViews
58 //
59 //  A ConstrainedWindow implementation that implements a Constrained Window as
60 //  a child HWND with a custom window frame.
61 //
62 class ConstrainedWindowViews : public ConstrainedWindow,
63                                public NativeConstrainedWindowDelegate {
64  public:
65   ConstrainedWindowViews(TabContents* owner,
66                          views::WindowDelegate* window_delegate);
67   virtual ~ConstrainedWindowViews();
68 
69   // Returns the TabContents that constrains this Constrained Window.
owner()70   TabContents* owner() const { return owner_; }
71 
72   views::Window* GetWindow();
73 
74   // Overridden from ConstrainedWindow:
75   virtual void ShowConstrainedWindow() OVERRIDE;
76   virtual void CloseConstrainedWindow() OVERRIDE;
77   virtual void FocusConstrainedWindow() OVERRIDE;
78 
79  private:
80   // Overridden from NativeConstrainedWindowDelegate:
81   virtual void OnNativeConstrainedWindowDestroyed() OVERRIDE;
82   virtual void OnNativeConstrainedWindowMouseActivate() OVERRIDE;
83   virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
84 
85   // The TabContents that owns and constrains this ConstrainedWindow.
86   TabContents* owner_;
87 
88   NativeConstrainedWindow* native_constrained_window_;
89 
90   DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews);
91 };
92 
93 #endif  // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_
94