| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 13 | 13 |
| 14 class Browser; | 14 class Browser; |
| 15 class ExtensionHost; | 15 class ExtensionHost; |
| 16 class RenderViewHost; | 16 class RenderViewHost; |
| 17 class RenderWidgetHostViewMac; |
| 17 class SkBitmap; | 18 class SkBitmap; |
| 18 | 19 |
| 19 // This class represents extension views. An extension view internally contains | 20 // This class represents extension views. An extension view internally contains |
| 20 // a bridge to an extension process, which draws to the extension view's | 21 // a bridge to an extension process, which draws to the extension view's |
| 21 // native view object through IPC. | 22 // native view object through IPC. |
| 22 class ExtensionViewMac { | 23 class ExtensionViewMac { |
| 23 public: | 24 public: |
| 24 ExtensionViewMac(ExtensionHost* extension_host, Browser* browser); | 25 ExtensionViewMac(ExtensionHost* extension_host, Browser* browser); |
| 25 ~ExtensionViewMac(); | 26 ~ExtensionViewMac(); |
| 26 | 27 |
| 27 // Starts the extension process and creates the native view. You must call | 28 // Starts the extension process and creates the native view. You must call |
| 28 // this method before calling any of this class's other methods. | 29 // this method before calling any of this class's other methods. |
| 29 void Init(); | 30 void Init(); |
| 30 | 31 |
| 31 // Returns the extension's native view. | 32 // Returns the extension's native view. |
| 32 gfx::NativeView native_view(); | 33 gfx::NativeView native_view(); |
| 33 | 34 |
| 34 // Returns the browser the extension belongs to. | 35 // Returns the browser the extension belongs to. |
| 35 Browser* browser() const { return browser_; } | 36 Browser* browser() const { return browser_; } |
| 36 | 37 |
| 37 // Method for the ExtensionHost to notify us that the extension page is | |
| 38 // loaded. | |
| 39 void DidStopLoading(); | |
| 40 | |
| 41 // Sets the extensions's background image. | 38 // Sets the extensions's background image. |
| 42 void SetBackground(const SkBitmap& background); | 39 void SetBackground(const SkBitmap& background); |
| 43 | 40 |
| 44 // Method for the ExtensionHost to notify us about the correct size for | 41 // Method for the ExtensionHost to notify us about the correct size for |
| 45 // extension contents. | 42 // extension contents. |
| 46 void UpdatePreferredSize(const gfx::Size& new_size); | 43 void UpdatePreferredSize(const gfx::Size& new_size); |
| 47 | 44 |
| 48 // Method for the ExtensionHost to notify us when the RenderViewHost has a | 45 // Method for the ExtensionHost to notify us when the RenderViewHost has a |
| 49 // connection. | 46 // connection. |
| 50 void RenderViewCreated(); | 47 void RenderViewCreated(); |
| 51 | 48 |
| 52 // Informs the view that its containing window's frame changed. | 49 // Informs the view that its containing window's frame changed. |
| 53 void WindowFrameChanged(); | 50 void WindowFrameChanged(); |
| 54 | 51 |
| 55 // The minimum/maximum dimensions of the popup. | 52 // The minimum/maximum dimensions of the popup. |
| 56 // The minimum is just a little larger than the size of the button itself. | 53 // The minimum is just a little larger than the size of the button itself. |
| 57 // The maximum is an arbitrary number that should be smaller than most | 54 // The maximum is an arbitrary number that should be smaller than most |
| 58 // screens. | 55 // screens. |
| 59 static const CGFloat kMinWidth; | 56 static const CGFloat kMinWidth; |
| 60 static const CGFloat kMinHeight; | 57 static const CGFloat kMinHeight; |
| 61 static const CGFloat kMaxWidth; | 58 static const CGFloat kMaxWidth; |
| 62 static const CGFloat kMaxHeight; | 59 static const CGFloat kMaxHeight; |
| 63 | 60 |
| 64 private: | 61 private: |
| 65 RenderViewHost* render_view_host() const; | 62 RenderViewHost* render_view_host() const; |
| 66 | 63 |
| 67 void CreateWidgetHostView(); | 64 void CreateWidgetHostView(); |
| 68 | 65 |
| 69 // We wait to show the ExtensionView until several things have loaded. | |
| 70 void ShowIfCompletelyLoaded(); | |
| 71 | |
| 72 Browser* browser_; // weak | 66 Browser* browser_; // weak |
| 73 | 67 |
| 74 ExtensionHost* extension_host_; // weak | 68 ExtensionHost* extension_host_; // weak |
| 75 | 69 |
| 70 // Created by us, but owned by its |native_view()|. We |release| the |
| 71 // rwhv's native view in our destructor, effectively freeing this. |
| 72 RenderWidgetHostViewMac* render_widget_host_view_; |
| 73 |
| 76 // The background the view should have once it is initialized. This is set | 74 // The background the view should have once it is initialized. This is set |
| 77 // when the view has a custom background, but hasn't been initialized yet. | 75 // when the view has a custom background, but hasn't been initialized yet. |
| 78 SkBitmap pending_background_; | 76 SkBitmap pending_background_; |
| 79 | 77 |
| 80 // What we should set the preferred width to once the ExtensionView has | |
| 81 // loaded. | |
| 82 gfx::Size pending_preferred_size_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac); | 78 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac); |
| 85 }; | 79 }; |
| 86 | 80 |
| 87 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ | 81 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ |
| OLD | NEW |