[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / extension_view_mac.h
blob5a81f5a5ee5c5706dd5d3bbf57c9994905a93e06
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 "base/basictypes.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/gfx/size.h"
13 class Browser;
14 class SkBitmap;
16 namespace content {
17 class RenderViewHost;
20 namespace extensions {
21 class ExtensionHost;
24 // 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 // native view object through IPC.
27 class ExtensionViewMac {
28 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) {};
37 ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser);
38 ~ExtensionViewMac();
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();
44 // Returns the extension's native view.
45 gfx::NativeView native_view();
47 // Returns the browser the extension belongs to.
48 Browser* browser() const { return browser_; }
50 // Method for the ExtensionHost to notify us that the extension page is
51 // loaded.
52 void DidStopLoading();
54 // Sets the container for this view.
55 void set_container(Container* container) { container_ = container; }
57 // Method for the ExtensionHost to notify us about the correct size for
58 // extension contents.
59 void ResizeDueToAutoResize(const gfx::Size& new_size);
61 // Method for the ExtensionHost to notify us when the RenderViewHost has a
62 // connection.
63 void RenderViewCreated();
65 // Informs the view that its containing window's frame changed.
66 void WindowFrameChanged();
68 // The minimum/maximum dimensions of the popup.
69 // 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
71 // screens.
72 static const CGFloat kMinWidth;
73 static const CGFloat kMinHeight;
74 static const CGFloat kMaxWidth;
75 static const CGFloat kMaxHeight;
77 private:
78 content::RenderViewHost* render_view_host() const;
80 void CreateWidgetHostView();
82 // We wait to show the ExtensionView until several things have loaded.
83 void ShowIfCompletelyLoaded();
85 Browser* browser_; // weak
87 extensions::ExtensionHost* extension_host_; // weak
89 // What we should set the preferred width to once the ExtensionView has
90 // loaded.
91 gfx::Size pending_preferred_size_;
93 Container* container_;
95 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac);
98 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_