summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/webview_host.h
blob: 2f09dec565f002b68442424f4d2e92fd75ab3624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_
#define WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_

#include <map>

#include "base/basictypes.h"
#include "gfx/native_widget_types.h"
#include "gfx/rect.h"
#include "webkit/tools/test_shell/webwidget_host.h"

#if defined(TOOLKIT_USES_GTK)
#include "webkit/glue/plugins/gtk_plugin_container_manager.h"
#endif

struct WebPreferences;
class TestWebViewDelegate;

namespace WebKit {
class WebView;
}

// This class is a simple NativeView-based host for a WebView
class WebViewHost : public WebWidgetHost {
 public:
  // The new instance is deleted once the associated NativeView is destroyed.
  // The newly created window should be resized after it is created, using the
  // MoveWindow (or equivalent) function.
  static WebViewHost* Create(gfx::NativeView parent_view,
                             TestWebViewDelegate* delegate,
                             const WebPreferences& prefs);

  WebKit::WebView* webview() const;

#if defined(TOOLKIT_USES_GTK)
  // Create a new plugin parent container for a given plugin XID.
  void CreatePluginContainer(gfx::PluginWindowHandle id);

  // Destroy the plugin parent container when a plugin has been destroyed.
  void DestroyPluginContainer(gfx::PluginWindowHandle id);

  GtkPluginContainerManager* plugin_container_manager() {
    return &plugin_container_manager_;
  }
#elif defined(OS_MACOSX)
  void SetIsActive(bool active);
#endif

 protected:
#if defined(OS_WIN)
  virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
    return false;
  }
#endif

#if defined(TOOLKIT_USES_GTK)
  // Helper class that creates and moves plugin containers.
  GtkPluginContainerManager plugin_container_manager_;
#endif
};

#endif  // WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_