summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/tab_contents.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 05:16:32 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 05:16:32 +0000
commit420ae012547bd2a176a0e0f5de27bc540b28a255 (patch)
treed20918df32ca7d86da1d9efb68e3da3cbd1df10b /chrome/browser/tab_contents/tab_contents.h
parentee734f6a14db32a073d7694b0fb288793dfaf57e (diff)
downloadchromium_src-420ae012547bd2a176a0e0f5de27bc540b28a255.zip
chromium_src-420ae012547bd2a176a0e0f5de27bc540b28a255.tar.gz
chromium_src-420ae012547bd2a176a0e0f5de27bc540b28a255.tar.bz2
Kill WebContents by moving the remaining methods to TabContents. WebContents
remains as a shell so I don't have to change all the callers in this CL. Review URL: http://codereview.chromium.org/92115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/tab_contents.h')
-rw-r--r--chrome/browser/tab_contents/tab_contents.h340
1 files changed, 316 insertions, 24 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 71559cb..d45d1dc 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -102,6 +102,10 @@ class TabContents : public PageNavigator,
INVALIDATE_EVERYTHING = 0xFFFFFFFF
};
+ TabContents(Profile* profile,
+ SiteInstance* site_instance,
+ int routing_id,
+ base::WaitableEvent* modal_dialog_event);
virtual ~TabContents();
static void RegisterUserPrefs(PrefService* prefs);
@@ -115,7 +119,8 @@ class TabContents : public PageNavigator,
PropertyBag* property_bag() { return &property_bag_; }
// Returns this object as a WebContents if it is one, and NULL otherwise.
- virtual WebContents* AsWebContents() = 0;
+ // TODO(brettw) this should not be necessary.
+ WebContents* AsWebContents();
// Const version of above for situations where const TabContents*'s are used.
WebContents* AsWebContents() const {
@@ -317,6 +322,9 @@ class TabContents : public PageNavigator,
// heap-allocated pointer is owned by the caller.
virtual TabContents* Clone();
+ // Tell Gears to create a shortcut for the current page.
+ void CreateShortcut();
+
// Window management ---------------------------------------------------------
#if defined(OS_WIN)
@@ -500,12 +508,88 @@ class TabContents : public PageNavigator,
// Accessor for find_result_.
const FindNotificationDetails& find_result() const { return find_result_; }
- protected:
+ // Misc state & callbacks ----------------------------------------------------
+
+ // Set whether the contents should block javascript message boxes or not.
+ // Default is not to block any message boxes.
+ void set_suppress_javascript_messages(bool suppress_javascript_messages) {
+ suppress_javascript_messages_ = suppress_javascript_messages;
+ }
+
+ // AppModalDialog calls this when the dialog is closed.
+ void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
+ bool success,
+ const std::wstring& prompt);
+
+ // Prepare for saving the current web page to disk.
+ void OnSavePage();
+
+ // Save page with the main HTML file path, the directory for saving resources,
+ // and the save type: HTML only or complete web page.
+ void SavePage(const std::wstring& main_file,
+ const std::wstring& dir_path,
+ SavePackage::SavePackageType save_type);
+
+ // Displays asynchronously a print preview (generated by the renderer) if not
+ // already displayed and ask the user for its preferred print settings with
+ // the "Print..." dialog box. (managed by the print worker thread).
+ // TODO(maruel): Creates a snapshot of the renderer to be used for the new
+ // tab for the printing facility.
+ void PrintPreview();
+
+ // Prints the current document immediately. Since the rendering is
+ // asynchronous, the actual printing will not be completed on the return of
+ // this function. Returns false if printing is impossible at the moment.
+ bool PrintNow();
+
+ // Returns true if the active NavigationEntry's page_id equals page_id.
+ bool IsActiveEntry(int32 page_id);
+
+ const std::string& contents_mime_type() const {
+ return contents_mime_type_;
+ }
+
+ // Returns true if this WebContents will notify about disconnection.
+ bool notify_disconnection() const { return notify_disconnection_; }
+
+ // Override the encoding and reload the page by sending down
+ // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
+ // the opposite of this, by which 'browser' is notified of
+ // the encoding of the current tab from 'renderer' (determined by
+ // auto-detect, http header, meta, bom detection, etc).
+ void override_encoding(const std::wstring& encoding) {
+ set_encoding(encoding);
+ render_view_host()->SetPageEncoding(encoding);
+ }
+
+ void CrossSiteNavigationCanceled() {
+ render_manager_.CrossSiteNavigationCanceled();
+ }
+
+ void WindowMoveOrResizeStarted() {
+ render_view_host()->WindowMoveOrResizeStarted();
+ }
+
+ private:
friend class NavigationController;
// Used to access the child_windows_ (ConstrainedWindowList) for testing
// automation purposes.
friend class AutomationProvider;
+ FRIEND_TEST(WebContentsTest, UpdateTitle);
+
+ // Temporary until the view/contents separation is complete.
+ friend class TabContentsView;
+#if defined(OS_WIN)
+ friend class TabContentsViewWin;
+#elif defined(OS_MACOSX)
+ friend class TabContentsViewMac;
+#elif defined(OS_LINUX)
+ friend class TabContentsViewGtk;
+#endif
+
+ // So InterstitialPage can access SetIsLoading.
+ friend class InterstitialPage;
// When CreateShortcut is invoked RenderViewHost::GetApplicationInfo is
// invoked. CreateShortcut caches the state of the page needed to create the
// shortcut in PendingInstall. When OnDidGetApplicationInfo is invoked, it
@@ -522,28 +606,8 @@ class TabContents : public PageNavigator,
GearsCreateShortcutCallbackFunctor* callback_functor;
};
- // TODO(brettw) move thos to tab_contents.cc once WebContents and
- // TabContents are merged.
- class GearsCreateShortcutCallbackFunctor {
- public:
- explicit GearsCreateShortcutCallbackFunctor(TabContents* contents)
- : contents_(contents) {}
-
- void Run(const GearsShortcutData2& shortcut_data, bool success) {
- if (contents_)
- contents_->OnGearsCreateShortcutDone(shortcut_data, success);
- delete this;
- }
- void Cancel() {
- contents_ = NULL;
- }
-
- private:
- TabContents* contents_;
- };
-
-
- TabContents(Profile* profile);
+ // TODO(brettw) TestWebContents shouldn't exist!
+ friend class TestWebContents;
RenderWidgetHostView* render_widget_host_view() const {
return render_manager_.current_view();
@@ -592,6 +656,234 @@ class TabContents : public PageNavigator,
// the pending DOMUI, the committed DOMUI, or NULL.
DOMUI* GetDOMUIForCurrentState();
+ // Navigation helpers --------------------------------------------------------
+ //
+ // These functions are helpers for Navigate() and DidNavigate().
+
+ // Handles post-navigation tasks in DidNavigate AFTER the entry has been
+ // committed to the navigation controller. Note that the navigation entry is
+ // not provided since it may be invalid/changed after being committed. The
+ // current navigation entry is in the NavigationController at this point.
+ void DidNavigateMainFramePostCommit(
+ const NavigationController::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params);
+ void DidNavigateAnyFramePostCommit(
+ RenderViewHost* render_view_host,
+ const NavigationController::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params);
+
+ // Closes all child windows (constrained popups) when the domain changes.
+ // Supply the new and old URLs, and this function will figure out when the
+ // domain changing conditions are met.
+ void MaybeCloseChildWindows(const GURL& previous_url,
+ const GURL& current_url);
+
+ // Updates the starred state from the bookmark bar model. If the state has
+ // changed, the delegate is notified.
+ void UpdateStarredStateForCurrentURL();
+
+ // Send the alternate error page URL to the renderer. This method is virtual
+ // so special html pages can override this (e.g., the new tab page).
+ virtual void UpdateAlternateErrorPageURL();
+
+ // Send webkit specific settings to the renderer.
+ void UpdateWebPreferences();
+
+ // If our controller was restored and the page id is > than the site
+ // instance's page id, the site instances page id is updated as well as the
+ // renderers max page id.
+ void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
+ RenderViewHost* rvh);
+
+ // Called by OnMsgNavigate to update history state. Overridden by subclasses
+ // that don't want to be added to history.
+ virtual void UpdateHistoryForNavigation(const GURL& display_url,
+ const ViewHostMsg_FrameNavigate_Params& params);
+
+ // Saves the given title to the navigation entry and does associated work. It
+ // will update history and the view for the new title, and also synthesize
+ // titles for file URLs that have none (so we require that the URL of the
+ // entry already be set).
+ //
+ // This is used as the backend for state updates, which include a new title,
+ // or the dedicated set title message. It returns true if the new title is
+ // different and was therefore updated.
+ bool UpdateTitleForEntry(NavigationEntry* entry, const std::wstring& title);
+
+ // Misc non-view stuff -------------------------------------------------------
+
+ // Helper functions for sending notifications.
+ void NotifySwapped();
+ void NotifyConnected();
+ void NotifyDisconnected();
+
+ // If params has a searchable form, this tries to create a new keyword.
+ void GenerateKeywordIfNecessary(
+ const ViewHostMsg_FrameNavigate_Params& params);
+
+ // RenderViewHostDelegate ----------------------------------------------------
+
+ virtual RenderViewHostDelegate::View* GetViewDelegate() const;
+ virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
+ virtual Profile* GetProfile() const;
+ virtual WebContents* GetAsWebContents();
+ virtual void RenderViewCreated(RenderViewHost* render_view_host);
+ virtual void RenderViewReady(RenderViewHost* render_view_host);
+ virtual void RenderViewGone(RenderViewHost* render_view_host);
+ virtual void DidNavigate(RenderViewHost* render_view_host,
+ const ViewHostMsg_FrameNavigate_Params& params);
+ virtual void UpdateState(RenderViewHost* render_view_host,
+ int32 page_id,
+ const std::string& state);
+ virtual void UpdateTitle(RenderViewHost* render_view_host,
+ int32 page_id,
+ const std::wstring& title);
+ virtual void UpdateFeedList(RenderViewHost* render_view_host,
+ const ViewHostMsg_UpdateFeedList_Params& params);
+ virtual void UpdateEncoding(RenderViewHost* render_view_host,
+ const std::wstring& encoding);
+ virtual void UpdateTargetURL(int32 page_id, const GURL& url);
+ virtual void UpdateThumbnail(const GURL& url,
+ const SkBitmap& bitmap,
+ const ThumbnailScore& score);
+ virtual void Close(RenderViewHost* render_view_host);
+ virtual void RequestMove(const gfx::Rect& new_bounds);
+ virtual void DidStartLoading(RenderViewHost* render_view_host, int32 page_id);
+ virtual void DidStopLoading(RenderViewHost* render_view_host, int32 page_id);
+ virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host,
+ bool is_main_frame,
+ const GURL& url);
+ virtual void DidRedirectProvisionalLoad(int32 page_id,
+ const GURL& source_url,
+ const GURL& target_url);
+ virtual void DidLoadResourceFromMemoryCache(
+ const GURL& url,
+ const std::string& frame_origin,
+ const std::string& main_frame_origin,
+ const std::string& security_info);
+ virtual void DidFailProvisionalLoadWithError(
+ RenderViewHost* render_view_host,
+ bool is_main_frame,
+ int error_code,
+ const GURL& url,
+ bool showing_repost_interstitial);
+ virtual void UpdateFavIconURL(RenderViewHost* render_view_host,
+ int32 page_id, const GURL& icon_url);
+ virtual void DidDownloadImage(RenderViewHost* render_view_host,
+ int id,
+ const GURL& image_url,
+ bool errored,
+ const SkBitmap& image);
+ virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
+ WindowOpenDisposition disposition);
+ virtual void DomOperationResponse(const std::string& json_string,
+ int automation_id);
+ virtual void ProcessDOMUIMessage(const std::string& message,
+ const std::string& content);
+ virtual void ProcessExternalHostMessage(const std::string& message,
+ const std::string& origin,
+ const std::string& target);
+ virtual void GoToEntryAtOffset(int offset);
+ virtual void GetHistoryListCount(int* back_list_count,
+ int* forward_list_count);
+ virtual void RunFileChooser(bool multiple_files,
+ const string16& title,
+ const FilePath& default_file);
+ virtual void RunJavaScriptMessage(const std::wstring& message,
+ const std::wstring& default_prompt,
+ const GURL& frame_url,
+ const int flags,
+ IPC::Message* reply_msg,
+ bool* did_suppress_message);
+ virtual void RunBeforeUnloadConfirm(const std::wstring& message,
+ IPC::Message* reply_msg);
+ virtual void ShowModalHTMLDialog(const GURL& url, int width, int height,
+ const std::string& json_arguments,
+ IPC::Message* reply_msg);
+ virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms);
+ virtual void AutofillFormSubmitted(const AutofillForm& form);
+ virtual void GetAutofillSuggestions(const std::wstring& field_name,
+ const std::wstring& user_text, int64 node_id, int request_id);
+ virtual void RemoveAutofillEntry(const std::wstring& field_name,
+ const std::wstring& value);
+ virtual void PageHasOSDD(RenderViewHost* render_view_host,
+ int32 page_id, const GURL& url, bool autodetected);
+ virtual void InspectElementReply(int num_resources);
+ virtual void DidGetPrintedPagesCount(int cookie, int number_pages);
+ virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params);
+ virtual GURL GetAlternateErrorPageURL() const;
+ virtual WebPreferences GetWebkitPrefs();
+ virtual void OnMissingPluginStatus(int status);
+ virtual void OnCrashedPlugin(const FilePath& plugin_path);
+ virtual void OnCrashedWorker();
+ virtual void OnJSOutOfMemory();
+ virtual void ShouldClosePage(bool proceed);
+ void OnCrossSiteResponse(int new_render_process_host_id,
+ int new_request_id);
+ virtual bool CanBlur() const;
+ virtual gfx::Rect GetRootWindowResizerRect() const;
+ virtual void RendererUnresponsive(RenderViewHost* render_view_host,
+ bool is_during_unload);
+ virtual void RendererResponsive(RenderViewHost* render_view_host);
+ virtual void LoadStateChanged(const GURL& url, net::LoadState load_state);
+ virtual void OnDidGetApplicationInfo(
+ int32 page_id,
+ const webkit_glue::WebApplicationInfo& info);
+ virtual void OnEnterOrSpace();
+ virtual void OnFindReply(int request_id,
+ int number_of_matches,
+ const gfx::Rect& selection_rect,
+ int active_match_ordinal,
+ bool final_update);
+ virtual bool CanTerminate() const;
+
+ // SelectFileDialog::Listener ------------------------------------------------
+
+ virtual void FileSelected(const FilePath& path, int index, void* params);
+ virtual void MultiFilesSelected(const std::vector<FilePath>& files,
+ void* params);
+ virtual void FileSelectionCanceled(void* params);
+
+ // RenderViewHostManager::Delegate -------------------------------------------
+
+ virtual void BeforeUnloadFiredFromRenderManager(
+ bool proceed,
+ bool* proceed_to_fire_unload);
+ virtual void DidStartLoadingFromRenderManager(
+ RenderViewHost* render_view_host, int32 page_id) {
+ DidStartLoading(render_view_host, page_id);
+ }
+ virtual void RenderViewGoneFromRenderManager(
+ RenderViewHost* render_view_host) {
+ RenderViewGone(render_view_host);
+ }
+ virtual void UpdateRenderViewSizeForRenderManager();
+ virtual void NotifySwappedFromRenderManager() {
+ NotifySwapped();
+ }
+ virtual NavigationController& GetControllerForRenderManager() {
+ return controller();
+ }
+ virtual DOMUI* CreateDOMUIForRenderManager(const GURL& url);
+ virtual NavigationEntry* GetLastCommittedNavigationEntryForRenderManager();
+
+ // Initializes the given renderer if necessary and creates the view ID
+ // corresponding to this view host. If this method is not called and the
+ // process is not shared, then the WebContents will act as though the renderer
+ // is not running (i.e., it will render "sad tab"). This method is
+ // automatically called from LoadURL.
+ //
+ // If you are attaching to an already-existing RenderView, you should call
+ // InitWithExistingID.
+ virtual bool CreateRenderViewForRenderManager(
+ RenderViewHost* render_view_host);
+
+ // NotificationObserver ------------------------------------------------------
+
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Data for core operation ---------------------------------------------------
// Delegate for notifying our owner about stuff. Not owned by us.