blob: c541425cec81ce18a7daf8c74a1a005d1781ca34 [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>
12#include <vector>
13
14#include "base/basictypes.h"
15#include "base/gtest_prod_util.h"
16#include "base/scoped_ptr.h"
17#include "base/string16.h"
18#include "chrome/browser/download/save_package.h"
19#include "chrome/browser/extensions/image_loading_tracker.h"
[email protected]34952d12011-03-14 19:45:1320#include "chrome/browser/favicon_helper.h"
[email protected]0dd3a0ab2011-02-18 08:17:4421#include "chrome/browser/prefs/pref_change_registrar.h"
[email protected]0dd3a0ab2011-02-18 08:17:4422#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
23#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
[email protected]1c9c7fb2011-03-11 16:38:3824#include "chrome/common/instant_types.h"
[email protected]0dd3a0ab2011-02-18 08:17:4425#include "chrome/common/translate_errors.h"
26#include "chrome/common/web_apps.h"
[email protected]5de634712011-03-02 00:20:1927#include "content/browser/renderer_host/render_view_host_delegate.h"
[email protected]0dd3a0ab2011-02-18 08:17:4428#include "content/browser/tab_contents/constrained_window.h"
29#include "content/browser/tab_contents/language_state.h"
30#include "content/browser/tab_contents/navigation_controller.h"
31#include "content/browser/tab_contents/navigation_entry.h"
32#include "content/browser/tab_contents/page_navigator.h"
33#include "content/browser/tab_contents/render_view_host_manager.h"
[email protected]67fc0392011-02-25 02:56:5734#include "content/browser/webui/web_ui_factory.h"
[email protected]7f070d42011-03-09 20:25:3235#include "content/common/notification_registrar.h"
[email protected]15a5fa52011-03-10 20:16:0436#include "content/common/property_bag.h"
[email protected]60916042011-03-19 00:43:3637#include "content/common/renderer_preferences.h"
[email protected]0dd3a0ab2011-02-18 08:17:4438#include "net/base/load_states.h"
[email protected]232a5812011-03-04 22:42:0839#include "net/base/network_change_notifier.h"
[email protected]0dd3a0ab2011-02-18 08:17:4440#include "ui/gfx/native_widget_types.h"
41
42#if defined(OS_WIN)
43#include "base/win/scoped_handle.h"
44#endif
45
46namespace gfx {
47class Rect;
48}
49
50namespace history {
51class HistoryAddPageArgs;
52}
53
54namespace prerender {
55class PrerenderManager;
[email protected]0dd3a0ab2011-02-18 08:17:4456}
57
58namespace printing {
59class PrintPreviewMessageHandler;
60class PrintViewManager;
61}
62
63namespace safe_browsing {
64class ClientSideDetectionHost;
65}
66
67class AutocompleteHistoryManager;
[email protected]c4a9e932011-03-05 04:05:5568class AutofillManager;
[email protected]0dd3a0ab2011-02-18 08:17:4469class BlockedContentContainer;
70class WebUI;
71class DesktopNotificationHandlerForTC;
72class DownloadItem;
73class Extension;
[email protected]0dd3a0ab2011-02-18 08:17:4474class InfoBarDelegate;
75class LoadNotificationDetails;
76class OmniboxSearchHint;
77class PluginObserver;
78class Profile;
79class RenderViewHost;
80class SessionStorageNamespace;
81class SiteInstance;
82class SkBitmap;
83class TabContents;
84class TabContentsDelegate;
85class TabContentsObserver;
86class TabContentsSSLHelper;
87class TabContentsView;
88class URLPattern;
89struct RendererPreferences;
90struct ThumbnailScore;
91struct ViewHostMsg_DomMessage_Params;
92struct ViewHostMsg_FrameNavigate_Params;
[email protected]0dd3a0ab2011-02-18 08:17:4493struct WebPreferences;
94
95// Describes what goes in the main content area of a tab. TabContents is
96// the only type of TabContents, and these should be merged together.
97class TabContents : public PageNavigator,
98 public NotificationObserver,
99 public RenderViewHostDelegate,
100 public RenderViewHostManager::Delegate,
101 public JavaScriptAppModalDialogDelegate,
102 public ImageLoadingTracker::Observer,
[email protected]232a5812011-03-04 22:42:08103 public TabSpecificContentSettings::Delegate,
104 public net::NetworkChangeNotifier::OnlineStateObserver {
[email protected]0dd3a0ab2011-02-18 08:17:44105 public:
106 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
107 // what has changed. Combine them to update more than one thing.
108 enum InvalidateTypes {
109 INVALIDATE_URL = 1 << 0, // The URL has changed.
110 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed
111 // state changed.
112 INVALIDATE_LOAD = 1 << 2, // The loading state has changed.
113 INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed.
114 INVALIDATE_BOOKMARK_BAR = 1 << 4, // State of ShouldShowBookmarkBar
115 // changed.
116 INVALIDATE_TITLE = 1 << 5, // The title changed.
117 };
118
119 // |base_tab_contents| is used if we want to size the new tab contents view
120 // based on an existing tab contents view. This can be NULL if not needed.
121 //
122 // The session storage namespace parameter allows multiple render views and
123 // tab contentses to share the same session storage (part of the WebStorage
124 // spec) space. This is useful when restoring tabs, but most callers should
125 // pass in NULL which will cause a new SessionStorageNamespace to be created.
126 TabContents(Profile* profile,
127 SiteInstance* site_instance,
128 int routing_id,
129 const TabContents* base_tab_contents,
130 SessionStorageNamespace* session_storage_namespace);
131 virtual ~TabContents();
132
133 // Intrinsic tab state -------------------------------------------------------
134
135 // Returns the property bag for this tab contents, where callers can add
136 // extra data they may wish to associate with the tab. Returns a pointer
137 // rather than a reference since the PropertyAccessors expect this.
138 const PropertyBag* property_bag() const { return &property_bag_; }
139 PropertyBag* property_bag() { return &property_bag_; }
140
141 TabContentsDelegate* delegate() const { return delegate_; }
142 void set_delegate(TabContentsDelegate* d) { delegate_ = d; }
143
144 // Gets the controller for this tab contents.
145 NavigationController& controller() { return controller_; }
146 const NavigationController& controller() const { return controller_; }
147
148 // Returns the user profile associated with this TabContents (via the
149 // NavigationController).
150 Profile* profile() const { return controller_.profile(); }
151
152 // Returns true if contains content rendered by an extension.
153 bool HostsExtension() const;
154
155 // Returns the TabContentsSSLHelper, creating it if necessary.
156 TabContentsSSLHelper* GetSSLHelper();
157
158 // Returns the SavePackage which manages the page saving job. May be NULL.
159 SavePackage* save_package() const { return save_package_.get(); }
160
161 // Return the currently active RenderProcessHost and RenderViewHost. Each of
162 // these may change over time.
163 RenderProcessHost* GetRenderProcessHost() const;
164 RenderViewHost* render_view_host() const {
165 return render_manager_.current_host();
166 }
167
168 WebUI* web_ui() const {
169 return render_manager_.web_ui() ? render_manager_.web_ui()
170 : render_manager_.pending_web_ui();
171 }
172
173 // Returns the currently active RenderWidgetHostView. This may change over
174 // time and can be NULL (during setup and teardown).
175 RenderWidgetHostView* GetRenderWidgetHostView() const {
176 return render_manager_.GetRenderWidgetHostView();
177 }
178
179 // The TabContentsView will never change and is guaranteed non-NULL.
180 TabContentsView* view() const {
181 return view_.get();
182 }
183
[email protected]34952d12011-03-14 19:45:13184 // Returns the FaviconHelper of this TabContents.
[email protected]16be5c32011-03-15 17:52:03185 FaviconHelper& favicon_helper() {
186 return *favicon_helper_.get();
[email protected]0dd3a0ab2011-02-18 08:17:44187 }
188
189 // App extensions ------------------------------------------------------------
190
191 // Sets the extension denoting this as an app. If |extension| is non-null this
192 // tab becomes an app-tab. TabContents does not listen for unload events for
193 // the extension. It's up to consumers of TabContents to do that.
194 //
195 // NOTE: this should only be manipulated before the tab is added to a browser.
196 // TODO(sky): resolve if this is the right way to identify an app tab. If it
197 // is, than this should be passed in the constructor.
198 void SetExtensionApp(const Extension* extension);
199
200 // Convenience for setting the app extension by id. This does nothing if
201 // |extension_app_id| is empty, or an extension can't be found given the
202 // specified id.
203 void SetExtensionAppById(const std::string& extension_app_id);
204
205 const Extension* extension_app() const { return extension_app_; }
206 bool is_app() const { return extension_app_ != NULL; }
207
208 // If an app extension has been explicitly set for this TabContents its icon
209 // is returned.
210 //
211 // NOTE: the returned icon is larger than 16x16 (its size is
212 // Extension::EXTENSION_ICON_SMALLISH).
213 SkBitmap* GetExtensionAppIcon();
214
215 // Tab navigation state ------------------------------------------------------
216
217 // Returns the current navigation properties, which if a navigation is
218 // pending may be provisional (e.g., the navigation could result in a
219 // download, in which case the URL would revert to what it was previously).
220 virtual const GURL& GetURL() const;
221 virtual const string16& GetTitle() const;
222
223 // The max PageID of any page that this TabContents has loaded. PageIDs
224 // increase with each new page that is loaded by a tab. If this is a
225 // TabContents, then the max PageID is kept separately on each SiteInstance.
226 // Returns -1 if no PageIDs have yet been seen.
227 int32 GetMaxPageID();
228
229 // Updates the max PageID to be at least the given PageID.
230 void UpdateMaxPageID(int32 page_id);
231
232 // Returns the site instance associated with the current page. By default,
233 // there is no site instance. TabContents overrides this to provide proper
234 // access to its site instance.
235 virtual SiteInstance* GetSiteInstance() const;
236
237 // Defines whether this tab's URL should be displayed in the browser's URL
238 // bar. Normally this is true so you can see the URL. This is set to false
239 // for the new tab page and related pages so that the URL bar is empty and
240 // the user is invited to type into it.
241 virtual bool ShouldDisplayURL();
242
243 // Returns the favicon for this tab, or an isNull() bitmap if the tab does not
244 // have a favicon. The default implementation uses the current navigation
245 // entry.
[email protected]9b488bda2011-03-15 14:42:27246 SkBitmap GetFavicon() const;
[email protected]0dd3a0ab2011-02-18 08:17:44247
248 // Returns true if we are not using the default favicon.
[email protected]d8e74e82011-03-15 19:38:48249 bool FaviconIsValid() const;
[email protected]0dd3a0ab2011-02-18 08:17:44250
251 // Returns whether the favicon should be displayed. If this returns false, no
252 // space is provided for the favicon, and the favicon is never displayed.
[email protected]d8e74e82011-03-15 19:38:48253 virtual bool ShouldDisplayFavicon();
[email protected]0dd3a0ab2011-02-18 08:17:44254
255 // Add and remove observers for page navigation notifications. Adding or
256 // removing multiple times has no effect. The order in which notifications
257 // are sent to observers is undefined. Clients must be sure to remove the
258 // observer before they go away.
259 void AddObserver(TabContentsObserver* observer);
260 void RemoveObserver(TabContentsObserver* observer);
261
262 // Return whether this tab contents is loading a resource.
263 bool is_loading() const { return is_loading_; }
264
265 // Returns whether this tab contents is waiting for a first-response for the
266 // main resource of the page. This controls whether the throbber state is
267 // "waiting" or "loading."
268 bool waiting_for_response() const { return waiting_for_response_; }
269
270 net::LoadState load_state() const { return load_state_; }
271 string16 load_state_host() const { return load_state_host_; }
272 uint64 upload_size() const { return upload_size_; }
273 uint64 upload_position() const { return upload_position_; }
274
275 const std::string& encoding() const { return encoding_; }
276 void set_encoding(const std::string& encoding);
277 void reset_encoding() {
278 encoding_.clear();
279 }
280
281 const WebApplicationInfo& web_app_info() const {
282 return web_app_info_;
283 }
284
285 const SkBitmap& app_icon() const { return app_icon_; }
286
287 // Sets an app icon associated with TabContents and fires an INVALIDATE_TITLE
288 // navigation state change to trigger repaint of title.
289 void SetAppIcon(const SkBitmap& app_icon);
290
291 bool displayed_insecure_content() const {
292 return displayed_insecure_content_;
293 }
294
295 // Internal state ------------------------------------------------------------
296
297 // This flag indicates whether the tab contents is currently being
298 // screenshotted by the DraggedTabController.
299 bool capturing_contents() const { return capturing_contents_; }
300 void set_capturing_contents(bool cap) { capturing_contents_ = cap; }
301
302 // Indicates whether this tab should be considered crashed. The setter will
303 // also notify the delegate when the flag is changed.
304 bool is_crashed() const {
305 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
306 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
307 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
308 }
309 base::TerminationStatus crashed_status() const { return crashed_status_; }
310 int crashed_error_code() const { return crashed_error_code_; }
311 void SetIsCrashed(base::TerminationStatus status, int error_code);
312
313 // Call this after updating a page action to notify clients about the changes.
314 void PageActionStateChanged();
315
316 // Whether the tab is in the process of being destroyed.
317 // Added as a tentative work-around for focus related bug #4633. This allows
318 // us not to store focus when a tab is being closed.
319 bool is_being_destroyed() const { return is_being_destroyed_; }
320
321 // Convenience method for notifying the delegate of a navigation state
322 // change. See TabContentsDelegate.
323 void NotifyNavigationStateChanged(unsigned changed_flags);
324
325 // Invoked when the tab contents becomes selected. If you override, be sure
326 // and invoke super's implementation.
327 virtual void DidBecomeSelected();
328 base::TimeTicks last_selected_time() const {
329 return last_selected_time_;
330 }
331
332 // Invoked when the tab contents becomes hidden.
333 // NOTE: If you override this, call the superclass version too!
334 virtual void WasHidden();
335
336 // Activates this contents within its containing window, bringing that window
337 // to the foreground if necessary.
338 void Activate();
339
340 // Deactivates this contents by deactivating its containing window.
341 void Deactivate();
342
343 // TODO(brettw) document these.
344 virtual void ShowContents();
345 virtual void HideContents();
346
347 // Returns true if the before unload and unload listeners need to be
348 // fired. The value of this changes over time. For example, if true and the
349 // before unload listener is executed and allows the user to exit, then this
350 // returns false.
351 bool NeedToFireBeforeUnload();
352
353#ifdef UNIT_TEST
354 // Expose the render manager for testing.
355 RenderViewHostManager* render_manager() { return &render_manager_; }
356#endif
357
358 // In the underlying RenderViewHostManager, swaps in the provided
359 // RenderViewHost to replace the current RenderViewHost. The current RVH
360 // will be shutdown and ultimately deleted.
361 void SwapInRenderViewHost(RenderViewHost* rvh);
362
363 // Commands ------------------------------------------------------------------
364
365 // Implementation of PageNavigator.
366 virtual void OpenURL(const GURL& url, const GURL& referrer,
367 WindowOpenDisposition disposition,
368 PageTransition::Type transition);
369
370 // Called by the NavigationController to cause the TabContents to navigate to
371 // the current pending entry. The NavigationController should be called back
372 // with CommitPendingEntry/RendererDidNavigate on success or
373 // DiscardPendingEntry. The callbacks can be inside of this function, or at
374 // some future time.
375 //
376 // The entry has a PageID of -1 if newly created (corresponding to navigation
377 // to a new URL).
378 //
379 // If this method returns false, then the navigation is discarded (equivalent
380 // to calling DiscardPendingEntry on the NavigationController).
381 virtual bool NavigateToPendingEntry(
382 NavigationController::ReloadType reload_type);
383
384 // Stop any pending navigation.
385 virtual void Stop();
386
387 // Called on a TabContents when it isn't a popup, but a new window.
388 virtual void DisassociateFromPopupCount();
389
390 // Creates a new TabContents with the same state as this one. The returned
391 // heap-allocated pointer is owned by the caller.
392 virtual TabContents* Clone();
393
394 // Shows the page info.
395 void ShowPageInfo(const GURL& url,
396 const NavigationEntry::SSLStatus& ssl,
397 bool show_history);
398
399 // Saves the favicon for the current page.
400 void SaveFavicon();
401
402 // Window management ---------------------------------------------------------
403
404 // Create a new window constrained to this TabContents' clip and visibility.
405 // The window is initialized by using the supplied delegate to obtain basic
406 // window characteristics, and the supplied view for the content. Note that
407 // the returned ConstrainedWindow might not yet be visible.
408 ConstrainedWindow* CreateConstrainedDialog(
409 ConstrainedWindowDelegate* delegate);
410
411 // Adds a new tab or window with the given already-created contents
412 void AddNewContents(TabContents* new_contents,
413 WindowOpenDisposition disposition,
414 const gfx::Rect& initial_pos,
415 bool user_gesture);
416
417 // Execute code in this tab. Returns true if the message was successfully
418 // sent.
419 bool ExecuteCode(int request_id, const std::string& extension_id,
420 bool is_js_code, const std::string& code_string,
421 bool all_frames);
422
423 // Called when the blocked popup notification is shown or hidden.
424 virtual void PopupNotificationVisibilityChanged(bool visible);
425
426 // Returns the number of constrained windows in this tab. Used by tests.
427 size_t constrained_window_count() { return child_windows_.size(); }
428
429 typedef std::deque<ConstrainedWindow*> ConstrainedWindowList;
430
431 // Return an iterator for the first constrained window in this tab contents.
432 ConstrainedWindowList::iterator constrained_window_begin()
433 { return child_windows_.begin(); }
434
435 // Return an iterator for the last constrained window in this tab contents.
436 ConstrainedWindowList::iterator constrained_window_end()
437 { return child_windows_.end(); }
438
439 // Views and focus -----------------------------------------------------------
440 // TODO(brettw): Most of these should be removed and the caller should call
441 // the view directly.
442
443 // Returns the actual window that is focused when this TabContents is shown.
444 gfx::NativeView GetContentNativeView() const;
445
446 // Returns the NativeView associated with this TabContents. Outside of
447 // automation in the context of the UI, this is required to be implemented.
448 gfx::NativeView GetNativeView() const;
449
450 // Returns the bounds of this TabContents in the screen coordinate system.
451 void GetContainerBounds(gfx::Rect *out) const;
452
453 // Makes the tab the focused window.
454 void Focus();
455
456 // Focuses the first (last if |reverse| is true) element in the page.
457 // Invoked when this tab is getting the focus through tab traversal (|reverse|
458 // is true when using Shift-Tab).
459 void FocusThroughTabTraversal(bool reverse);
460
461 // These next two functions are declared on RenderViewHostManager::Delegate
462 // but also accessed directly by other callers.
463
464 // Returns true if the location bar should be focused by default rather than
465 // the page contents. The view calls this function when the tab is focused
466 // to see what it should do.
467 virtual bool FocusLocationBarByDefault();
468
469 // Focuses the location bar.
470 virtual void SetFocusToLocationBar(bool select_all);
471
472 // Creates a view and sets the size for the specified RVH.
473 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh);
474
475 // Infobars ------------------------------------------------------------------
476
477 // Adds an InfoBar for the specified |delegate|.
[email protected]dc83fcbd2011-02-23 23:26:52478 void AddInfoBar(InfoBarDelegate* delegate);
[email protected]0dd3a0ab2011-02-18 08:17:44479
480 // Removes the InfoBar for the specified |delegate|.
481 void RemoveInfoBar(InfoBarDelegate* delegate);
482
483 // Replaces one infobar with another, without any animation in between.
484 void ReplaceInfoBar(InfoBarDelegate* old_delegate,
485 InfoBarDelegate* new_delegate);
486
487 // Enumeration and access functions.
488 size_t infobar_count() const { return infobar_delegates_.size(); }
489 // WARNING: This does not sanity-check |index|!
490 InfoBarDelegate* GetInfoBarDelegateAt(size_t index) {
491 return infobar_delegates_[index];
492 }
493
494 // Toolbars and such ---------------------------------------------------------
495
496 // Returns true if a Bookmark Bar should be shown for this tab.
497 virtual bool ShouldShowBookmarkBar();
498
499 // Notifies the delegate that a download is about to be started.
500 // This notification is fired before a local temporary file has been created.
501 bool CanDownload(int request_id);
502
503 // Notifies the delegate that a download started.
504 void OnStartDownload(DownloadItem* download);
505
506 // Notify our delegate that some of our content has animated.
507 void ToolbarSizeChanged(bool is_animating);
508
509 // Called when a ConstrainedWindow we own is about to be closed.
510 void WillClose(ConstrainedWindow* window);
511
512 // Called when a BlockedContentContainer we own is about to be closed.
513 void WillCloseBlockedContentContainer(BlockedContentContainer* container);
514
515 // Called when a ConstrainedWindow we own is moved or resized.
516 void DidMoveOrResize(ConstrainedWindow* window);
517
518 // Interstitials -------------------------------------------------------------
519
520 // Various other systems need to know about our interstitials.
521 bool showing_interstitial_page() const {
522 return render_manager_.interstitial_page() != NULL;
523 }
524
525 // Sets the passed passed interstitial as the currently showing interstitial.
526 // |interstitial_page| should be non NULL (use the remove_interstitial_page
527 // method to unset the interstitial) and no interstitial page should be set
528 // when there is already a non NULL interstitial page set.
529 void set_interstitial_page(InterstitialPage* interstitial_page) {
530 render_manager_.set_interstitial_page(interstitial_page);
531 }
532
533 // Unsets the currently showing interstitial.
534 void remove_interstitial_page() {
535 render_manager_.remove_interstitial_page();
536 }
537
538 // Returns the currently showing interstitial, NULL if no interstitial is
539 // showing.
540 InterstitialPage* interstitial_page() const {
541 return render_manager_.interstitial_page();
542 }
543
544 // Misc state & callbacks ----------------------------------------------------
545
546 // Set whether the contents should block javascript message boxes or not.
547 // Default is not to block any message boxes.
548 void set_suppress_javascript_messages(bool suppress_javascript_messages) {
549 suppress_javascript_messages_ = suppress_javascript_messages;
550 }
551
552 // Prepare for saving the current web page to disk.
553 void OnSavePage();
554
555 // Save page with the main HTML file path, the directory for saving resources,
556 // and the save type: HTML only or complete web page. Returns true if the
557 // saving process has been initiated successfully.
558 bool SavePage(const FilePath& main_file, const FilePath& dir_path,
559 SavePackage::SavePackageType save_type);
560
561 // Tells the user's email client to open a compose window containing the
562 // current page's URL.
563 void EmailPageLocation();
564
565 // Displays asynchronously a print preview (generated by the renderer) if not
566 // already displayed and ask the user for its preferred print settings with
567 // the "Print..." dialog box. (managed by the print worker thread).
568 // TODO(maruel): Creates a snapshot of the renderer to be used for the new
569 // tab for the printing facility.
570 void PrintPreview();
571
572 // Prints the current document immediately. Since the rendering is
573 // asynchronous, the actual printing will not be completed on the return of
574 // this function. Returns false if printing is impossible at the moment.
575 bool PrintNow();
576
577 // Notify the completion of a printing job.
578 void PrintingDone(int document_cookie, bool success);
579
580 // Returns true if the active NavigationEntry's page_id equals page_id.
581 bool IsActiveEntry(int32 page_id);
582
583 const std::string& contents_mime_type() const {
584 return contents_mime_type_;
585 }
586
587 // Returns true if this TabContents will notify about disconnection.
588 bool notify_disconnection() const { return notify_disconnection_; }
589
590 // Override the encoding and reload the page by sending down
591 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
592 // the opposite of this, by which 'browser' is notified of
593 // the encoding of the current tab from 'renderer' (determined by
594 // auto-detect, http header, meta, bom detection, etc).
595 void SetOverrideEncoding(const std::string& encoding);
596
597 // Remove any user-defined override encoding and reload by sending down
598 // ViewMsg_ResetPageEncodingToDefault to the renderer.
599 void ResetOverrideEncoding();
600
601 void WindowMoveOrResizeStarted();
602
603 // Sets whether all TabContents added by way of |AddNewContents| should be
604 // blocked. Transitioning from all blocked to not all blocked results in
605 // reevaluating any blocked TabContents, which may result in unblocking some
606 // of the blocked TabContents.
607 void SetAllContentsBlocked(bool value);
608
609 BlockedContentContainer* blocked_content_container() const {
610 return blocked_contents_;
611 }
612
613 RendererPreferences* GetMutableRendererPrefs() {
614 return &renderer_preferences_;
615 }
616
617 void set_opener_web_ui_type(WebUITypeID opener_web_ui_type) {
618 opener_web_ui_type_ = opener_web_ui_type;
619 }
620
621 // We want to time how long it takes to create a new tab page. This method
622 // gets called as parts of the new tab page have loaded.
623 void LogNewTabTime(const std::string& event_name);
624
625 // Set the time when we started to create the new tab page. This time is
626 // from before we created this TabContents.
627 void set_new_tab_start_time(const base::TimeTicks& time) {
628 new_tab_start_time_ = time;
629 }
630
631 // Notification that tab closing has started. This can be called multiple
632 // times, subsequent calls are ignored.
633 void OnCloseStarted();
634
635 LanguageState& language_state() {
636 return language_state_;
637 }
638
639 // Returns true if underlying TabContentsView should accept drag-n-drop.
640 bool ShouldAcceptDragAndDrop() const;
641
642 // A render view-originated drag has ended. Informs the render view host and
643 // tab contents delegate.
644 void SystemDragEnded();
645
646 // Indicates if this tab was explicitly closed by the user (control-w, close
647 // tab menu item...). This is false for actions that indirectly close the tab,
648 // such as closing the window. The setter is maintained by TabStripModel, and
649 // the getter only useful from within TAB_CLOSED notification
650 void set_closed_by_user_gesture(bool value) {
651 closed_by_user_gesture_ = value;
652 }
653 bool closed_by_user_gesture() const { return closed_by_user_gesture_; }
654
655 // Overridden from JavaScriptAppModalDialogDelegate:
656 virtual void OnMessageBoxClosed(IPC::Message* reply_msg,
657 bool success,
658 const std::wstring& prompt);
659 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes);
660 virtual gfx::NativeWindow GetMessageBoxRootWindow();
661 virtual TabContents* AsTabContents();
662 virtual ExtensionHost* AsExtensionHost();
663
664 // The BookmarkDragDelegate is used to forward bookmark drag and drop events
665 // to extensions.
666 virtual RenderViewHostDelegate::BookmarkDrag* GetBookmarkDragDelegate();
667
668 // It is up to callers to call SetBookmarkDragDelegate(NULL) when
669 // |bookmark_drag| is deleted since this class does not take ownership of
670 // |bookmark_drag|.
671 virtual void SetBookmarkDragDelegate(
672 RenderViewHostDelegate::BookmarkDrag* bookmark_drag);
673
674 // The TabSpecificContentSettings object is used to query the blocked content
675 // state by various UI elements.
676 TabSpecificContentSettings* GetTabSpecificContentSettings() const;
677
678 // Updates history with the specified navigation. This is called by
679 // OnMsgNavigate to update history state.
680 void UpdateHistoryForNavigation(
681 scoped_refptr<history::HistoryAddPageArgs> add_page_args);
682
683 // Sends the page title to the history service. This is called when we receive
684 // the page title and we know we want to update history.
685 void UpdateHistoryPageTitle(const NavigationEntry& entry);
686
687 // Gets the zoom level for this tab.
688 double GetZoomLevel() const;
689
690 // Gets the zoom percent for this tab.
691 int GetZoomPercent(bool* enable_increment, bool* enable_decrement);
692
693 // Shows a fade effect over this tab contents. Repeated calls will be ignored
694 // until the fade is canceled. If |animate| is true the fade should animate.
695 void FadeForInstant(bool animate);
696
697 // Immediately removes the fade.
698 void CancelInstantFade();
699
700 // Opens view-source tab for this contents.
701 void ViewSource();
702
[email protected]932b7a12011-03-09 12:50:27703 void ViewFrameSource(const GURL& url,
704 const std::string& content_state);
705
[email protected]0dd3a0ab2011-02-18 08:17:44706 // Gets the minimum/maximum zoom percent.
707 int minimum_zoom_percent() const { return minimum_zoom_percent_; }
708 int maximum_zoom_percent() const { return maximum_zoom_percent_; }
709
710 int content_restrictions() const { return content_restrictions_; }
711
712 AutocompleteHistoryManager* autocomplete_history_manager() {
713 return autocomplete_history_manager_.get();
714 }
[email protected]c4a9e932011-03-05 04:05:55715 AutofillManager* autofill_manager() { return autofill_manager_.get(); }
[email protected]0dd3a0ab2011-02-18 08:17:44716
717 safe_browsing::ClientSideDetectionHost* safebrowsing_detection_host() {
718 return safebrowsing_detection_host_.get();
719 }
720
721 protected:
722 // from RenderViewHostDelegate.
723 virtual bool OnMessageReceived(const IPC::Message& message);
724
725 private:
726 friend class NavigationController;
727 // Used to access the child_windows_ (ConstrainedWindowList) for testing
728 // automation purposes.
729 friend class TestingAutomationProvider;
730
731 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, NoJSMessageOnInterstitials);
732 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, UpdateTitle);
733 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, CrossSiteCantPreemptAfterUnload);
[email protected]aed59602011-02-28 22:57:33734 FRIEND_TEST_ALL_PREFIXES(TabContentsTest, ConstrainedWindows);
[email protected]0dd3a0ab2011-02-18 08:17:44735 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
736 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
737 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload);
738
739 // Temporary until the view/contents separation is complete.
740 friend class TabContentsView;
741#if defined(OS_WIN)
742 friend class TabContentsViewWin;
743#elif defined(OS_MACOSX)
744 friend class TabContentsViewMac;
745#elif defined(TOOLKIT_USES_GTK)
746 friend class TabContentsViewGtk;
747#endif
748
749 // So InterstitialPage can access SetIsLoading.
750 friend class InterstitialPage;
751
752 // TODO(brettw) TestTabContents shouldn't exist!
753 friend class TestTabContents;
754
755 // Used to access the CreateHistoryAddPageArgs member function.
756 friend class ExternalTabContainer;
757
758 // Used to access RVH Delegates.
759 friend class prerender::PrerenderManager;
760
761 // Add all the TabContentObservers.
762 void AddObservers();
763
764 // Message handlers.
765 void OnDidStartProvisionalLoadForFrame(int64 frame_id,
766 bool main_frame,
767 const GURL& url);
768 void OnDidRedirectProvisionalLoad(int32 page_id,
769 const GURL& source_url,
770 const GURL& target_url);
771 void OnDidFailProvisionalLoadWithError(int64 frame_id,
772 bool main_frame,
773 int error_code,
774 const GURL& url,
775 bool showing_repost_interstitial);
776 void OnDidLoadResourceFromMemoryCache(const GURL& url,
777 const std::string& security_info);
778 void OnDidDisplayInsecureContent();
779 void OnDidRunInsecureContent(const std::string& security_origin,
780 const GURL& target_url);
781 void OnDocumentLoadedInFrame(int64 frame_id);
782 void OnDidFinishLoad(int64 frame_id);
783 void OnUpdateContentRestrictions(int restrictions);
784 void OnPDFHasUnsupportedFeature();
785
786 void OnGoToEntryAtOffset(int offset);
787 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info);
788 void OnInstallApplication(const WebApplicationInfo& info);
789 void OnPageContents(const GURL& url,
790 int32 page_id,
791 const string16& contents,
792 const std::string& language,
793 bool page_translatable);
794 void OnPageTranslated(int32 page_id,
795 const std::string& original_lang,
796 const std::string& translated_lang,
797 TranslateErrors::Type error_type);
798 void OnSetSuggestions(int32 page_id,
[email protected]1c9c7fb2011-03-11 16:38:38799 const std::vector<std::string>& suggestions,
[email protected]33b8b8e2011-03-15 14:51:55800 InstantCompleteBehavior behavior);
[email protected]0dd3a0ab2011-02-18 08:17:44801 void OnInstantSupportDetermined(int32 page_id, bool result);
[email protected]0dd3a0ab2011-02-18 08:17:44802
803 // Changes the IsLoading state and notifies delegate as needed
804 // |details| is used to provide details on the load that just finished
805 // (but can be null if not applicable). Can be overridden.
806 void SetIsLoading(bool is_loading,
807 LoadNotificationDetails* details);
808
809 // Adds the incoming |new_contents| to the |blocked_contents_| container.
810 void AddPopup(TabContents* new_contents,
811 const gfx::Rect& initial_pos);
812
813 // Called by derived classes to indicate that we're no longer waiting for a
814 // response. This won't actually update the throbber, but it will get picked
815 // up at the next animation step if the throbber is going.
816 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
817
818 ConstrainedWindowList child_windows_;
819
820 // Expires InfoBars that need to be expired, according to the state carried
821 // in |details|, in response to a new NavigationEntry being committed (the
822 // user navigated to another page).
823 void ExpireInfoBars(
824 const NavigationController::LoadCommittedDetails& details);
825
826 // Returns the WebUI for the current state of the tab. This will either be
827 // the pending WebUI, the committed WebUI, or NULL.
828 WebUI* GetWebUIForCurrentState();
829
830 // Navigation helpers --------------------------------------------------------
831 //
832 // These functions are helpers for Navigate() and DidNavigate().
833
834 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
835 // committed to the navigation controller. Note that the navigation entry is
836 // not provided since it may be invalid/changed after being committed. The
837 // current navigation entry is in the NavigationController at this point.
838 void DidNavigateMainFramePostCommit(
839 const NavigationController::LoadCommittedDetails& details,
840 const ViewHostMsg_FrameNavigate_Params& params);
841 void DidNavigateAnyFramePostCommit(
842 RenderViewHost* render_view_host,
843 const NavigationController::LoadCommittedDetails& details,
844 const ViewHostMsg_FrameNavigate_Params& params);
845
846 // Closes all constrained windows.
847 void CloseConstrainedWindows();
848
849 // Send the alternate error page URL to the renderer. This method is virtual
850 // so special html pages can override this (e.g., the new tab page).
851 virtual void UpdateAlternateErrorPageURL();
852
853 // Send webkit specific settings to the renderer.
854 void UpdateWebPreferences();
855
856 // Instruct the renderer to update the zoom level.
857 void UpdateZoomLevel();
858
859 // If our controller was restored and the page id is > than the site
860 // instance's page id, the site instances page id is updated as well as the
861 // renderers max page id.
862 void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
863 RenderViewHost* rvh);
864
865 // Returns the history::HistoryAddPageArgs to use for adding a page to
866 // history.
867 scoped_refptr<history::HistoryAddPageArgs> CreateHistoryAddPageArgs(
868 const GURL& virtual_url,
869 const NavigationController::LoadCommittedDetails& details,
870 const ViewHostMsg_FrameNavigate_Params& params);
871
872 // Saves the given title to the navigation entry and does associated work. It
873 // will update history and the view for the new title, and also synthesize
874 // titles for file URLs that have none (so we require that the URL of the
875 // entry already be set).
876 //
877 // This is used as the backend for state updates, which include a new title,
878 // or the dedicated set title message. It returns true if the new title is
879 // different and was therefore updated.
880 bool UpdateTitleForEntry(NavigationEntry* entry, const std::wstring& title);
881
882 // Causes the TabContents to navigate in the right renderer to |entry|, which
883 // must be already part of the entries in the navigation controller.
884 // This does not change the NavigationController state.
885 bool NavigateToEntry(const NavigationEntry& entry,
886 NavigationController::ReloadType reload_type);
887
888 // Misc non-view stuff -------------------------------------------------------
889
890 // Helper functions for sending notifications.
891 void NotifySwapped();
892 void NotifyConnected();
893 void NotifyDisconnected();
894
895 // TabSpecificContentSettings::Delegate implementation.
896 virtual void OnContentSettingsAccessed(bool content_was_blocked);
897
898 // RenderViewHostDelegate ----------------------------------------------------
899
900 // RenderViewHostDelegate implementation.
901 virtual RenderViewHostDelegate::View* GetViewDelegate();
902 virtual RenderViewHostDelegate::RendererManagement*
903 GetRendererManagementDelegate();
904 virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate();
905 virtual RenderViewHostDelegate::SSL* GetSSLDelegate();
906 virtual AutomationResourceRoutingDelegate*
907 GetAutomationResourceRoutingDelegate();
908 virtual TabContents* GetAsTabContents();
909 virtual ViewType::Type GetRenderViewType() const;
910 virtual int GetBrowserWindowID() const;
911 virtual void RenderViewCreated(RenderViewHost* render_view_host);
912 virtual void RenderViewReady(RenderViewHost* render_view_host);
913 virtual void RenderViewGone(RenderViewHost* render_view_host,
914 base::TerminationStatus status,
915 int error_code);
916 virtual void RenderViewDeleted(RenderViewHost* render_view_host);
917 virtual void DidNavigate(RenderViewHost* render_view_host,
918 const ViewHostMsg_FrameNavigate_Params& params);
919 virtual void UpdateState(RenderViewHost* render_view_host,
920 int32 page_id,
921 const std::string& state);
922 virtual void UpdateTitle(RenderViewHost* render_view_host,
923 int32 page_id,
924 const std::wstring& title);
925 virtual void UpdateEncoding(RenderViewHost* render_view_host,
926 const std::string& encoding);
927 virtual void UpdateTargetURL(int32 page_id, const GURL& url);
928 virtual void UpdateThumbnail(const GURL& url,
929 const SkBitmap& bitmap,
930 const ThumbnailScore& score);
931 virtual void UpdateInspectorSetting(const std::string& key,
932 const std::string& value);
933 virtual void ClearInspectorSettings();
934 virtual void Close(RenderViewHost* render_view_host);
935 virtual void RequestMove(const gfx::Rect& new_bounds);
936 virtual void DidStartLoading();
937 virtual void DidStopLoading();
938 virtual void DidChangeLoadProgress(double progress);
939 virtual void DocumentOnLoadCompletedInMainFrame(
940 RenderViewHost* render_view_host,
941 int32 page_id);
942 virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
943 WindowOpenDisposition disposition);
944 virtual void DomOperationResponse(const std::string& json_string,
945 int automation_id);
946 virtual void ProcessWebUIMessage(const ViewHostMsg_DomMessage_Params& params);
947 virtual void ProcessExternalHostMessage(const std::string& message,
948 const std::string& origin,
949 const std::string& target);
950 virtual void RunJavaScriptMessage(const std::wstring& message,
951 const std::wstring& default_prompt,
952 const GURL& frame_url,
953 const int flags,
954 IPC::Message* reply_msg,
955 bool* did_suppress_message);
956 virtual void RunBeforeUnloadConfirm(const std::wstring& message,
957 IPC::Message* reply_msg);
[email protected]0dd3a0ab2011-02-18 08:17:44958 virtual GURL GetAlternateErrorPageURL() const;
959 virtual RendererPreferences GetRendererPrefs(Profile* profile) const;
960 virtual WebPreferences GetWebkitPrefs();
961 virtual void OnUserGesture();
962 virtual void OnIgnoredUIEvent();
963 virtual void OnCrossSiteResponse(int new_render_process_host_id,
964 int new_request_id);
965 virtual void RendererUnresponsive(RenderViewHost* render_view_host,
966 bool is_during_unload);
967 virtual void RendererResponsive(RenderViewHost* render_view_host);
968 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state,
969 uint64 upload_position, uint64 upload_size);
970 virtual bool IsExternalTabContainer() const;
971 virtual void DidInsertCSS();
972 virtual void FocusedNodeChanged(bool is_editable_node);
973 virtual void UpdateZoomLimits(int minimum_percent,
974 int maximum_percent,
975 bool remember);
976 virtual void WorkerCrashed();
977
978 // RenderViewHostManager::Delegate -------------------------------------------
979
980 // Blocks/unblocks interaction with renderer process.
981 void BlockTabContent(bool blocked);
982
983 virtual void BeforeUnloadFiredFromRenderManager(
984 bool proceed,
985 bool* proceed_to_fire_unload);
986 virtual void DidStartLoadingFromRenderManager(
987 RenderViewHost* render_view_host);
988 virtual void RenderViewGoneFromRenderManager(
989 RenderViewHost* render_view_host);
990 virtual void UpdateRenderViewSizeForRenderManager();
991 virtual void NotifySwappedFromRenderManager();
992 virtual NavigationController& GetControllerForRenderManager();
993 virtual WebUI* CreateWebUIForRenderManager(const GURL& url);
994 virtual NavigationEntry* GetLastCommittedNavigationEntryForRenderManager();
995
996 // Initializes the given renderer if necessary and creates the view ID
997 // corresponding to this view host. If this method is not called and the
998 // process is not shared, then the TabContents will act as though the renderer
999 // is not running (i.e., it will render "sad tab"). This method is
1000 // automatically called from LoadURL.
1001 //
1002 // If you are attaching to an already-existing RenderView, you should call
1003 // InitWithExistingID.
1004 virtual bool CreateRenderViewForRenderManager(
1005 RenderViewHost* render_view_host);
1006
1007 // NotificationObserver ------------------------------------------------------
1008
1009 virtual void Observe(NotificationType type,
1010 const NotificationSource& source,
1011 const NotificationDetails& details);
1012
1013 // App extensions related methods:
1014
1015 // Returns the first extension whose extent contains |url|.
1016 const Extension* GetExtensionContaining(const GURL& url);
1017
1018 // Resets app_icon_ and if |extension| is non-null creates a new
1019 // ImageLoadingTracker to load the extension's image.
1020 void UpdateExtensionAppIcon(const Extension* extension);
1021
1022 // ImageLoadingTracker::Observer.
[email protected]bd5174d2011-03-11 01:02:561023 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource,
[email protected]0dd3a0ab2011-02-18 08:17:441024 int index);
1025
[email protected]232a5812011-03-04 22:42:081026 // NetworkChangeNotifier::OnlineStateObserver:
1027 virtual void OnOnlineStateChanged(bool online);
1028
[email protected]aed59602011-02-28 22:57:331029 // Adds the given window to the list of child windows. The window will notify
1030 // via WillClose() when it is being destroyed.
1031 void AddConstrainedDialog(ConstrainedWindow* window);
1032
[email protected]0dd3a0ab2011-02-18 08:17:441033 // Data for core operation ---------------------------------------------------
1034
1035 // Delegate for notifying our owner about stuff. Not owned by us.
1036 TabContentsDelegate* delegate_;
1037
1038 // Handles the back/forward list and loading.
1039 NavigationController controller_;
1040
1041 // The corresponding view.
1042 scoped_ptr<TabContentsView> view_;
1043
1044 // Helper classes ------------------------------------------------------------
1045
1046 // Manages creation and swapping of render views.
1047 RenderViewHostManager render_manager_;
1048
1049 // Stores random bits of data for others to associate with this object.
1050 PropertyBag property_bag_;
1051
1052 // Registers and unregisters us for notifications.
1053 NotificationRegistrar registrar_;
1054
1055 // Registers and unregisters for pref notifications.
1056 PrefChangeRegistrar pref_change_registrar_;
1057
1058 // Handles print job for this contents.
1059 scoped_ptr<printing::PrintViewManager> printing_;
1060
1061 // Handles print preview for this contents.
1062 scoped_ptr<printing::PrintPreviewMessageHandler> print_preview_;
1063
1064 // SavePackage, lazily created.
1065 scoped_refptr<SavePackage> save_package_;
1066
1067 // AutocompleteHistoryManager.
1068 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
1069
[email protected]c4a9e932011-03-05 04:05:551070 // AutofillManager.
1071 scoped_ptr<AutofillManager> autofill_manager_;
[email protected]0dd3a0ab2011-02-18 08:17:441072
1073 // Handles plugin messages.
1074 scoped_ptr<PluginObserver> plugin_observer_;
1075
[email protected]0dd3a0ab2011-02-18 08:17:441076 // TabContentsSSLHelper, lazily created.
1077 scoped_ptr<TabContentsSSLHelper> ssl_helper_;
1078
[email protected]0dd3a0ab2011-02-18 08:17:441079 // Handles drag and drop event forwarding to extensions.
1080 BookmarkDrag* bookmark_drag_;
1081
1082 // Handles downloading favicons.
[email protected]16be5c32011-03-15 17:52:031083 scoped_ptr<FaviconHelper> favicon_helper_;
[email protected]0dd3a0ab2011-02-18 08:17:441084
1085 // Cached web app info data.
1086 WebApplicationInfo web_app_info_;
1087
1088 // Cached web app icon.
1089 SkBitmap app_icon_;
1090
1091 // RenderViewHost::ContentSettingsDelegate.
1092 scoped_ptr<TabSpecificContentSettings> content_settings_delegate_;
1093
1094 // Handles desktop notification IPCs.
1095 scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_;
1096
1097 // Handles IPCs related to SafeBrowsing client-side phishing detection.
1098 scoped_ptr<safe_browsing::ClientSideDetectionHost>
1099 safebrowsing_detection_host_;
1100
1101 // Data for loading state ----------------------------------------------------
1102
1103 // Indicates whether we're currently loading a resource.
1104 bool is_loading_;
1105
1106 // Indicates if the tab is considered crashed.
1107 base::TerminationStatus crashed_status_;
1108 int crashed_error_code_;
1109
1110 // See waiting_for_response() above.
1111 bool waiting_for_response_;
1112
1113 // Indicates the largest PageID we've seen. This field is ignored if we are
1114 // a TabContents, in which case the max page ID is stored separately with
1115 // each SiteInstance.
1116 // TODO(brettw) this seems like it can be removed according to the comment.
1117 int32 max_page_id_;
1118
1119 // System time at which the current load was started.
1120 base::TimeTicks current_load_start_;
1121
1122 // The current load state and the URL associated with it.
1123 net::LoadState load_state_;
1124 string16 load_state_host_;
1125 // Upload progress, for displaying in the status bar.
1126 // Set to zero when there is no significant upload happening.
1127 uint64 upload_size_;
1128 uint64 upload_position_;
1129
1130 // Data for current page -----------------------------------------------------
1131
1132 // Whether we have a (non-empty) title for the current page.
1133 // Used to prevent subsequent title updates from affecting history. This
1134 // prevents some weirdness because some AJAXy apps use titles for status
1135 // messages.
1136 bool received_page_title_;
1137
1138 // When a navigation occurs, we record its contents MIME type. It can be
1139 // used to check whether we can do something for some special contents.
1140 std::string contents_mime_type_;
1141
1142 // Character encoding.
1143 std::string encoding_;
1144
1145 // Object that holds any blocked TabContents spawned from this TabContents.
1146 BlockedContentContainer* blocked_contents_;
1147
1148 // Should we block all child TabContents this attempts to spawn.
1149 bool all_contents_blocked_;
1150
1151 // TODO(pkasting): Hack to try and fix Linux browser tests.
1152 bool dont_notify_render_view_;
1153
1154 // True if this is a secure page which displayed insecure content.
1155 bool displayed_insecure_content_;
1156
1157 // Data for shelves and stuff ------------------------------------------------
1158
1159 // Delegates for InfoBars associated with this TabContents.
1160 std::vector<InfoBarDelegate*> infobar_delegates_;
1161
1162 // Data for app extensions ---------------------------------------------------
1163
1164 // If non-null this tab is an app tab and this is the extension the tab was
1165 // created for.
1166 const Extension* extension_app_;
1167
1168 // Icon for extension_app_ (if non-null) or extension_for_current_page_.
1169 SkBitmap extension_app_icon_;
1170
1171 // Used for loading extension_app_icon_.
1172 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
1173
1174 // Data for misc internal state ----------------------------------------------
1175
1176 // See capturing_contents() above.
1177 bool capturing_contents_;
1178
1179 // See getter above.
1180 bool is_being_destroyed_;
1181
1182 // Indicates whether we should notify about disconnection of this
1183 // TabContents. This is used to ensure disconnection notifications only
1184 // happen if a connection notification has happened and that they happen only
1185 // once.
1186 bool notify_disconnection_;
1187
1188 // Maps from handle to page_id.
1189 typedef std::map<FaviconService::Handle, int32> HistoryRequestMap;
1190 HistoryRequestMap history_requests_;
1191
1192#if defined(OS_WIN)
1193 // Handle to an event that's set when the page is showing a message box (or
1194 // equivalent constrained window). Plugin processes check this to know if
1195 // they should pump messages then.
1196 base::win::ScopedHandle message_box_active_;
1197#endif
1198
1199 // The time that the last javascript message was dismissed.
1200 base::TimeTicks last_javascript_message_dismissal_;
1201
1202 // True if the user has decided to block future javascript messages. This is
1203 // reset on navigations to false on navigations.
1204 bool suppress_javascript_messages_;
1205
1206 // Set to true when there is an active "before unload" dialog. When true,
1207 // we've forced the throbber to start in Navigate, and we need to remember to
1208 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1209 bool is_showing_before_unload_dialog_;
1210
1211 // Shows an info-bar to users when they search from a known search engine and
1212 // have never used the monibox for search before.
1213 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_;
1214
1215 // Settings that get passed to the renderer process.
1216 RendererPreferences renderer_preferences_;
1217
1218 // If this tab was created from a renderer using window.open, this will be
1219 // non-NULL and represent the WebUI of the opening renderer.
1220 WebUITypeID opener_web_ui_type_;
1221
1222 // The time that we started to create the new tab page.
1223 base::TimeTicks new_tab_start_time_;
1224
1225 // The time that we started to close the tab.
1226 base::TimeTicks tab_close_start_time_;
1227
1228 // The time that this tab was last selected.
1229 base::TimeTicks last_selected_time_;
1230
1231 // Information about the language the page is in and has been translated to.
1232 LanguageState language_state_;
1233
1234 // See description above setter.
1235 bool closed_by_user_gesture_;
1236
1237 // Minimum/maximum zoom percent.
1238 int minimum_zoom_percent_;
1239 int maximum_zoom_percent_;
1240 // If true, the default zoom limits have been overriden for this tab, in which
1241 // case we don't want saved settings to apply to it and we don't want to
1242 // remember it.
1243 bool temporary_zoom_settings_;
1244
1245 // A list of observers notified when page state changes. Weak references.
1246 ObserverList<TabContentsObserver> observers_;
1247
1248 // Content restrictions, used to disable print/copy etc based on content's
1249 // (full-page plugins for now only) permissions.
1250 int content_restrictions_;
1251
[email protected]0dd3a0ab2011-02-18 08:17:441252 DISALLOW_COPY_AND_ASSIGN(TabContents);
1253};
1254
1255#endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_