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 CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_
10 #include "base/basictypes.h"
11 #include "base/process/kill.h"
12 #include "content/common/content_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
20 // The WebContentsView is an interface that is implemented by the platform-
21 // dependent web contents views. The WebContents uses this interface to talk to
23 class CONTENT_EXPORT WebContentsView
{
25 virtual ~WebContentsView() {}
27 // Returns the native widget that contains the contents of the tab.
28 virtual gfx::NativeView
GetNativeView() const = 0;
30 // Returns the native widget with the main content of the tab (i.e. the main
31 // render view host, though there may be many popups in the tab as children of
33 virtual gfx::NativeView
GetContentNativeView() const = 0;
35 // Returns the outermost native view. This will be used as the parent for
37 virtual gfx::NativeWindow
GetTopLevelNativeWindow() const = 0;
39 // Computes the rectangle for the native widget that contains the contents of
40 // the tab in the screen coordinate system.
41 virtual void GetContainerBounds(gfx::Rect
* out
) const = 0;
43 // Helper function for GetContainerBounds. Most callers just want to know the
44 // size, and this makes it more clear.
45 gfx::Size
GetContainerSize() const {
47 GetContainerBounds(&rc
);
48 return gfx::Size(rc
.width(), rc
.height());
51 // Used to notify the view that a tab has crashed.
52 virtual void OnTabCrashed(base::TerminationStatus status
, int error_code
) = 0;
54 // TODO(brettw) this is a hack. It's used in two places at the time of this
55 // writing: (1) when render view hosts switch, we need to size the replaced
56 // one to be correct, since it wouldn't have known about sizes that happened
57 // while it was hidden; (2) in constrained windows.
59 // (1) will be fixed once interstitials are cleaned up. (2) seems like it
60 // should be cleaned up or done some other way, since this works for normal
61 // WebContents without the special code.
62 virtual void SizeContents(const gfx::Size
& size
) = 0;
64 // Sets focus to the native widget for this tab.
65 virtual void Focus() = 0;
67 // Sets focus to the appropriate element when the WebContents is shown the
69 virtual void SetInitialFocus() = 0;
71 // Stores the currently focused view.
72 virtual void StoreFocus() = 0;
74 // Restores focus to the last focus view. If StoreFocus has not yet been
75 // invoked, SetInitialFocus is invoked.
76 virtual void RestoreFocus() = 0;
78 // Returns the current drop data, if any.
79 virtual DropData
* GetDropData() const = 0;
81 // Get the bounds of the View, relative to the parent.
82 virtual gfx::Rect
GetViewBounds() const = 0;
84 #if defined(OS_MACOSX)
85 // The web contents view assumes that its view will never be overlapped by
86 // another view (either partially or fully). This allows it to perform
87 // optimizations. If the view is in a view hierarchy where it might be
88 // overlapped by another view, notify the view by calling this with |true|.
89 virtual void SetAllowOverlappingViews(bool overlapping
) = 0;
91 // Returns true if overlapping views are allowed, false otherwise.
92 virtual bool GetAllowOverlappingViews() const = 0;
96 } // namespace content
98 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_