extension_view_gtk.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_
6#define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_
7#pragma once
8
9#include "base/basictypes.h"
10#include "third_party/skia/include/core/SkBitmap.h"
11#include "ui/gfx/native_widget_types.h"
12#include "ui/gfx/size.h"
13
14class Browser;
15class ExtensionHost;
16class RenderViewHost;
17class RenderWidgetHostViewGtk;
18class SkBitmap;
19
20class ExtensionViewGtk {
21 public:
22  ExtensionViewGtk(ExtensionHost* extension_host, Browser* browser);
23
24  class Container {
25   public:
26    virtual ~Container() {}
27    virtual void OnExtensionPreferredSizeChanged(ExtensionViewGtk* view,
28                                                 const gfx::Size& new_size) {}
29  };
30
31  void Init();
32
33  gfx::NativeView native_view();
34  Browser* browser() const { return browser_; }
35
36  void SetBackground(const SkBitmap& background);
37
38  // Sets the container for this view.
39  void SetContainer(Container* container) { container_ = container; }
40
41  // Method for the ExtensionHost to notify us about the correct size for
42  // extension contents.
43  void UpdatePreferredSize(const gfx::Size& new_size);
44
45  // Method for the ExtensionHost to notify us when the RenderViewHost has a
46  // connection.
47  void RenderViewCreated();
48
49  RenderViewHost* render_view_host() const;
50
51 private:
52  void CreateWidgetHostView();
53
54  Browser* browser_;
55
56  ExtensionHost* extension_host_;
57
58  RenderWidgetHostViewGtk* render_widget_host_view_;
59
60  // The background the view should have once it is initialized. This is set
61  // when the view has a custom background, but hasn't been initialized yet.
62  SkBitmap pending_background_;
63
64  // This view's container.
65  Container* container_;
66
67  DISALLOW_COPY_AND_ASSIGN(ExtensionViewGtk);
68};
69
70#endif  // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_
71