Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef WM_FOREIGN_WINDOW_H_ | |
| 6 #define WM_FOREIGN_WINDOW_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "ui/views/widget/widget_delegate.h" | |
| 10 #include "wm/host/foreign_window_host_delegate.h" | |
| 11 | |
| 12 namespace views { | |
| 13 class ClientView; | |
| 14 } | |
| 15 | |
| 16 namespace wm { | |
| 17 class ForeignWindowClientView; | |
| 18 class ForeignWindowHost; | |
| 19 | |
| 20 class ForeignWindow : public base::RefCounted<ForeignWindow>, | |
| 21 public ForeignWindowHostDelegate, | |
| 22 public views::WidgetDelegate { | |
| 23 public: | |
| 24 enum DisplayState { | |
| 25 DISPLAY_NORMAL, | |
| 26 DISPLAY_ICONIC, | |
| 27 DISPLAY_WITHDRAWN | |
| 28 }; | |
| 29 struct CreateParams { | |
| 30 CreateParams(gfx::PluginWindowHandle window_handle, | |
| 31 gfx::Size preferred_size); | |
| 32 | |
| 33 gfx::PluginWindowHandle window_handle; | |
| 34 gfx::Size preferred_size; | |
| 35 }; | |
| 36 explicit ForeignWindow(const CreateParams& params); | |
| 37 | |
| 38 // Retrieves the ForeignWindow implementation associated with the | |
| 39 // given NativeView, or NULL if the supplied handle has no associated | |
| 40 // ForeignWindow. | |
| 41 static ForeignWindow* GetForeignWindowForNativeView( | |
| 42 gfx::NativeView native_view); | |
| 43 | |
| 44 // Overridden from wm::ForeignWindowHostDelegate: | |
| 45 virtual void OnWindowContentsChanged() OVERRIDE; | |
| 46 | |
| 47 // Overridden from views::WidgetDelegate: | |
| 48 virtual views::Widget* GetWidget() OVERRIDE; | |
| 49 virtual const views::Widget* GetWidget() const OVERRIDE; | |
| 50 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; | |
| 51 virtual void DeleteDelegate() OVERRIDE; | |
| 52 virtual bool CanResize() const OVERRIDE; | |
| 53 virtual bool CanMaximize() const OVERRIDE; | |
| 54 virtual bool CanActivate() const OVERRIDE; | |
| 55 | |
| 56 // Called by widget. Attempts to close the foreign window. | |
| 57 void Close(); | |
| 58 | |
| 59 // Create a new views::WidgetDelegate. | |
| 60 views::WidgetDelegate* CreateWidgetDelegate(); | |
| 61 | |
| 62 // Returns the window handle. | |
| 63 gfx::PluginWindowHandle GetWindowHandle() const; | |
| 64 | |
| 65 // Returns the native view. | |
| 66 gfx::NativeView GetNativeView() const; | |
| 67 | |
| 68 // Set foreign window display state. | |
| 69 void SetDisplayState(DisplayState state); | |
| 70 DisplayState GetDisplayState() const; | |
| 71 | |
| 72 // Returns true if foreign window is managed. | |
| 73 bool IsManaged() const; | |
| 74 | |
| 75 // Returns true if foreign window handle has been destroyed. | |
| 76 bool HasBeenDestroyed() const; | |
| 77 | |
| 78 // Called when foreign window size has changed. | |
| 79 void OnWindowSizeChanged(const gfx::Size& size); | |
|
danakj
2013/02/22 21:42:59
Ya this is much better, thanks.
| |
| 80 | |
| 81 // Called when foreign window visibility has changed. | |
| 82 void OnWindowVisibilityChanged(bool visible); | |
| 83 | |
| 84 // Called when foreign window has been destroyed. | |
| 85 void OnWindowDestroyed(); | |
| 86 | |
| 87 private: | |
| 88 friend class base::RefCounted<ForeignWindow>; | |
| 89 virtual ~ForeignWindow(); | |
| 90 | |
| 91 scoped_ptr<ForeignWindowHost> host_; | |
| 92 gfx::Size preferred_size_; | |
| 93 base::WeakPtr<ForeignWindowClientView> client_view_; | |
| 94 DisplayState display_state_; | |
| 95 bool destroyed_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(ForeignWindow); | |
| 98 }; | |
| 99 | |
| 100 } // namespace wm | |
| 101 | |
| 102 #endif // WM_FOREIGN_WINDOW_H_ | |
| OLD | NEW |