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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
8 #include <ApplicationServices/ApplicationServices.h>
10 #include "base/basictypes.h"
11 #include "chrome/browser/extensions/extension_view.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/native_widget_types.h"
23 namespace extensions
{
27 // This class represents extension views. An extension view internally contains
28 // a bridge to an extension process, which draws to the extension view's
29 // native view object through IPC.
30 class ExtensionViewMac
: public extensions::ExtensionView
{
34 virtual ~Container() {}
35 virtual void OnExtensionSizeChanged(ExtensionViewMac
* view
,
36 const gfx::Size
& new_size
) {}
37 virtual void OnExtensionViewDidShow(ExtensionViewMac
* view
) {};
40 // The minimum/maximum dimensions of the popup.
41 // The minimum is just a little larger than the size of the button itself.
42 // The maximum is an arbitrary number that should be smaller than most
44 static const CGFloat kMinWidth
;
45 static const CGFloat kMinHeight
;
46 static const CGFloat kMaxWidth
;
47 static const CGFloat kMaxHeight
;
49 ExtensionViewMac(extensions::ExtensionHost
* extension_host
, Browser
* browser
);
50 ~ExtensionViewMac() override
;
52 // Sets the container for this view.
53 void set_container(Container
* container
) { container_
= container
; }
55 // Informs the view that its containing window's frame changed.
56 void WindowFrameChanged();
58 // Create the host view, adding it as a subview of |superview|.
59 void CreateWidgetHostViewIn(gfx::NativeView superview
);
61 // extensions::ExtensionView:
62 Browser
* GetBrowser() override
;
63 gfx::NativeView
GetNativeView() override
;
64 void ResizeDueToAutoResize(const gfx::Size
& new_size
) override
;
65 void RenderViewCreated() override
;
66 void HandleKeyboardEvent(
67 content::WebContents
* source
,
68 const content::NativeWebKeyboardEvent
& event
) override
;
69 void DidStopLoading() override
;
72 content::RenderViewHost
* render_view_host() const;
74 // We wait to show the ExtensionView until several things have loaded.
75 void ShowIfCompletelyLoaded();
77 Browser
* browser_
; // weak
79 extensions::ExtensionHost
* extension_host_
; // weak
81 // What we should set the preferred width to once the ExtensionView has
83 gfx::Size pending_preferred_size_
;
85 Container
* container_
;
87 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac
);
90 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_