Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / extension_view_mac.h
blobe74135ae30ad0c5246e96fe177dc19ebd0de7055
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"
16 class Browser;
17 class SkBitmap;
19 namespace content {
20 class RenderViewHost;
23 namespace extensions {
24 class ExtensionHost;
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 {
31 public:
32 class Container {
33 public:
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
43 // screens.
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(content::WebContents* web_contents,
65 const gfx::Size& new_size) override;
66 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
67 void HandleKeyboardEvent(
68 content::WebContents* source,
69 const content::NativeWebKeyboardEvent& event) override;
70 void DidStopLoading() override;
72 private:
73 content::RenderViewHost* render_view_host() const;
75 // We wait to show the ExtensionView until several things have loaded.
76 void ShowIfCompletelyLoaded();
78 Browser* browser_; // weak
80 extensions::ExtensionHost* extension_host_; // weak
82 // What we should set the preferred width to once the ExtensionView has
83 // loaded.
84 gfx::Size pending_preferred_size_;
86 Container* container_;
88 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac);
91 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_