Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4069)

Unified Diff: chrome/browser/web_contents.h

Issue 5005: Reorganize the declarations to have some grouping and logical ordering in tab... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.cc ('k') | chrome/browser/web_contents.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_contents.h
===================================================================
--- chrome/browser/web_contents.h (revision 2626)
+++ chrome/browser/web_contents.h (working copy)
@@ -28,11 +28,14 @@
struct WebDropData;
class WebDropTarget;
+// WebContents represents the contents of a tab that shows web pages. It embeds
+// a RenderViewHost (via RenderViewHostManager) to actually display the page.
class WebContents : public TabContents,
public RenderViewHostDelegate,
public RenderViewHostManager::Delegate,
public ChromeViews::HWNDViewContainer,
public SelectFileDialog::Listener,
+ public NotificationObserver,
public WebApp::Observer {
public:
// If instance is NULL, then creates a new process for this view. Otherwise
@@ -48,83 +51,79 @@
static void RegisterUserPrefs(PrefService* prefs);
- virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds);
- virtual HWND GetContainerHWND() const { return GetHWND(); }
- virtual void GetContainerBounds(gfx::Rect *out) const;
- virtual void ShowContents();
- virtual void HideContents();
- virtual void SizeContents(const gfx::Size& size);
+ // Getters -------------------------------------------------------------------
- // TabContents
- virtual WebContents* AsWebContents() { return this; }
- virtual SiteInstance* GetSiteInstance() const {
- return render_manager_.current_host()->site_instance();
+ // Returns the PasswordManager, creating it if necessary.
+ PasswordManager* GetPasswordManager();
+
+ // Returns the PluginInstaller, creating it if necessary.
+ PluginInstaller* GetPluginInstaller();
+
+ // Returns the SavePackage which manages the page saving job. May be NULL.
+ SavePackage* save_package() const { return save_package_.get(); }
+
+ // Return the currently active RenderProcessHost, RenderViewHost, and
+ // SiteInstance, respectively. Each of these may change over time. Callers
+ // should be aware that the SiteInstance could be deleted if its ref count
+ // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that
+ // use it are deleted).
+ RenderProcessHost* process() const {
+ return render_manager_.current_host()->process();
}
- virtual bool NavigateToPendingEntry(bool reload);
- virtual void Stop();
- virtual void DidBecomeSelected();
- virtual void WasHidden();
+ RenderViewHost* render_view_host() const {
+ return render_manager_.current_host();
+ }
+ RenderWidgetHostView* view() const {
+ return render_manager_.current_view();
+ }
+
+ bool is_starred() const { return is_starred_; }
+
+ // TabContents (public overrides) --------------------------------------------
+
virtual void Destroy();
+ virtual WebContents* AsWebContents() { return this; }
+ virtual SiteInstance* GetSiteInstance() const;
virtual SkBitmap GetFavIcon();
virtual std::wstring GetStatusText() const;
-
- // Find functions
+ virtual bool NavigateToPendingEntry(bool reload);
+ virtual void Stop();
virtual void StartFinding(int request_id,
const std::wstring& search_string,
bool forward,
bool match_case,
bool find_next);
virtual void StopFinding(bool clear_selection);
- virtual void OpenFindInPageWindow(const Browser& browser);
- virtual void ReparentFindWindow(HWND new_parent);
- virtual bool AdvanceFindSelection(bool forward_direction);
- virtual bool IsFindWindowFullyVisible();
- virtual bool GetFindInPageWindowLocation(int* x, int* y);
-
- bool is_starred() const { return is_starred_; }
-
- // 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;
- }
-
- // Various other systems need to know about our interstitials.
- bool showing_interstitial_page() const {
- return render_manager_.showing_interstitial_page();
- }
- bool showing_repost_interstitial() const {
- return render_manager_.showing_repost_interstitial();
- }
-
- // Overridden from TabContents to remember at what time the download bar was
- // shown.
- void SetDownloadShelfVisible(bool visible);
-
- // Returns the SavePackage which manages the page saving job. May be NULL.
- SavePackage* save_package() const { return save_package_.get(); }
-
- // Whether or not the info bar is visible. This delegates to
- // the ChromeFrame method InfoBarVisibilityChanged.
- void SetInfoBarVisible(bool visible);
- virtual bool IsInfoBarVisible() { return info_bar_visible_; }
-
- // Whether or not the FindInPage bar is visible.
- void SetFindInPageVisible(bool visible);
-
+ virtual void Cut();
+ virtual void Copy();
+ virtual void Paste();
+ virtual void DidBecomeSelected();
+ virtual void WasHidden();
+ virtual void ShowContents();
+ virtual void HideContents();
+ virtual void SizeContents(const gfx::Size& size);
+ virtual HWND GetContentHWND();
+ virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds);
+ virtual HWND GetContainerHWND() const { return GetHWND(); }
+ virtual void GetContainerBounds(gfx::Rect *out) const;
// Create the InfoBarView and returns it if none has been created.
// Just returns existing InfoBarView if it is already created.
virtual InfoBarView* GetInfoBarView();
+ virtual bool IsInfoBarVisible() { return info_bar_visible_; }
+ virtual void SetDownloadShelfVisible(bool visible);
- // Prepare for saving page.
- void OnSavePage();
+ // Find in page --------------------------------------------------------------
- // 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);
+ // TODO(brettw) these should be commented.
+ void OpenFindInPageWindow(const Browser& browser);
+ void ReparentFindWindow(HWND new_parent);
+ bool AdvanceFindSelection(bool forward_direction);
+ bool IsFindWindowFullyVisible();
+ bool GetFindInPageWindowLocation(int* x, int* y);
+ void SetFindInPageVisible(bool visible);
+ // Web apps ------------------------------------------------------------------
+
// Sets the WebApp for this WebContents.
void SetWebApp(WebApp* web_app);
WebApp* web_app() { return web_app_.get(); }
@@ -135,57 +134,16 @@
// Tell Gears to create a shortcut for the current page.
void CreateShortcut();
- // JavascriptMessageBoxHandler calls this when the dialog is closed.
- void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success,
- const std::wstring& prompt);
+ // Interstitials -------------------------------------------------------------
- // Returns the PasswordManager, creating it if necessary.
- PasswordManager* GetPasswordManager();
-
- // Returns the PluginInstaller, creating it if necessary.
- PluginInstaller* GetPluginInstaller();
-
- // Return the currently active RenderProcessHost, RenderViewHost, and
- // SiteInstance, respectively. Each of these may change over time. Callers
- // should be aware that the SiteInstance could be deleted if its ref count
- // drops to zero (i.e., if all RenderViewHosts and NavigationEntries that
- // use it are deleted).
- RenderProcessHost* process() const {
- return render_manager_.current_host()->process();
+ // Various other systems need to know about our interstitials.
+ bool showing_interstitial_page() const {
+ return render_manager_.showing_interstitial_page();
}
- RenderViewHost* render_view_host() const {
- return render_manager_.current_host();
+ bool showing_repost_interstitial() const {
+ return render_manager_.showing_repost_interstitial();
}
- RenderWidgetHostView* view() const {
- return render_manager_.current_view();
- }
- // Overridden from TabContents to return the window of the
- // RenderWidgetHostView.
- virtual HWND GetContentHWND();
-
- // Handling the drag and drop of files into the content area.
- virtual bool CanDisplayFile(const std::wstring& full_path);
-
- // 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();
-
- virtual void WillCaptureContents();
- virtual void DidCaptureContents();
-
- virtual void Cut();
- virtual void Copy();
- virtual void Paste();
-
// The rest of the system wants to interact with the delegate our render view
// host manager has. See those setters for more.
InterstitialPageDelegate* interstitial_page_delegate() const {
@@ -215,15 +173,45 @@
render_manager_.HideInterstitialPage(wait_for_navigation, proceed);
}
- // Allows the WebContents to react when a cross-site response is ready to be
- // delivered to a pending RenderViewHost. We must first run the onunload
- // handler of the old RenderViewHost before we can allow it to proceed.
- void OnCrossSiteResponse(int new_render_process_host_id,
- int new_request_id) {
- render_manager_.OnCrossSiteResponse(new_render_process_host_id,
- new_request_id);
+ // 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;
}
+ // JavascriptMessageBoxHandler calls this when the dialog is closed.
+ void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
+ bool success,
+ const std::wstring& prompt);
+
+ // Whether or not the info bar is visible. This delegates to
+ // the ChromeFrame method InfoBarVisibilityChanged. See also IsInfoBarVisible
+ // (a TabContents override).
+ void SetInfoBarVisible(bool visible);
+
+ // Prepare for saving page.
+ 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);
@@ -235,17 +223,19 @@
bool notify_disconnection() const { return notify_disconnection_; }
protected:
- FRIEND_TEST(WebContentsTest, UpdateTitle);
-
// Should be deleted via CloseContents.
virtual ~WebContents();
- // RenderViewHostDelegate
+ // TabContents (private overrides) -------------------------------------------
+
+ virtual void SetInitialFocus(bool reverse);
+ virtual void SetIsLoading(bool is_loading, LoadNotificationDetails* details);
+
+ // RenderViewHostDelegate ----------------------------------------------------
+
virtual RenderViewHostDelegate::FindInPage* GetFindInPageDelegate() const;
virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
-
virtual Profile* GetProfile() const;
-
virtual void CreateView(int route_id, HANDLE modal_dialog_event);
virtual void CreateWidget(int route_id);
virtual void ShowView(int route_id,
@@ -257,7 +247,6 @@
virtual void RendererGone(RenderViewHost* render_view_host);
virtual void DidNavigate(RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params);
- virtual void UpdateRenderViewSize();
virtual void UpdateState(RenderViewHost* render_view_host,
int32 page_id,
const GURL& url,
@@ -321,8 +310,12 @@
IPC::Message* reply_msg);
virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms);
virtual void TakeFocus(bool reverse);
+ 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 void HandleKeyboardEvent(const WebKeyboardEvent& event);
virtual GURL GetAlternateErrorPageURL() const;
virtual WebPreferences GetWebkitPrefs();
virtual void OnMissingPluginStatus(int status);
@@ -331,41 +324,47 @@
virtual void ShouldClosePage(bool proceed) {
render_manager_.ShouldClosePage(proceed);
}
+ // Allows the WebContents to react when a cross-site response is ready to be
+ // delivered to a pending RenderViewHost. We must first run the onunload
+ // handler of the old RenderViewHost before we can allow it to proceed.
+ void OnCrossSiteResponse(int new_render_process_host_id,
+ int new_request_id) {
+ render_manager_.OnCrossSiteResponse(new_render_process_host_id,
+ new_request_id);
+ }
virtual bool CanBlur() const;
virtual void RendererUnresponsive(RenderViewHost* render_view_host);
virtual void RendererResponsive(RenderViewHost* render_view_host);
virtual void LoadStateChanged(const GURL& url, net::LoadState load_state);
-
- // Notification that a page has an OpenSearch description document available
- // at url. This checks to see if we should generate a keyword based on the
- // OSDD, and if necessary uses TemplateURLFetcher to download the OSDD
- // and create a keyword.
- virtual void PageHasOSDD(RenderViewHost* render_view_host,
- int32 page_id, const GURL& url, bool autodetected);
-
virtual void OnDidGetApplicationInfo(
int32 page_id,
const webkit_glue::WebApplicationInfo& info);
- // Overridden from TabContents.
- virtual void SetInitialFocus(bool reverse);
+ // SelectFileDialog::Listener ------------------------------------------------
- // Handle reply from inspect element request
- virtual void InspectElementReply(int num_resources);
-
- // Handle keyboard events not processed by the renderer.
- virtual void HandleKeyboardEvent(const WebKeyboardEvent& event);
-
- // Notifies the RenderWidgetHost instance about the fact that the
- // page is loading, or done loading and calls the base implementation.
- void SetIsLoading(bool is_loading, LoadNotificationDetails* details);
-
- // Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const std::wstring& path, void* params);
virtual void FileSelectionCanceled(void* params);
- // Another part of RenderViewHostManager::Delegate.
- //
+ // 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 RendererGoneFromRenderManager(RenderViewHost* render_view_host) {
+ RendererGone(render_view_host);
+ }
+ virtual void UpdateRenderViewSizeForRenderManager();
+ virtual void NotifySwappedFromRenderManager() {
+ NotifySwapped();
+ }
+ virtual NavigationController* GetControllerForRenderManager() {
+ return controller();
+ }
+
// 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
@@ -382,6 +381,7 @@
RenderViewHost* render_view_host);
private:
+ FRIEND_TEST(WebContentsTest, UpdateTitle);
friend class TestWebContents;
// When CreateShortcut is invoked RenderViewHost::GetApplicationInfo is
@@ -400,17 +400,14 @@
GearsCreateShortcutCallbackFunctor* callback_functor;
};
- void ScrollCommon(UINT message, int scroll_type, short position,
- HWND scrollbar);
- bool ScrollZoom(int scroll_type);
- void WheelZoom(int distance);
+ // NotificationObserver ------------------------------------------------------
- // Backend for LoadURL that optionally creates a history entry. The
- // transition type will be ignored if a history entry is not created.
- void LoadURL(const std::wstring& url, bool create_history_entry,
- PageTransition::Type transition);
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
- // Windows Event handlers
+ // Windows events ------------------------------------------------------------
+
virtual void OnDestroy();
virtual void OnHScroll(int scroll_type, short position, HWND scrollbar);
virtual void OnMouseLeave();
@@ -424,34 +421,15 @@
virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param);
virtual void OnNCPaint(HRGN rgn);
- // Callback from HistoryService for our request for a favicon.
- void OnFavIconData(HistoryService::Handle handle,
- bool know_favicon,
- scoped_refptr<RefCountedBytes> data,
- bool expired);
+ // Backend for all scroll messages, the |message| parameter indicates which
+ // one it is.
+ void ScrollCommon(UINT message, int scroll_type, short position,
+ HWND scrollbar);
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
+ // TODO(brettw) comment these. They're confusing.
+ bool ScrollZoom(int scroll_type);
+ void WheelZoom(int distance);
- // Helper functions for sending notifications.
- void NotifySwapped();
- void NotifyConnected();
- void NotifyDisconnected();
-
- // Called by OnMsgNavigate to update history state.
- virtual void UpdateHistoryForNavigation(const GURL& display_url,
- const ViewHostMsg_FrameNavigate_Params& params);
-
- // If params has a searchable form, this tries to create a new keyword.
- void GenerateKeywordIfNecessary(
- const ViewHostMsg_FrameNavigate_Params& params);
-
- // Sets up the View that holds the rendered web page, receives messages for
- // it and contains page plugins.
- RenderWidgetHostHWND* CreatePageView(RenderViewHost* render_view_host);
-
// Navigation helpers --------------------------------------------------------
//
// These functions are helpers for Navigate() and DidNavigate().
@@ -505,35 +483,33 @@
void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
RenderViewHost* rvh);
- // RenderViewHostManager::Delegate pass-throughs -----------------------------
+ // 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);
- 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 RendererGoneFromRenderManager(RenderViewHost* render_view_host) {
- RendererGone(render_view_host);
- }
- virtual void UpdateRenderViewSizeForRenderManager() {
- UpdateRenderViewSize();
- }
- virtual void NotifySwappedFromRenderManager() {
- NotifySwapped();
- }
- virtual NavigationController* GetControllerForRenderManager() {
- return controller();
- }
+ // Misc view stuff -----------------------------------------------------------
- // ---------------------------------------------------------------------------
+ // Sets up the View that holds the rendered web page, receives messages for
+ // it and contains page plugins.
+ RenderWidgetHostHWND* CreatePageView(RenderViewHost* render_view_host);
// Enumerate and 'un-parent' any plugin windows that are children
// of this web contents.
void DetachPluginWindows();
static BOOL CALLBACK EnumPluginWindowsCallback(HWND window, LPARAM param);
+ // 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);
+
// Data ----------------------------------------------------------------------
// Manages creation and swapping of render views.
@@ -603,9 +579,6 @@
// The SadTab renderer.
scoped_ptr<SadTabView> sad_tab_;
- // This flag is true while we are in the photo-booth. See dragged_tab.cc.
- bool capturing_contents_;
-
// Handles downloading favicons.
FavIconHelper fav_icon_helper_;
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.cc ('k') | chrome/browser/web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698