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