| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "chrome/browser/extensions/extension_view.h" | |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 13 | 12 |
| 13 class Browser; |
| 14 class SkBitmap; |
| 15 |
| 16 namespace content { |
| 17 class RenderViewHost; |
| 18 } |
| 19 |
| 20 namespace extensions { |
| 21 class ExtensionHost; |
| 22 } |
| 23 |
| 14 // This class represents extension views. An extension view internally contains | 24 // This class represents extension views. An extension view internally contains |
| 15 // a bridge to an extension process, which draws to the extension view's | 25 // a bridge to an extension process, which draws to the extension view's |
| 16 // native view object through IPC. | 26 // native view object through IPC. |
| 17 class ExtensionViewMac : public ExtensionView { | 27 class ExtensionViewMac { |
| 18 public: | 28 public: |
| 29 class Container { |
| 30 public: |
| 31 virtual ~Container() {} |
| 32 virtual void OnExtensionSizeChanged(ExtensionViewMac* view, |
| 33 const gfx::Size& new_size) {} |
| 34 virtual void OnExtensionViewDidShow(ExtensionViewMac* view) {}; |
| 35 }; |
| 36 |
| 19 ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser); | 37 ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser); |
| 20 virtual ~ExtensionViewMac(); | 38 ~ExtensionViewMac(); |
| 21 | 39 |
| 22 // Starts the extension process and creates the native view. You must call | 40 // Starts the extension process and creates the native view. You must call |
| 23 // this method before calling any of this class's other methods. | 41 // this method before calling any of this class's other methods. |
| 24 void Init(); | 42 void Init(); |
| 25 | 43 |
| 44 // Returns the extension's native view. |
| 45 gfx::NativeView native_view(); |
| 46 |
| 47 // Returns the browser the extension belongs to. |
| 48 Browser* browser() const { return browser_; } |
| 49 |
| 50 // Method for the ExtensionHost to notify us that the extension page is |
| 51 // loaded. |
| 52 void DidStopLoading(); |
| 53 |
| 26 // Sets the extensions's background image. | 54 // Sets the extensions's background image. |
| 27 void SetBackground(const SkBitmap& background); | 55 void SetBackground(const SkBitmap& background); |
| 28 | 56 |
| 57 // Sets the container for this view. |
| 58 void set_container(Container* container) { container_ = container; } |
| 59 |
| 60 // Method for the ExtensionHost to notify us about the correct size for |
| 61 // extension contents. |
| 62 void ResizeDueToAutoResize(const gfx::Size& new_size); |
| 63 |
| 64 // Method for the ExtensionHost to notify us when the RenderViewHost has a |
| 65 // connection. |
| 66 void RenderViewCreated(); |
| 67 |
| 68 // Informs the view that its containing window's frame changed. |
| 69 void WindowFrameChanged(); |
| 70 |
| 29 // The minimum/maximum dimensions of the popup. | 71 // The minimum/maximum dimensions of the popup. |
| 30 // The minimum is just a little larger than the size of the button itself. | 72 // The minimum is just a little larger than the size of the button itself. |
| 31 // The maximum is an arbitrary number that should be smaller than most | 73 // The maximum is an arbitrary number that should be smaller than most |
| 32 // screens. | 74 // screens. |
| 33 static const CGFloat kMinWidth; | 75 static const CGFloat kMinWidth; |
| 34 static const CGFloat kMinHeight; | 76 static const CGFloat kMinHeight; |
| 35 static const CGFloat kMaxWidth; | 77 static const CGFloat kMaxWidth; |
| 36 static const CGFloat kMaxHeight; | 78 static const CGFloat kMaxHeight; |
| 37 | 79 |
| 38 private: | 80 private: |
| 39 // Overridden from ExtensionView: | 81 content::RenderViewHost* render_view_host() const; |
| 40 virtual Browser* GetBrowser() OVERRIDE; | |
| 41 virtual const Browser* GetBrowser() const OVERRIDE; | |
| 42 virtual gfx::NativeView GetNativeView() OVERRIDE; | |
| 43 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; | |
| 44 virtual void SetContainer(ExtensionViewContainer* container) OVERRIDE; | |
| 45 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE; | |
| 46 virtual void RenderViewCreated() OVERRIDE; | |
| 47 virtual void DidStopLoading() OVERRIDE; | |
| 48 virtual void WindowFrameChanged() OVERRIDE; | |
| 49 | 82 |
| 50 void CreateWidgetHostView(); | 83 void CreateWidgetHostView(); |
| 51 | 84 |
| 52 // We wait to show the ExtensionView until several things have loaded. | 85 // We wait to show the ExtensionView until several things have loaded. |
| 53 void ShowIfCompletelyLoaded(); | 86 void ShowIfCompletelyLoaded(); |
| 54 | 87 |
| 55 Browser* browser_; // weak | 88 Browser* browser_; // weak |
| 56 | 89 |
| 57 extensions::ExtensionHost* extension_host_; // weak | 90 extensions::ExtensionHost* extension_host_; // weak |
| 58 | 91 |
| 59 // The background the view should have once it is initialized. This is set | 92 // The background the view should have once it is initialized. This is set |
| 60 // when the view has a custom background, but hasn't been initialized yet. | 93 // when the view has a custom background, but hasn't been initialized yet. |
| 61 SkBitmap pending_background_; | 94 SkBitmap pending_background_; |
| 62 | 95 |
| 63 // What we should set the preferred width to once the ExtensionView has | 96 // What we should set the preferred width to once the ExtensionView has |
| 64 // loaded. | 97 // loaded. |
| 65 gfx::Size pending_preferred_size_; | 98 gfx::Size pending_preferred_size_; |
| 66 | 99 |
| 67 ExtensionViewContainer* container_; // weak | 100 Container* container_; |
| 68 | 101 |
| 69 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac); | 102 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac); |
| 70 }; | 103 }; |
| 71 | 104 |
| 72 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ | 105 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ |
| OLD | NEW |