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"
21 namespace extensions
{
25 // This handles the display portion of an ExtensionHost.
26 class ExtensionViewViews
: public views::WebView
,
27 public extensions::ExtensionView
{
29 // A class that represents the container that this view is in.
30 // (bottom shelf, side bar, etc.)
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
;
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
; }
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
;
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.
77 // What we should set the preferred width to once the ExtensionViewViews has
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
88 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_
;
90 DISALLOW_COPY_AND_ASSIGN(ExtensionViewViews
);
93 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_