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