Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / content / public / browser / web_contents_view.h
blobd0a7309145a1f24196e12a1355bebbb880567a48
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/process_util.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"
17 struct WebDropData;
19 namespace content {
21 // The WebContentsView is an interface that is implemented by the platform-
22 // dependent web contents views. The WebContents uses this interface to talk to
23 // them.
24 class CONTENT_EXPORT WebContentsView {
25 public:
26 virtual ~WebContentsView() {}
28 // Returns the native widget that contains the contents of the tab.
29 virtual gfx::NativeView GetNativeView() const = 0;
31 // Returns the native widget with the main content of the tab (i.e. the main
32 // render view host, though there may be many popups in the tab as children of
33 // the container).
34 virtual gfx::NativeView GetContentNativeView() const = 0;
36 // Returns the outermost native view. This will be used as the parent for
37 // dialog boxes.
38 virtual gfx::NativeWindow GetTopLevelNativeWindow() const = 0;
40 // Computes the rectangle for the native widget that contains the contents of
41 // the tab in the screen coordinate system.
42 virtual void GetContainerBounds(gfx::Rect* out) const = 0;
44 // Helper function for GetContainerBounds. Most callers just want to know the
45 // size, and this makes it more clear.
46 gfx::Size GetContainerSize() const {
47 gfx::Rect rc;
48 GetContainerBounds(&rc);
49 return gfx::Size(rc.width(), rc.height());
52 // Used to notify the view that a tab has crashed.
53 virtual void OnTabCrashed(base::TerminationStatus status, int error_code) = 0;
55 // TODO(brettw) this is a hack. It's used in two places at the time of this
56 // writing: (1) when render view hosts switch, we need to size the replaced
57 // one to be correct, since it wouldn't have known about sizes that happened
58 // while it was hidden; (2) in constrained windows.
60 // (1) will be fixed once interstitials are cleaned up. (2) seems like it
61 // should be cleaned up or done some other way, since this works for normal
62 // WebContents without the special code.
63 virtual void SizeContents(const gfx::Size& size) = 0;
65 // Sets focus to the native widget for this tab.
66 virtual void Focus() = 0;
68 // Sets focus to the appropriate element when the WebContents is shown the
69 // first time.
70 virtual void SetInitialFocus() = 0;
72 // Stores the currently focused view.
73 virtual void StoreFocus() = 0;
75 // Restores focus to the last focus view. If StoreFocus has not yet been
76 // invoked, SetInitialFocus is invoked.
77 virtual void RestoreFocus() = 0;
79 // Returns the current drop data, if any.
80 virtual WebDropData* GetDropData() const = 0;
82 // Get the bounds of the View, relative to the parent.
83 virtual gfx::Rect GetViewBounds() const = 0;
85 #if defined(OS_MACOSX)
86 // The web contents view assumes that its view will never be overlapped by
87 // another view (either partially or fully). This allows it to perform
88 // optimizations. If the view is in a view hierarchy where it might be
89 // overlapped by another view, notify the view by calling this with |true|
90 // before it draws for the first time. After the first draw, do not change
91 // this setting.
92 virtual void SetAllowOverlappingViews(bool overlapping) = 0;
93 #endif
96 } // namespace content
98 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_