OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |
6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 class RenderWidgetHostView; | 43 class RenderWidgetHostView; |
44 class SessionStorageNamespace; | 44 class SessionStorageNamespace; |
45 class SiteInstance; | 45 class SiteInstance; |
46 class WebContentsDelegate; | 46 class WebContentsDelegate; |
47 class WebContentsView; | 47 class WebContentsView; |
48 struct RendererPreferences; | 48 struct RendererPreferences; |
49 | 49 |
50 // Describes what goes in the main content area of a tab. | 50 // Describes what goes in the main content area of a tab. |
51 class WebContents : public PageNavigator { | 51 class WebContents : public PageNavigator { |
52 public: | 52 public: |
53 // |base_tab_contents| is used if we want to size the new tab contents view | 53 // |base_tab_contents| is used if we want to size the new WebContents's view |
54 // based on an existing tab contents view. This can be NULL if not needed. | 54 // based on the view of an existing WebContents. This can be NULL if not |
| 55 // needed. |
55 // | 56 // |
56 // The session storage namespace parameter allows multiple render views and | 57 // The session storage namespace parameter allows multiple render views and |
57 // tab contentses to share the same session storage (part of the WebStorage | 58 // web contentses to share the same session storage (part of the WebStorage |
58 // spec) space. This is useful when restoring tabs, but most callers should | 59 // spec) space. This is useful when restoring tabs, but most callers should |
59 // pass in NULL which will cause a new SessionStorageNamespace to be created. | 60 // pass in NULL which will cause a new SessionStorageNamespace to be created. |
60 CONTENT_EXPORT static WebContents* Create( | 61 CONTENT_EXPORT static WebContents* Create( |
61 BrowserContext* browser_context, | 62 BrowserContext* browser_context, |
62 SiteInstance* site_instance, | 63 SiteInstance* site_instance, |
63 int routing_id, | 64 int routing_id, |
64 const WebContents* base_web_contents, | 65 const WebContents* base_web_contents, |
65 SessionStorageNamespace* session_storage_namespace); | 66 SessionStorageNamespace* session_storage_namespace); |
66 | 67 |
67 virtual ~WebContents() {} | 68 virtual ~WebContents() {} |
68 | 69 |
69 // Intrinsic tab state ------------------------------------------------------- | 70 // Intrinsic tab state ------------------------------------------------------- |
70 | 71 |
71 // Returns the property bag for this tab contents, where callers can add | 72 // Returns the property bag for this WebContents, where callers can add |
72 // extra data they may wish to associate with the tab. Returns a pointer | 73 // extra data they may wish to associate with the tab. Returns a pointer |
73 // rather than a reference since the PropertyAccessors expect this. | 74 // rather than a reference since the PropertyAccessors expect this. |
74 virtual const base::PropertyBag* GetPropertyBag() const = 0; | 75 virtual const base::PropertyBag* GetPropertyBag() const = 0; |
75 virtual base::PropertyBag* GetPropertyBag() = 0; | 76 virtual base::PropertyBag* GetPropertyBag() = 0; |
76 | 77 |
77 // Gets/Sets the delegate. | 78 // Gets/Sets the delegate. |
78 virtual WebContentsDelegate* GetDelegate() = 0; | 79 virtual WebContentsDelegate* GetDelegate() = 0; |
79 virtual void SetDelegate(WebContentsDelegate* delegate) = 0; | 80 virtual void SetDelegate(WebContentsDelegate* delegate) = 0; |
80 | 81 |
81 // Gets the controller for this tab contents. | 82 // Gets the controller for this WebContents. |
82 virtual NavigationController& GetController() = 0; | 83 virtual NavigationController& GetController() = 0; |
83 virtual const NavigationController& GetController() const = 0; | 84 virtual const NavigationController& GetController() const = 0; |
84 | 85 |
85 // Returns the user browser context associated with this WebContents (via the | 86 // Returns the user browser context associated with this WebContents (via the |
86 // NavigationController). | 87 // NavigationController). |
87 virtual content::BrowserContext* GetBrowserContext() const = 0; | 88 virtual content::BrowserContext* GetBrowserContext() const = 0; |
88 | 89 |
89 // Allows overriding the type of this tab. | 90 // Allows overriding the type of this tab. |
90 virtual void SetViewType(content::ViewType type) = 0; | 91 virtual void SetViewType(content::ViewType type) = 0; |
91 virtual content::ViewType GetViewType() const = 0; | 92 virtual content::ViewType GetViewType() const = 0; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // this WebContents. | 137 // this WebContents. |
137 virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0; | 138 virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0; |
138 | 139 |
139 // Returns the SiteInstance associated with the current page. | 140 // Returns the SiteInstance associated with the current page. |
140 virtual SiteInstance* GetSiteInstance() const = 0; | 141 virtual SiteInstance* GetSiteInstance() const = 0; |
141 | 142 |
142 // Returns the SiteInstance for the pending navigation, if any. Otherwise | 143 // Returns the SiteInstance for the pending navigation, if any. Otherwise |
143 // returns the current SiteInstance. | 144 // returns the current SiteInstance. |
144 virtual SiteInstance* GetPendingSiteInstance() const = 0; | 145 virtual SiteInstance* GetPendingSiteInstance() const = 0; |
145 | 146 |
146 // Return whether this tab contents is loading a resource. | 147 // Return whether this WebContents is loading a resource. |
147 virtual bool IsLoading() const = 0; | 148 virtual bool IsLoading() const = 0; |
148 | 149 |
149 // Returns whether this tab contents is waiting for a first-response for the | 150 // Returns whether this WebContents is waiting for a first-response for the |
150 // main resource of the page. | 151 // main resource of the page. |
151 virtual bool IsWaitingForResponse() const = 0; | 152 virtual bool IsWaitingForResponse() const = 0; |
152 | 153 |
153 // Return the current load state and the URL associated with it. | 154 // Return the current load state and the URL associated with it. |
154 virtual const net::LoadStateWithParam& GetLoadState() const = 0; | 155 virtual const net::LoadStateWithParam& GetLoadState() const = 0; |
155 virtual const string16& GetLoadStateHost() const = 0; | 156 virtual const string16& GetLoadStateHost() const = 0; |
156 | 157 |
157 // Return the upload progress. | 158 // Return the upload progress. |
158 virtual uint64 GetUploadSize() const = 0; | 159 virtual uint64 GetUploadSize() const = 0; |
159 virtual uint64 GetUploadPosition() const = 0; | 160 virtual uint64 GetUploadPosition() const = 0; |
160 | 161 |
161 // Return the character encoding of the page. | 162 // Return the character encoding of the page. |
162 virtual const std::string& GetEncoding() const = 0; | 163 virtual const std::string& GetEncoding() const = 0; |
163 | 164 |
164 // True if this is a secure page which displayed insecure content. | 165 // True if this is a secure page which displayed insecure content. |
165 virtual bool DisplayedInsecureContent() const = 0; | 166 virtual bool DisplayedInsecureContent() const = 0; |
166 | 167 |
167 // Internal state ------------------------------------------------------------ | 168 // Internal state ------------------------------------------------------------ |
168 | 169 |
169 // This flag indicates whether the tab contents is currently being | 170 // This flag indicates whether the WebContents is currently being |
170 // screenshotted by the DraggedTabController. | 171 // screenshotted. |
171 virtual void SetCapturingContents(bool cap) = 0; | 172 virtual void SetCapturingContents(bool cap) = 0; |
172 | 173 |
173 // Indicates whether this tab should be considered crashed. The setter will | 174 // Indicates whether this tab should be considered crashed. The setter will |
174 // also notify the delegate when the flag is changed. | 175 // also notify the delegate when the flag is changed. |
175 virtual bool IsCrashed() const = 0; | 176 virtual bool IsCrashed() const = 0; |
176 virtual void SetIsCrashed(base::TerminationStatus status, int error_code) = 0; | 177 virtual void SetIsCrashed(base::TerminationStatus status, int error_code) = 0; |
177 | 178 |
178 virtual base::TerminationStatus GetCrashedStatus() const = 0; | 179 virtual base::TerminationStatus GetCrashedStatus() const = 0; |
179 | 180 |
180 // Whether the tab is in the process of being destroyed. | 181 // Whether the tab is in the process of being destroyed. |
181 // Added as a tentative work-around for focus related bug #4633. This allows | 182 // Added as a tentative work-around for focus related bug #4633. This allows |
182 // us not to store focus when a tab is being closed. | 183 // us not to store focus when a tab is being closed. |
183 virtual bool IsBeingDestroyed() const = 0; | 184 virtual bool IsBeingDestroyed() const = 0; |
184 | 185 |
185 // Convenience method for notifying the delegate of a navigation state | 186 // Convenience method for notifying the delegate of a navigation state |
186 // change. See InvalidateType enum. | 187 // change. See InvalidateType enum. |
187 virtual void NotifyNavigationStateChanged(unsigned changed_flags) = 0; | 188 virtual void NotifyNavigationStateChanged(unsigned changed_flags) = 0; |
188 | 189 |
189 // Invoked when the tab contents becomes selected. If you override, be sure | 190 // Invoked when the WebContents becomes selected. If you override, be sure |
190 // and invoke super's implementation. | 191 // and invoke super's implementation. |
191 virtual void DidBecomeSelected() = 0; | 192 virtual void DidBecomeSelected() = 0; |
192 virtual base::TimeTicks GetLastSelectedTime() const = 0; | 193 virtual base::TimeTicks GetLastSelectedTime() const = 0; |
193 | 194 |
194 // Invoked when the tab contents becomes hidden. | 195 // Invoked when the WebContents becomes hidden. |
195 // NOTE: If you override this, call the superclass version too! | 196 // NOTE: If you override this, call the superclass version too! |
196 virtual void WasHidden() = 0; | 197 virtual void WasHidden() = 0; |
197 | 198 |
198 // TODO(brettw) document these. | 199 // TODO(brettw) document these. |
199 virtual void ShowContents() = 0; | 200 virtual void ShowContents() = 0; |
200 virtual void HideContents() = 0; | 201 virtual void HideContents() = 0; |
201 | 202 |
202 // Returns true if the before unload and unload listeners need to be | 203 // Returns true if the before unload and unload listeners need to be |
203 // fired. The value of this changes over time. For example, if true and the | 204 // fired. The value of this changes over time. For example, if true and the |
204 // before unload listener is executed and allows the user to exit, then this | 205 // before unload listener is executed and allows the user to exit, then this |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 virtual base::TimeTicks GetNewTabStartTime() const = 0; | 305 virtual base::TimeTicks GetNewTabStartTime() const = 0; |
305 | 306 |
306 // Notification that tab closing has started. This can be called multiple | 307 // Notification that tab closing has started. This can be called multiple |
307 // times, subsequent calls are ignored. | 308 // times, subsequent calls are ignored. |
308 virtual void OnCloseStarted() = 0; | 309 virtual void OnCloseStarted() = 0; |
309 | 310 |
310 // Returns true if underlying WebContentsView should accept drag-n-drop. | 311 // Returns true if underlying WebContentsView should accept drag-n-drop. |
311 virtual bool ShouldAcceptDragAndDrop() const = 0; | 312 virtual bool ShouldAcceptDragAndDrop() const = 0; |
312 | 313 |
313 // A render view-originated drag has ended. Informs the render view host and | 314 // A render view-originated drag has ended. Informs the render view host and |
314 // tab contents delegate. | 315 // WebContentsDelegate. |
315 virtual void SystemDragEnded() = 0; | 316 virtual void SystemDragEnded() = 0; |
316 | 317 |
317 // Indicates if this tab was explicitly closed by the user (control-w, close | 318 // Indicates if this tab was explicitly closed by the user (control-w, close |
318 // tab menu item...). This is false for actions that indirectly close the tab, | 319 // tab menu item...). This is false for actions that indirectly close the tab, |
319 // such as closing the window. The setter is maintained by TabStripModel, and | 320 // such as closing the window. The setter is maintained by TabStripModel, and |
320 // the getter only useful from within TAB_CLOSED notification | 321 // the getter only useful from within TAB_CLOSED notification |
321 virtual void SetClosedByUserGesture(bool value) = 0; | 322 virtual void SetClosedByUserGesture(bool value) = 0; |
322 virtual bool GetClosedByUserGesture() const = 0; | 323 virtual bool GetClosedByUserGesture() const = 0; |
323 | 324 |
324 // Gets the zoom level for this tab. | 325 // Gets the zoom level for this tab. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // Focuses the location bar. | 372 // Focuses the location bar. |
372 virtual void SetFocusToLocationBar(bool select_all) = 0; | 373 virtual void SetFocusToLocationBar(bool select_all) = 0; |
373 | 374 |
374 // Does this have an opener associated with it? | 375 // Does this have an opener associated with it? |
375 virtual bool HasOpener() const = 0; | 376 virtual bool HasOpener() const = 0; |
376 }; | 377 }; |
377 | 378 |
378 } // namespace content | 379 } // namespace content |
379 | 380 |
380 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ | 381 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |
OLD | NEW |