blob: 872d1d1bf9b02d1e6d47189f7079c84ec7049295 [file] [log] [blame]
[email protected]0dd3a0ab2011-02-18 08:17:441// Copyright (c) 2011 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.
4
5#ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
6#define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_
7#pragma once
8
9#include <deque>
10#include <map>
11#include <string>
[email protected]0dd3a0ab2011-02-18 08:17:4412
13#include "base/basictypes.h"
14#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1515#include "base/memory/scoped_ptr.h"
[email protected]6eac57a2011-07-12 21:15:0916#include "base/observer_list.h"
[email protected]45644f62011-11-23 00:58:2317#include "base/property_bag.h"
[email protected]0dd3a0ab2011-02-18 08:17:4418#include "base/string16.h"
[email protected]c7dd2f62011-07-18 15:57:5919#include "content/browser/download/save_package.h"
[email protected]3ab9cb82011-06-03 18:02:0720#include "content/browser/javascript_dialogs.h"
[email protected]07161902011-11-11 09:57:4221#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
[email protected]5de634712011-03-02 00:20:1922#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]0dd3a0ab2011-02-18 08:17:4423#include "content/browser/tab_contents/navigation_controller.h"
24#include "content/browser/tab_contents/navigation_entry.h"
25#include "content/browser/tab_contents/page_navigator.h"
26#include "content/browser/tab_contents/render_view_host_manager.h"
[email protected]553602e12011-04-05 17:01:1827#include "content/browser/tab_contents/tab_contents_observer.h"
[email protected]1fd1a502011-03-30 16:55:5628#include "content/browser/webui/web_ui.h"
[email protected]8d128d62011-09-13 22:11:5729#include "content/common/content_export.h"
[email protected]6934a702011-12-20 00:04:5130#include "content/public/browser/web_page.h"
[email protected]daf82f82011-10-31 22:35:3131#include "content/public/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4432#include "net/base/load_states.h"
33#include "ui/gfx/native_widget_types.h"
[email protected]70435962011-08-02 20:13:2834#include "webkit/glue/resource_type.h"
[email protected]0dd3a0ab2011-02-18 08:17:4435
36#if defined(OS_WIN)
37#include "base/win/scoped_handle.h"
38#endif
39
[email protected]0dd3a0ab2011-02-18 08:17:4440class LoadNotificationDetails;
[email protected]0dd3a0ab2011-02-18 08:17:4441class RenderViewHost;
42class SessionStorageNamespace;
43class SiteInstance;
[email protected]0dd3a0ab2011-02-18 08:17:4444class TabContentsDelegate;
45class TabContentsObserver;
[email protected]0dd3a0ab2011-02-18 08:17:4446class TabContentsView;
[email protected]d7b175e2011-10-11 15:31:5847struct ViewHostMsg_DidFailProvisionalLoadWithError_Params;
[email protected]daf82f82011-10-31 22:35:3148
[email protected]e582fdd2011-12-20 16:48:1749namespace content {
50class DownloadItem;
51}
52
[email protected]daf82f82011-10-31 22:35:3153namespace webkit_glue {
54struct WebIntentData;
55}
[email protected]0dd3a0ab2011-02-18 08:17:4456
[email protected]6934a702011-12-20 00:04:5157class CONTENT_EXPORT TabContents : public content::WebPage,
58 public PageNavigator,
[email protected]8d128d62011-09-13 22:11:5759 public RenderViewHostDelegate,
60 public RenderViewHostManager::Delegate,
61 public content::JavaScriptDialogDelegate {
[email protected]0dd3a0ab2011-02-18 08:17:4462 public:
63 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
64 // what has changed. Combine them to update more than one thing.
65 enum InvalidateTypes {
66 INVALIDATE_URL = 1 << 0, // The URL has changed.
67 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed
68 // state changed.
69 INVALIDATE_LOAD = 1 << 2, // The loading state has changed.
70 INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed.
[email protected]93f230e02011-06-01 14:40:0071 INVALIDATE_TITLE = 1 << 4, // The title changed.
[email protected]0dd3a0ab2011-02-18 08:17:4472 };
73
74 // |base_tab_contents| is used if we want to size the new tab contents view
75 // based on an existing tab contents view. This can be NULL if not needed.
76 //
77 // The session storage namespace parameter allows multiple render views and
78 // tab contentses to share the same session storage (part of the WebStorage
79 // spec) space. This is useful when restoring tabs, but most callers should
80 // pass in NULL which will cause a new SessionStorageNamespace to be created.
[email protected]3d7474ff2011-07-27 17:47:3781 TabContents(content::BrowserContext* browser_context,
[email protected]0dd3a0ab2011-02-18 08:17:4482 SiteInstance* site_instance,
83 int routing_id,
84 const TabContents* base_tab_contents,
85 SessionStorageNamespace* session_storage_namespace);
86 virtual ~TabContents();
87
88 // Intrinsic tab state -------------------------------------------------------
89
[email protected]0dd3a0ab2011-02-18 08:17:4490 // Gets the controller for this tab contents.
91 NavigationController& controller() { return controller_; }
92 const NavigationController& controller() const { return controller_; }
93
[email protected]3d7474ff2011-07-27 17:47:3794 // Returns the user browser context associated with this TabContents (via the
[email protected]0dd3a0ab2011-02-18 08:17:4495 // NavigationController).
[email protected]3d7474ff2011-07-27 17:47:3796 content::BrowserContext* browser_context() const {
97 return controller_.browser_context();
98 }
99
[email protected]32ded2212011-11-10 18:51:43100 // Allows overriding the type of this tab.
101 void set_view_type(content::ViewType type) { view_type_ = type; }
102
[email protected]c7dd2f62011-07-18 15:57:59103 // Returns the SavePackage which manages the page saving job. May be NULL.
104 SavePackage* save_package() const { return save_package_.get(); }
105
[email protected]0dd3a0ab2011-02-18 08:17:44106 // Return the currently active RenderProcessHost and RenderViewHost. Each of
107 // these may change over time.
[email protected]f3b1a082011-11-18 00:34:30108 content::RenderProcessHost* GetRenderProcessHost() const;
[email protected]0dd3a0ab2011-02-18 08:17:44109 RenderViewHost* render_view_host() const {
110 return render_manager_.current_host();
111 }
112
[email protected]93f230e02011-06-01 14:40:00113 WebUI* committed_web_ui() const {
114 return render_manager_.web_ui();
115 }
116
[email protected]6e5a00a2011-10-13 17:47:16117 // Returns the committed WebUI if one exists, otherwise the pending one.
118 // Callers who want to use the pending WebUI for the pending navigation entry
119 // should use GetWebUIForCurrentState instead.
[email protected]0dd3a0ab2011-02-18 08:17:44120 WebUI* web_ui() const {
121 return render_manager_.web_ui() ? render_manager_.web_ui()
122 : render_manager_.pending_web_ui();
123 }
124
125 // Returns the currently active RenderWidgetHostView. This may change over
126 // time and can be NULL (during setup and teardown).
127 RenderWidgetHostView* GetRenderWidgetHostView() const {
128 return render_manager_.GetRenderWidgetHostView();
129 }
130
131 // The TabContentsView will never change and is guaranteed non-NULL.
132 TabContentsView* view() const {
133 return view_.get();
134 }
135
[email protected]0dd3a0ab2011-02-18 08:17:44136 // Tab navigation state ------------------------------------------------------
137
138 // Returns the current navigation properties, which if a navigation is
139 // pending may be provisional (e.g., the navigation could result in a
140 // download, in which case the URL would revert to what it was previously).
[email protected]edc64de2011-11-17 20:07:38141 virtual const GURL& GetURL() const OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44142 virtual const string16& GetTitle() const;
143
[email protected]74ce1ad2011-12-16 21:51:46144 // The max page ID for any page that the current SiteInstance has loaded in
145 // this TabContents. Page IDs are specific to a given SiteInstance and
146 // TabContents, corresponding to a specific RenderView in the renderer.
147 // Page IDs increase with each new page that is loaded by a tab.
[email protected]0dd3a0ab2011-02-18 08:17:44148 int32 GetMaxPageID();
149
[email protected]74ce1ad2011-12-16 21:51:46150 // The max page ID for any page that the given SiteInstance has loaded in
151 // this TabContents.
152 int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance);
153
154 // Updates the max page ID for the current SiteInstance in this TabContents
155 // to be at least |page_id|.
[email protected]0dd3a0ab2011-02-18 08:17:44156 void UpdateMaxPageID(int32 page_id);
157
[email protected]74ce1ad2011-12-16 21:51:46158 // Updates the max page ID for the given SiteInstance in this TabContents
159 // to be at least |page_id|.
160 void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
161 int32 page_id);
162
163 // Returns the SiteInstance associated with the current page.
164 SiteInstance* GetSiteInstance() const;
[email protected]0dd3a0ab2011-02-18 08:17:44165
[email protected]77362eb2011-08-01 17:18:38166 // Returns the SiteInstance for the pending navigation, if any. Otherwise
167 // returns the current SiteInstance.
168 SiteInstance* GetPendingSiteInstance() const;
169
[email protected]755d174b2011-11-07 23:33:30170 // Return whether this tab contents is loading a resource.
171 bool IsLoading() const { return is_loading_; }
[email protected]0dd3a0ab2011-02-18 08:17:44172
173 // Returns whether this tab contents is waiting for a first-response for the
174 // main resource of the page. This controls whether the throbber state is
175 // "waiting" or "loading."
176 bool waiting_for_response() const { return waiting_for_response_; }
177
[email protected]9c235f042011-08-10 22:28:21178 const net::LoadStateWithParam& load_state() const { return load_state_; }
179 const string16& load_state_host() const { return load_state_host_; }
[email protected]0dd3a0ab2011-02-18 08:17:44180 uint64 upload_size() const { return upload_size_; }
181 uint64 upload_position() const { return upload_position_; }
182
183 const std::string& encoding() const { return encoding_; }
184 void set_encoding(const std::string& encoding);
185 void reset_encoding() {
186 encoding_.clear();
187 }
188
[email protected]0dd3a0ab2011-02-18 08:17:44189 bool displayed_insecure_content() const {
190 return displayed_insecure_content_;
191 }
192
193 // Internal state ------------------------------------------------------------
194
195 // This flag indicates whether the tab contents is currently being
196 // screenshotted by the DraggedTabController.
197 bool capturing_contents() const { return capturing_contents_; }
198 void set_capturing_contents(bool cap) { capturing_contents_ = cap; }
199
200 // Indicates whether this tab should be considered crashed. The setter will
201 // also notify the delegate when the flag is changed.
202 bool is_crashed() const {
203 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
204 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
205 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
206 }
207 base::TerminationStatus crashed_status() const { return crashed_status_; }
208 int crashed_error_code() const { return crashed_error_code_; }
209 void SetIsCrashed(base::TerminationStatus status, int error_code);
210
[email protected]0dd3a0ab2011-02-18 08:17:44211 // Whether the tab is in the process of being destroyed.
212 // Added as a tentative work-around for focus related bug #4633. This allows
213 // us not to store focus when a tab is being closed.
214 bool is_being_destroyed() const { return is_being_destroyed_; }
215
216 // Convenience method for notifying the delegate of a navigation state
217 // change. See TabContentsDelegate.
218 void NotifyNavigationStateChanged(unsigned changed_flags);
219
220 // Invoked when the tab contents becomes selected. If you override, be sure
221 // and invoke super's implementation.
222 virtual void DidBecomeSelected();
223 base::TimeTicks last_selected_time() const {
224 return last_selected_time_;
225 }
226
227 // Invoked when the tab contents becomes hidden.
228 // NOTE: If you override this, call the superclass version too!
229 virtual void WasHidden();
230
[email protected]0dd3a0ab2011-02-18 08:17:44231 // TODO(brettw) document these.
232 virtual void ShowContents();
233 virtual void HideContents();
234
235 // Returns true if the before unload and unload listeners need to be
236 // fired. The value of this changes over time. For example, if true and the
237 // before unload listener is executed and allows the user to exit, then this
238 // returns false.
239 bool NeedToFireBeforeUnload();
240
[email protected]0dd3a0ab2011-02-18 08:17:44241 // Expose the render manager for testing.
[email protected]03ff5e52011-09-30 00:28:14242 RenderViewHostManager* render_manager_for_testing() {
243 return &render_manager_;
244 }
[email protected]0dd3a0ab2011-02-18 08:17:44245
[email protected]0dd3a0ab2011-02-18 08:17:44246 // Commands ------------------------------------------------------------------
247
248 // Implementation of PageNavigator.
[email protected]00c37fc2011-08-02 00:22:50249
250 // Deprecated. Please use the one-argument variant instead.
251 // TODO(adriansc): Remove this method once refactoring changed all call sites.
[email protected]992e4542011-07-20 23:09:25252 virtual TabContents* OpenURL(const GURL& url,
253 const GURL& referrer,
254 WindowOpenDisposition disposition,
[email protected]2905f742011-10-13 03:51:58255 content::PageTransition transition) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44256
[email protected]00c37fc2011-08-02 00:22:50257 virtual TabContents* OpenURL(const OpenURLParams& params) OVERRIDE;
258
[email protected]0dd3a0ab2011-02-18 08:17:44259 // Called by the NavigationController to cause the TabContents to navigate to
260 // the current pending entry. The NavigationController should be called back
[email protected]9a7e68c2011-05-26 17:35:50261 // with RendererDidNavigate on success or DiscardPendingEntry on failure.
262 // The callbacks can be inside of this function, or at some future time.
[email protected]0dd3a0ab2011-02-18 08:17:44263 //
264 // The entry has a PageID of -1 if newly created (corresponding to navigation
265 // to a new URL).
266 //
267 // If this method returns false, then the navigation is discarded (equivalent
268 // to calling DiscardPendingEntry on the NavigationController).
269 virtual bool NavigateToPendingEntry(
270 NavigationController::ReloadType reload_type);
271
272 // Stop any pending navigation.
273 virtual void Stop();
274
[email protected]0dd3a0ab2011-02-18 08:17:44275 // Creates a new TabContents with the same state as this one. The returned
276 // heap-allocated pointer is owned by the caller.
277 virtual TabContents* Clone();
278
279 // Shows the page info.
280 void ShowPageInfo(const GURL& url,
281 const NavigationEntry::SSLStatus& ssl,
282 bool show_history);
283
[email protected]0dd3a0ab2011-02-18 08:17:44284 // Window management ---------------------------------------------------------
285
[email protected]473174942011-04-19 22:52:35286 // Adds a new tab or window with the given already-created contents.
[email protected]e7cfdbd2011-04-22 14:41:37287 void AddNewContents(TabContents* new_contents,
288 WindowOpenDisposition disposition,
289 const gfx::Rect& initial_pos,
290 bool user_gesture);
[email protected]0dd3a0ab2011-02-18 08:17:44291
[email protected]0dd3a0ab2011-02-18 08:17:44292 // Views and focus -----------------------------------------------------------
293 // TODO(brettw): Most of these should be removed and the caller should call
294 // the view directly.
295
296 // Returns the actual window that is focused when this TabContents is shown.
297 gfx::NativeView GetContentNativeView() const;
298
299 // Returns the NativeView associated with this TabContents. Outside of
300 // automation in the context of the UI, this is required to be implemented.
301 gfx::NativeView GetNativeView() const;
302
303 // Returns the bounds of this TabContents in the screen coordinate system.
304 void GetContainerBounds(gfx::Rect *out) const;
305
306 // Makes the tab the focused window.
307 void Focus();
308
309 // Focuses the first (last if |reverse| is true) element in the page.
310 // Invoked when this tab is getting the focus through tab traversal (|reverse|
311 // is true when using Shift-Tab).
312 void FocusThroughTabTraversal(bool reverse);
313
314 // These next two functions are declared on RenderViewHostManager::Delegate
315 // but also accessed directly by other callers.
316
317 // Returns true if the location bar should be focused by default rather than
318 // the page contents. The view calls this function when the tab is focused
319 // to see what it should do.
[email protected]edc64de2011-11-17 20:07:38320 virtual bool FocusLocationBarByDefault() OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44321
322 // Focuses the location bar.
[email protected]edc64de2011-11-17 20:07:38323 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44324
325 // Creates a view and sets the size for the specified RVH.
[email protected]edc64de2011-11-17 20:07:38326 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44327
[email protected]0dd3a0ab2011-02-18 08:17:44328 // Toolbars and such ---------------------------------------------------------
329
[email protected]686493142011-07-15 21:47:22330 // Notifies the delegate that a download is about to be started.
331 // This notification is fired before a local temporary file has been created.
332 bool CanDownload(int request_id);
333
334 // Notifies the delegate that a download started.
[email protected]e582fdd2011-12-20 16:48:17335 void OnStartDownload(content::DownloadItem* download);
[email protected]686493142011-07-15 21:47:22336
[email protected]0dd3a0ab2011-02-18 08:17:44337 // Interstitials -------------------------------------------------------------
338
339 // Various other systems need to know about our interstitials.
340 bool showing_interstitial_page() const {
341 return render_manager_.interstitial_page() != NULL;
342 }
343
344 // Sets the passed passed interstitial as the currently showing interstitial.
345 // |interstitial_page| should be non NULL (use the remove_interstitial_page
346 // method to unset the interstitial) and no interstitial page should be set
347 // when there is already a non NULL interstitial page set.
348 void set_interstitial_page(InterstitialPage* interstitial_page) {
349 render_manager_.set_interstitial_page(interstitial_page);
350 }
351
352 // Unsets the currently showing interstitial.
353 void remove_interstitial_page() {
354 render_manager_.remove_interstitial_page();
355 }
356
357 // Returns the currently showing interstitial, NULL if no interstitial is
358 // showing.
359 InterstitialPage* interstitial_page() const {
360 return render_manager_.interstitial_page();
361 }
362
363 // Misc state & callbacks ----------------------------------------------------
364
[email protected]c7dd2f62011-07-18 15:57:59365 // Prepare for saving the current web page to disk.
366 void OnSavePage();
367
368 // Save page with the main HTML file path, the directory for saving resources,
369 // and the save type: HTML only or complete web page. Returns true if the
370 // saving process has been initiated successfully.
371 bool SavePage(const FilePath& main_file, const FilePath& dir_path,
372 SavePackage::SavePackageType save_type);
373
374 // Prepare for saving the URL to disk.
375 // URL may refer to the iframe on the page.
376 void OnSaveURL(const GURL& url);
377
[email protected]0dd3a0ab2011-02-18 08:17:44378 // Returns true if the active NavigationEntry's page_id equals page_id.
379 bool IsActiveEntry(int32 page_id);
380
381 const std::string& contents_mime_type() const {
382 return contents_mime_type_;
383 }
384
385 // Returns true if this TabContents will notify about disconnection.
386 bool notify_disconnection() const { return notify_disconnection_; }
387
388 // Override the encoding and reload the page by sending down
389 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
390 // the opposite of this, by which 'browser' is notified of
391 // the encoding of the current tab from 'renderer' (determined by
392 // auto-detect, http header, meta, bom detection, etc).
393 void SetOverrideEncoding(const std::string& encoding);
394
395 // Remove any user-defined override encoding and reload by sending down
396 // ViewMsg_ResetPageEncodingToDefault to the renderer.
397 void ResetOverrideEncoding();
398
[email protected]daf82f82011-10-31 22:35:31399 content::RendererPreferences* GetMutableRendererPrefs() {
[email protected]0dd3a0ab2011-02-18 08:17:44400 return &renderer_preferences_;
401 }
402
[email protected]1fd1a502011-03-30 16:55:56403 void set_opener_web_ui_type(WebUI::TypeID opener_web_ui_type) {
[email protected]0dd3a0ab2011-02-18 08:17:44404 opener_web_ui_type_ = opener_web_ui_type;
405 }
406
[email protected]0dd3a0ab2011-02-18 08:17:44407 // Set the time when we started to create the new tab page. This time is
408 // from before we created this TabContents.
409 void set_new_tab_start_time(const base::TimeTicks& time) {
410 new_tab_start_time_ = time;
411 }
[email protected]763ec4ca2011-04-29 15:48:12412 base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; }
[email protected]0dd3a0ab2011-02-18 08:17:44413
414 // Notification that tab closing has started. This can be called multiple
415 // times, subsequent calls are ignored.
416 void OnCloseStarted();
417
[email protected]0dd3a0ab2011-02-18 08:17:44418 // Returns true if underlying TabContentsView should accept drag-n-drop.
419 bool ShouldAcceptDragAndDrop() const;
420
421 // A render view-originated drag has ended. Informs the render view host and
422 // tab contents delegate.
423 void SystemDragEnded();
424
425 // Indicates if this tab was explicitly closed by the user (control-w, close
426 // tab menu item...). This is false for actions that indirectly close the tab,
427 // such as closing the window. The setter is maintained by TabStripModel, and
428 // the getter only useful from within TAB_CLOSED notification
429 void set_closed_by_user_gesture(bool value) {
430 closed_by_user_gesture_ = value;
431 }
432 bool closed_by_user_gesture() const { return closed_by_user_gesture_; }
433
[email protected]3ab9cb82011-06-03 18:02:07434 // Overridden from JavaScriptDialogDelegate:
435 virtual void OnDialogClosed(IPC::Message* reply_msg,
436 bool success,
437 const string16& user_input) OVERRIDE;
[email protected]0b08add2011-11-29 03:27:06438 virtual gfx::NativeWindow GetDialogRootWindow() const OVERRIDE;
[email protected]a1e97f02011-06-30 14:04:34439 virtual void OnDialogShown() OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44440
[email protected]0dd3a0ab2011-02-18 08:17:44441 // Gets the zoom level for this tab.
442 double GetZoomLevel() const;
443
444 // Gets the zoom percent for this tab.
445 int GetZoomPercent(bool* enable_increment, bool* enable_decrement);
446
[email protected]0dd3a0ab2011-02-18 08:17:44447 // Opens view-source tab for this contents.
448 void ViewSource();
449
[email protected]932b7a12011-03-09 12:50:27450 void ViewFrameSource(const GURL& url,
451 const std::string& content_state);
452
[email protected]0dd3a0ab2011-02-18 08:17:44453 // Gets the minimum/maximum zoom percent.
454 int minimum_zoom_percent() const { return minimum_zoom_percent_; }
455 int maximum_zoom_percent() const { return maximum_zoom_percent_; }
456
457 int content_restrictions() const { return content_restrictions_; }
[email protected]c40d6232011-03-25 00:16:21458 void SetContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44459
[email protected]1fd1a502011-03-30 16:55:56460 // Query the WebUIFactory for the TypeID for the current URL.
461 WebUI::TypeID GetWebUITypeForCurrentState();
462
[email protected]b375c5d2011-05-03 21:15:04463 // Returns the WebUI for the current state of the tab. This will either be
464 // the pending WebUI, the committed WebUI, or NULL.
465 WebUI* GetWebUIForCurrentState();
466
[email protected]e9621112011-10-17 05:38:37467 // Called when the reponse to a pending mouse lock request has arrived.
468 // Returns true if |allowed| is true and the mouse has been successfully
469 // locked.
470 bool GotResponseToLockMouseRequest(bool allowed);
471
[email protected]276b37a22011-11-08 20:45:46472 JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
473 return java_bridge_dispatcher_host_manager_.get();
474 }
475
[email protected]6934a702011-12-20 00:04:51476 // content::WebPage ----------------------------------------------------------
477 virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
478 virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
479 virtual TabContentsDelegate* GetDelegate() OVERRIDE;
480 virtual void SetDelegate(TabContentsDelegate* delegate) OVERRIDE;
481
482
[email protected]952a68e2011-11-17 00:36:10483 // RenderViewHostDelegate ----------------------------------------------------
484
485 virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE;
486 virtual RenderViewHostDelegate::RendererManagement*
487 GetRendererManagementDelegate() OVERRIDE;
488 virtual TabContents* GetAsTabContents() OVERRIDE;
489 virtual content::ViewType GetRenderViewType() const OVERRIDE;
490 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
491 virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
492 virtual void RenderViewGone(RenderViewHost* render_view_host,
493 base::TerminationStatus status,
494 int error_code) OVERRIDE;
495 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
496 virtual void DidNavigate(
497 RenderViewHost* render_view_host,
498 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
499 virtual void UpdateState(RenderViewHost* render_view_host,
500 int32 page_id,
501 const std::string& state) OVERRIDE;
502 virtual void UpdateTitle(RenderViewHost* render_view_host,
503 int32 page_id,
504 const string16& title,
505 base::i18n::TextDirection title_direction) OVERRIDE;
506 virtual void UpdateEncoding(RenderViewHost* render_view_host,
507 const std::string& encoding) OVERRIDE;
508 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
509 virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
510 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
511 virtual void SwappedOut(RenderViewHost* render_view_host) OVERRIDE;
512 virtual void DidStartLoading() OVERRIDE;
513 virtual void DidStopLoading() OVERRIDE;
514 virtual void DidCancelLoading() OVERRIDE;
515 virtual void DidChangeLoadProgress(double progress) OVERRIDE;
516 virtual void DocumentAvailableInMainFrame(
517 RenderViewHost* render_view_host) OVERRIDE;
518 virtual void DocumentOnLoadCompletedInMainFrame(
519 RenderViewHost* render_view_host,
520 int32 page_id) OVERRIDE;
521 virtual void RequestOpenURL(const GURL& url,
[email protected]445e1042011-12-03 21:03:15522 const content::Referrer& referrer,
[email protected]952a68e2011-11-17 00:36:10523 WindowOpenDisposition disposition,
524 int64 source_frame_id) OVERRIDE;
[email protected]4ad5d77d2011-12-03 02:00:48525 virtual void RequestTransferURL(
526 const GURL& url,
[email protected]bce1f1c2011-12-05 15:11:58527 const content::Referrer& referrer,
[email protected]4ad5d77d2011-12-03 02:00:48528 WindowOpenDisposition disposition,
529 int64 source_frame_id,
530 const GlobalRequestID& transferred_global_request_id) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10531 virtual void RunJavaScriptMessage(const RenderViewHost* rvh,
532 const string16& message,
533 const string16& default_prompt,
534 const GURL& frame_url,
[email protected]269f86d2011-12-07 02:43:47535 ui::JavascriptMessageType type,
[email protected]952a68e2011-11-17 00:36:10536 IPC::Message* reply_msg,
537 bool* did_suppress_message) OVERRIDE;
538 virtual void RunBeforeUnloadConfirm(const RenderViewHost* rvh,
539 const string16& message,
540 IPC::Message* reply_msg) OVERRIDE;
541 virtual content::RendererPreferences GetRendererPrefs(
542 content::BrowserContext* browser_context) const OVERRIDE;
543 virtual WebPreferences GetWebkitPrefs() OVERRIDE;
544 virtual void OnUserGesture() OVERRIDE;
545 virtual void OnIgnoredUIEvent() OVERRIDE;
546 virtual void RendererUnresponsive(RenderViewHost* render_view_host,
547 bool is_during_unload) OVERRIDE;
548 virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE;
549 virtual void LoadStateChanged(const GURL& url,
550 const net::LoadStateWithParam& load_state,
551 uint64 upload_position,
552 uint64 upload_size) OVERRIDE;
553 virtual void WorkerCrashed() OVERRIDE;
554 virtual void Activate() OVERRIDE;
555 virtual void Deactivate() OVERRIDE;
556 virtual void LostCapture() OVERRIDE;
557 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
558 bool* is_keyboard_shortcut) OVERRIDE;
559 virtual void HandleKeyboardEvent(
560 const NativeWebKeyboardEvent& event) OVERRIDE;
561 virtual void HandleMouseDown() OVERRIDE;
562 virtual void HandleMouseUp() OVERRIDE;
563 virtual void HandleMouseActivate() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38564 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
565 virtual void RunFileChooser(
566 RenderViewHost* render_view_host,
[email protected]8caadeb2011-11-22 02:45:23567 const content::FileChooserParams& params) OVERRIDE;
[email protected]952a68e2011-11-17 00:36:10568 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
569 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
570 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
571 virtual void WebUISend(RenderViewHost* render_view_host,
572 const GURL& source_url,
573 const std::string& name,
574 const base::ListValue& args) OVERRIDE;
575 virtual void RequestToLockMouse() OVERRIDE;
576 virtual void LostMouseLock() OVERRIDE;
577
[email protected]0dd3a0ab2011-02-18 08:17:44578 protected:
[email protected]553602e12011-04-05 17:01:18579 friend class TabContentsObserver;
[email protected]553602e12011-04-05 17:01:18580
581 // Add and remove observers for page navigation notifications. Adding or
582 // removing multiple times has no effect. The order in which notifications
583 // are sent to observers is undefined. Clients must be sure to remove the
584 // observer before they go away.
585 void AddObserver(TabContentsObserver* observer);
586 void RemoveObserver(TabContentsObserver* observer);
587
[email protected]0dd3a0ab2011-02-18 08:17:44588 private:
589 friend class NavigationController;
[email protected]0dd3a0ab2011-02-18 08:17:44590
591 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, NoJSMessageOnInterstitials);
592 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, UpdateTitle);
593 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, CrossSiteCantPreemptAfterUnload);
594 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
595 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
596 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
597
598 // Temporary until the view/contents separation is complete.
599 friend class TabContentsView;
[email protected]9a56a0d2011-05-13 19:03:31600#if defined(TOOLKIT_VIEWS)
[email protected]7e2cef52011-04-11 21:47:23601 friend class TabContentsViewViews;
[email protected]0dd3a0ab2011-02-18 08:17:44602#elif defined(OS_MACOSX)
603 friend class TabContentsViewMac;
604#elif defined(TOOLKIT_USES_GTK)
605 friend class TabContentsViewGtk;
606#endif
607
608 // So InterstitialPage can access SetIsLoading.
609 friend class InterstitialPage;
610
611 // TODO(brettw) TestTabContents shouldn't exist!
612 friend class TestTabContents;
613
[email protected]0dd3a0ab2011-02-18 08:17:44614 // Message handlers.
[email protected]8b5af492011-11-28 21:50:58615 void OnRegisterIntentService(const string16& action,
[email protected]63c239322011-10-31 23:56:30616 const string16& type,
617 const string16& href,
618 const string16& title,
619 const string16& disposition);
[email protected]678105012011-12-09 04:01:21620 void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
[email protected]63c239322011-10-31 23:56:30621 int intent_id);
[email protected]0dd3a0ab2011-02-18 08:17:44622 void OnDidStartProvisionalLoadForFrame(int64 frame_id,
623 bool main_frame,
[email protected]57b9396c2011-10-07 19:11:59624 const GURL& opener_url,
[email protected]0dd3a0ab2011-02-18 08:17:44625 const GURL& url);
626 void OnDidRedirectProvisionalLoad(int32 page_id,
[email protected]57b9396c2011-10-07 19:11:59627 const GURL& opener_url,
[email protected]0dd3a0ab2011-02-18 08:17:44628 const GURL& source_url,
629 const GURL& target_url);
[email protected]d7b175e2011-10-11 15:31:58630 void OnDidFailProvisionalLoadWithError(
631 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params);
[email protected]0dd3a0ab2011-02-18 08:17:44632 void OnDidLoadResourceFromMemoryCache(const GURL& url,
[email protected]70435962011-08-02 20:13:28633 const std::string& security_info,
634 const std::string& http_request,
635 ResourceType::Type resource_type);
[email protected]0dd3a0ab2011-02-18 08:17:44636 void OnDidDisplayInsecureContent();
637 void OnDidRunInsecureContent(const std::string& security_origin,
638 const GURL& target_url);
639 void OnDocumentLoadedInFrame(int64 frame_id);
[email protected]1a55c5be2011-11-29 11:36:31640 void OnDidFinishLoad(int64 frame_id,
641 const GURL& validated_url,
642 bool is_main_frame);
643 void OnDidFailLoadWithError(int64 frame_id,
644 const GURL& validated_url,
645 bool is_main_frame,
646 int error_code,
647 const string16& error_description);
[email protected]0dd3a0ab2011-02-18 08:17:44648 void OnUpdateContentRestrictions(int restrictions);
[email protected]0dd3a0ab2011-02-18 08:17:44649 void OnGoToEntryAtOffset(int offset);
[email protected]216813952011-05-19 22:21:26650 void OnUpdateZoomLimits(int minimum_percent,
651 int maximum_percent,
652 bool remember);
[email protected]3a29a6e2011-08-24 18:26:21653 void OnEnumerateDirectory(int request_id, const FilePath& path);
[email protected]7d189022011-08-25 22:54:20654 void OnJSOutOfMemory();
655 void OnRegisterProtocolHandler(const std::string& protocol,
656 const GURL& url,
657 const string16& title);
[email protected]b888919c2011-09-02 00:32:16658 void OnFindReply(int request_id, int number_of_matches,
659 const gfx::Rect& selection_rect, int active_match_ordinal,
660 bool final_update);
[email protected]d952a052011-09-06 18:42:45661 void OnCrashedPlugin(const FilePath& plugin_path);
[email protected]7fc4bbb2011-09-08 21:23:10662 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
[email protected]0dd3a0ab2011-02-18 08:17:44663
664 // Changes the IsLoading state and notifies delegate as needed
665 // |details| is used to provide details on the load that just finished
666 // (but can be null if not applicable). Can be overridden.
667 void SetIsLoading(bool is_loading,
668 LoadNotificationDetails* details);
669
[email protected]0dd3a0ab2011-02-18 08:17:44670 // Called by derived classes to indicate that we're no longer waiting for a
671 // response. This won't actually update the throbber, but it will get picked
672 // up at the next animation step if the throbber is going.
673 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
674
[email protected]0dd3a0ab2011-02-18 08:17:44675 // Navigation helpers --------------------------------------------------------
676 //
677 // These functions are helpers for Navigate() and DidNavigate().
678
679 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
680 // committed to the navigation controller. Note that the navigation entry is
681 // not provided since it may be invalid/changed after being committed. The
682 // current navigation entry is in the NavigationController at this point.
683 void DidNavigateMainFramePostCommit(
[email protected]8286f51a2011-05-31 17:39:13684 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44685 const ViewHostMsg_FrameNavigate_Params& params);
686 void DidNavigateAnyFramePostCommit(
687 RenderViewHost* render_view_host,
[email protected]8286f51a2011-05-31 17:39:13688 const content::LoadCommittedDetails& details,
[email protected]0dd3a0ab2011-02-18 08:17:44689 const ViewHostMsg_FrameNavigate_Params& params);
690
[email protected]74ce1ad2011-12-16 21:51:46691 // If our controller was restored, update the max page ID associated with the
692 // given RenderViewHost to be larger than the number of restored entries.
693 // This is called in CreateRenderView before any navigations in the RenderView
694 // have begun, to prevent any races in updating RenderView::next_page_id.
695 void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
[email protected]0dd3a0ab2011-02-18 08:17:44696
[email protected]0dd3a0ab2011-02-18 08:17:44697 // Saves the given title to the navigation entry and does associated work. It
698 // will update history and the view for the new title, and also synthesize
699 // titles for file URLs that have none (so we require that the URL of the
700 // entry already be set).
701 //
702 // This is used as the backend for state updates, which include a new title,
703 // or the dedicated set title message. It returns true if the new title is
704 // different and was therefore updated.
[email protected]acafd272011-07-26 17:35:57705 bool UpdateTitleForEntry(NavigationEntry* entry, const string16& title);
[email protected]0dd3a0ab2011-02-18 08:17:44706
707 // Causes the TabContents to navigate in the right renderer to |entry|, which
708 // must be already part of the entries in the navigation controller.
709 // This does not change the NavigationController state.
[email protected]dd11de52011-11-03 22:54:27710 bool NavigateToEntry(const NavigationEntry& entry,
[email protected]0dd3a0ab2011-02-18 08:17:44711 NavigationController::ReloadType reload_type);
712
[email protected]796931a92011-08-10 01:32:14713 // Sets the history for this tab_contents to |history_length| entries, and
714 // moves the current page_id to the last entry in the list if it's valid.
715 // This is mainly used when a prerendered page is swapped into the current
[email protected]9e1ad4b2011-08-14 16:49:19716 // tab. The method is virtual for testing.
717 virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance,
718 int merge_history_length,
719 int32 minimum_page_id);
[email protected]796931a92011-08-10 01:32:14720
[email protected]0dd3a0ab2011-02-18 08:17:44721 // Misc non-view stuff -------------------------------------------------------
722
723 // Helper functions for sending notifications.
724 void NotifySwapped();
725 void NotifyConnected();
726 void NotifyDisconnected();
727
[email protected]0dd3a0ab2011-02-18 08:17:44728 // RenderViewHostManager::Delegate -------------------------------------------
729
[email protected]0dd3a0ab2011-02-18 08:17:44730 virtual void BeforeUnloadFiredFromRenderManager(
731 bool proceed,
[email protected]edc64de2011-11-17 20:07:38732 bool* proceed_to_fire_unload) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44733 virtual void DidStartLoadingFromRenderManager(
[email protected]edc64de2011-11-17 20:07:38734 RenderViewHost* render_view_host) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44735 virtual void RenderViewGoneFromRenderManager(
[email protected]edc64de2011-11-17 20:07:38736 RenderViewHost* render_view_host) OVERRIDE;
737 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
738 virtual void NotifySwappedFromRenderManager() OVERRIDE;
739 virtual NavigationController& GetControllerForRenderManager() OVERRIDE;
740 virtual WebUI* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
741 virtual NavigationEntry*
742 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44743
744 // Initializes the given renderer if necessary and creates the view ID
745 // corresponding to this view host. If this method is not called and the
746 // process is not shared, then the TabContents will act as though the renderer
747 // is not running (i.e., it will render "sad tab"). This method is
748 // automatically called from LoadURL.
749 //
750 // If you are attaching to an already-existing RenderView, you should call
751 // InitWithExistingID.
752 virtual bool CreateRenderViewForRenderManager(
[email protected]edc64de2011-11-17 20:07:38753 RenderViewHost* render_view_host) OVERRIDE;
[email protected]0dd3a0ab2011-02-18 08:17:44754
[email protected]81898992011-06-14 22:15:00755 // Stores random bits of data for others to associate with this object.
756 // WARNING: this needs to be deleted after NavigationController.
[email protected]45644f62011-11-23 00:58:23757 base::PropertyBag property_bag_;
[email protected]81898992011-06-14 22:15:00758
[email protected]0dd3a0ab2011-02-18 08:17:44759 // Data for core operation ---------------------------------------------------
760
761 // Delegate for notifying our owner about stuff. Not owned by us.
762 TabContentsDelegate* delegate_;
763
764 // Handles the back/forward list and loading.
765 NavigationController controller_;
766
767 // The corresponding view.
768 scoped_ptr<TabContentsView> view_;
769
[email protected]996042972011-11-08 22:43:59770 // A list of observers notified when page state changes. Weak references.
771 // This MUST be listed above render_manager_ since at destruction time the
772 // latter might cause RenderViewHost's destructor to call us and we might use
773 // the observer list then.
774 ObserverList<TabContentsObserver> observers_;
775
[email protected]0dd3a0ab2011-02-18 08:17:44776 // Helper classes ------------------------------------------------------------
777
778 // Manages creation and swapping of render views.
779 RenderViewHostManager render_manager_;
780
[email protected]483623eb2011-10-25 09:30:00781 // Manages injecting Java objects into all RenderViewHosts associated with
782 // this TabContents.
783 scoped_ptr<JavaBridgeDispatcherHostManager>
784 java_bridge_dispatcher_host_manager_;
785
[email protected]c7dd2f62011-07-18 15:57:59786 // SavePackage, lazily created.
787 scoped_refptr<SavePackage> save_package_;
788
[email protected]0dd3a0ab2011-02-18 08:17:44789 // Data for loading state ----------------------------------------------------
790
791 // Indicates whether we're currently loading a resource.
792 bool is_loading_;
793
794 // Indicates if the tab is considered crashed.
795 base::TerminationStatus crashed_status_;
796 int crashed_error_code_;
797
798 // See waiting_for_response() above.
799 bool waiting_for_response_;
800
[email protected]74ce1ad2011-12-16 21:51:46801 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
802 // to a given tab and SiteInstance, and must be valid for the lifetime of the
803 // TabContents.
804 std::map<int32, int32> max_page_ids_;
[email protected]0dd3a0ab2011-02-18 08:17:44805
806 // System time at which the current load was started.
807 base::TimeTicks current_load_start_;
808
809 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:21810 net::LoadStateWithParam load_state_;
[email protected]0dd3a0ab2011-02-18 08:17:44811 string16 load_state_host_;
812 // Upload progress, for displaying in the status bar.
813 // Set to zero when there is no significant upload happening.
814 uint64 upload_size_;
815 uint64 upload_position_;
816
817 // Data for current page -----------------------------------------------------
818
[email protected]987fc3a2011-05-26 14:18:09819 // When a title cannot be taken from any entry, this title will be used.
820 string16 page_title_when_no_navigation_entry_;
821
[email protected]0dd3a0ab2011-02-18 08:17:44822 // When a navigation occurs, we record its contents MIME type. It can be
823 // used to check whether we can do something for some special contents.
824 std::string contents_mime_type_;
825
826 // Character encoding.
827 std::string encoding_;
828
[email protected]0dd3a0ab2011-02-18 08:17:44829 // True if this is a secure page which displayed insecure content.
830 bool displayed_insecure_content_;
831
[email protected]0dd3a0ab2011-02-18 08:17:44832 // Data for misc internal state ----------------------------------------------
833
834 // See capturing_contents() above.
835 bool capturing_contents_;
836
837 // See getter above.
838 bool is_being_destroyed_;
839
840 // Indicates whether we should notify about disconnection of this
841 // TabContents. This is used to ensure disconnection notifications only
842 // happen if a connection notification has happened and that they happen only
843 // once.
844 bool notify_disconnection_;
845
[email protected]2e5b90c2011-08-16 21:11:55846 // Pointer to the JavaScript dialog creator, lazily assigned. Used because the
847 // delegate of this TabContents is nulled before its destructor is called.
848 content::JavaScriptDialogCreator* dialog_creator_;
849
[email protected]0dd3a0ab2011-02-18 08:17:44850#if defined(OS_WIN)
851 // Handle to an event that's set when the page is showing a message box (or
852 // equivalent constrained window). Plugin processes check this to know if
853 // they should pump messages then.
854 base::win::ScopedHandle message_box_active_;
855#endif
856
[email protected]0dd3a0ab2011-02-18 08:17:44857 // Set to true when there is an active "before unload" dialog. When true,
858 // we've forced the throbber to start in Navigate, and we need to remember to
859 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
860 bool is_showing_before_unload_dialog_;
861
[email protected]0dd3a0ab2011-02-18 08:17:44862 // Settings that get passed to the renderer process.
[email protected]daf82f82011-10-31 22:35:31863 content::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:44864
865 // If this tab was created from a renderer using window.open, this will be
866 // non-NULL and represent the WebUI of the opening renderer.
[email protected]1fd1a502011-03-30 16:55:56867 WebUI::TypeID opener_web_ui_type_;
[email protected]0dd3a0ab2011-02-18 08:17:44868
869 // The time that we started to create the new tab page.
870 base::TimeTicks new_tab_start_time_;
871
872 // The time that we started to close the tab.
873 base::TimeTicks tab_close_start_time_;
874
875 // The time that this tab was last selected.
876 base::TimeTicks last_selected_time_;
877
[email protected]0dd3a0ab2011-02-18 08:17:44878 // See description above setter.
879 bool closed_by_user_gesture_;
880
881 // Minimum/maximum zoom percent.
882 int minimum_zoom_percent_;
883 int maximum_zoom_percent_;
884 // If true, the default zoom limits have been overriden for this tab, in which
885 // case we don't want saved settings to apply to it and we don't want to
886 // remember it.
887 bool temporary_zoom_settings_;
888
[email protected]0dd3a0ab2011-02-18 08:17:44889 // Content restrictions, used to disable print/copy etc based on content's
890 // (full-page plugins for now only) permissions.
891 int content_restrictions_;
892
[email protected]32ded2212011-11-10 18:51:43893 // Our view type. Default is VIEW_TYPE_TAB_CONTENTS.
894 content::ViewType view_type_;
895
[email protected]0dd3a0ab2011-02-18 08:17:44896 DISALLOW_COPY_AND_ASSIGN(TabContents);
897};
898
899#endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_