Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / extensions / extension_view_views.h
blobf3b88546d0d83400d5a0e25b7bed970c15fecc7e
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_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/extensions/extension_view.h"
10 #include "content/public/browser/native_web_keyboard_event.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
13 #include "ui/views/controls/webview/webview.h"
15 class Browser;
17 namespace content {
18 class RenderViewHost;
21 namespace extensions {
22 class ExtensionHost;
25 // This handles the display portion of an ExtensionHost.
26 class ExtensionViewViews : public views::WebView,
27 public extensions::ExtensionView {
28 public:
29 // A class that represents the container that this view is in.
30 // (bottom shelf, side bar, etc.)
31 class Container {
32 public:
33 virtual ~Container() {}
35 virtual void OnExtensionSizeChanged(ExtensionViewViews* view) {}
38 ExtensionViewViews(extensions::ExtensionHost* host, Browser* browser);
39 ~ExtensionViewViews() override;
41 // extensions::ExtensionView:
42 Browser* GetBrowser() override;
44 // views::WebView:
45 void SetVisible(bool is_visible) override;
47 void set_minimum_size(const gfx::Size& minimum_size) {
48 minimum_size_ = minimum_size;
50 void set_container(Container* container) { container_ = container; }
52 private:
53 friend class extensions::ExtensionHost;
55 // extensions::ExtensionView:
56 gfx::NativeView GetNativeView() override;
57 void ResizeDueToAutoResize(content::WebContents* web_contents,
58 const gfx::Size& new_size) override;
59 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
60 void HandleKeyboardEvent(
61 content::WebContents* source,
62 const content::NativeWebKeyboardEvent& event) override;
63 void DidStopLoading() override;
65 // views::WebView:
66 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
67 gfx::Size GetMinimumSize() const override;
68 void PreferredSizeChanged() override;
69 void OnWebContentsAttached() override;
71 // Note that host_ owns view
72 extensions::ExtensionHost* host_;
74 // The browser window that this view is in.
75 Browser* browser_;
77 // What we should set the preferred width to once the ExtensionViewViews has
78 // loaded.
79 gfx::Size pending_preferred_size_;
80 gfx::Size minimum_size_;
82 // The container this view is in (not necessarily its direct superview).
83 // Note: the view does not own its container.
84 Container* container_;
86 // A handler to handle unhandled keyboard messages coming back from the
87 // renderer process.
88 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
90 DISALLOW_COPY_AND_ASSIGN(ExtensionViewViews);
93 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_