diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-23 22:55:01 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-23 22:55:01 +0000 |
commit | 6e95706dcc9a205e78b1d4820427754d16a50465 (patch) | |
tree | 6bca69c386a5199bc88f59f0f92afc6dd6734fc3 /chrome | |
parent | 1ffdb40816d6a92cbcb7eb6c2386232c561abc56 (diff) | |
download | chromium_src-6e95706dcc9a205e78b1d4820427754d16a50465.zip chromium_src-6e95706dcc9a205e78b1d4820427754d16a50465.tar.gz chromium_src-6e95706dcc9a205e78b1d4820427754d16a50465.tar.bz2 |
Move a bunch of functions from WebContents to TabContents. Change the services
used by the getters I moved to take a TabContents instead of a WebContents.
Review URL: http://codereview.chromium.org/96010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autofill_manager.cc | 10 | ||||
-rw-r--r-- | chrome/browser/autofill_manager.h | 6 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_manager.cc | 36 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_manager.h | 8 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.cc | 16 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.h | 8 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 59 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 133 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents.cc | 58 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents.h | 143 |
10 files changed, 230 insertions, 247 deletions
diff --git a/chrome/browser/autofill_manager.cc b/chrome/browser/autofill_manager.cc index 5cf318f..441d708 100644 --- a/chrome/browser/autofill_manager.cc +++ b/chrome/browser/autofill_manager.cc @@ -6,7 +6,7 @@ #include "base/string_util.h" #include "chrome/browser/profile.h" -#include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "webkit/glue/autofill_form.h" @@ -16,8 +16,8 @@ void AutofillManager::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kFormAutofillEnabled, true); } -AutofillManager::AutofillManager(WebContents* web_contents) - : web_contents_(web_contents), +AutofillManager::AutofillManager(TabContents* tab_contents) + : tab_contents_(tab_contents), pending_query_handle_(0), node_id_(0), request_id_(0) { @@ -43,7 +43,7 @@ void AutofillManager::CancelPendingQuery() { } Profile* AutofillManager::profile() { - return web_contents_->profile(); + return tab_contents_->profile(); } void AutofillManager::AutofillFormSubmitted(const AutofillForm& form) { @@ -100,7 +100,7 @@ void AutofillManager::OnWebDataServiceRequestDone(WebDataService::Handle h, switch (result->GetType()) { case AUTOFILL_VALUE_RESULT: { - RenderViewHost* host = web_contents_->render_view_host(); + RenderViewHost* host = tab_contents_->render_view_host(); if (!host) return; const WDResult<std::vector<std::wstring> >* r = diff --git a/chrome/browser/autofill_manager.h b/chrome/browser/autofill_manager.h index bac2167..f251954 100644 --- a/chrome/browser/autofill_manager.h +++ b/chrome/browser/autofill_manager.h @@ -13,13 +13,13 @@ class AutofillForm; class Profile; -class WebContents; +class TabContents; // Per-tab autofill manager. Handles receiving form data from the renderer and // the storing and retrieving of form data through WebDataService. class AutofillManager : public WebDataServiceConsumer { public: - explicit AutofillManager(WebContents* web_contents); + explicit AutofillManager(TabContents* tab_contents); virtual ~AutofillManager(); void CancelPendingQuery(); @@ -50,7 +50,7 @@ class AutofillManager : public WebDataServiceConsumer { private: void StoreFormEntriesInWebDatabase(const AutofillForm& form); - WebContents* web_contents_; + TabContents* tab_contents_; BooleanPrefMember form_autofill_enabled_; diff --git a/chrome/browser/password_manager/password_manager.cc b/chrome/browser/password_manager/password_manager.cc index 2144806..1e7339d 100644 --- a/chrome/browser/password_manager/password_manager.cc +++ b/chrome/browser/password_manager/password_manager.cc @@ -6,7 +6,7 @@ #include "base/string_util.h" #include "chrome/browser/profile.h" -#include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" @@ -86,20 +86,20 @@ void PasswordManager::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kPasswordManagerEnabled, true); } -PasswordManager::PasswordManager(WebContents* web_contents) +PasswordManager::PasswordManager(TabContents* tab_contents) : login_managers_deleter_(&pending_login_managers_), - web_contents_(web_contents), + tab_contents_(tab_contents), observer_(NULL) { password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, - web_contents->profile()->GetPrefs(), NULL); + tab_contents->profile()->GetPrefs(), NULL); } PasswordManager::~PasswordManager() { } void PasswordManager::ProvisionallySavePassword(PasswordForm form) { - if (!web_contents_->profile() || - web_contents_->profile()->IsOffTheRecord() || + if (!tab_contents_->profile() || + tab_contents_->profile()->IsOffTheRecord() || !*password_manager_enabled_) return; @@ -135,7 +135,7 @@ void PasswordManager::ProvisionallySavePassword(PasswordForm form) { return; form.ssl_valid = form.origin.SchemeIsSecure() && - !web_contents_->controller().ssl_manager()-> + !tab_contents_->controller().ssl_manager()-> ProcessedSSLErrorFromRequest(); form.preferred = true; manager->ProvisionallySave(form); @@ -161,15 +161,15 @@ void PasswordManager::DidStopLoading() { if (!provisional_save_manager_.get()) return; - DCHECK(!web_contents_->profile()->IsOffTheRecord()); + DCHECK(!tab_contents_->profile()->IsOffTheRecord()); DCHECK(!provisional_save_manager_->IsBlacklisted()); - if (!web_contents_->profile() || - !web_contents_->profile()->GetWebDataService(Profile::IMPLICIT_ACCESS)) + if (!tab_contents_->profile() || + !tab_contents_->profile()->GetWebDataService(Profile::IMPLICIT_ACCESS)) return; if (provisional_save_manager_->IsNewLogin()) { - web_contents_->AddInfoBar( - new SavePasswordInfoBarDelegate(web_contents_, + tab_contents_->AddInfoBar( + new SavePasswordInfoBarDelegate(tab_contents_, provisional_save_manager_.release())); } else { // If the save is not a new username entry, then we just want to save this @@ -181,14 +181,14 @@ void PasswordManager::DidStopLoading() { void PasswordManager::PasswordFormsSeen( const std::vector<PasswordForm>& forms) { - if (!web_contents_->profile() || - !web_contents_->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS)) + if (!tab_contents_->profile() || + !tab_contents_->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS)) return; if (!*password_manager_enabled_) return; // Ask the SSLManager for current security. - bool had_ssl_error = web_contents_->controller().ssl_manager()-> + bool had_ssl_error = tab_contents_->controller().ssl_manager()-> ProcessedSSLErrorFromRequest(); std::vector<PasswordForm>::const_iterator iter; @@ -205,7 +205,7 @@ void PasswordManager::PasswordFormsSeen( } else { bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error; PasswordFormManager* manager = - new PasswordFormManager(web_contents_->profile(), + new PasswordFormManager(tab_contents_->profile(), this, *iter, ssl_valid); pending_login_managers_.push_back(manager); manager->FetchMatchingLoginsFromWebDatabase(); @@ -217,7 +217,7 @@ void PasswordManager::Autofill( const PasswordForm& form_for_autofill, const PasswordFormMap& best_matches, const PasswordForm* const preferred_match) const { - DCHECK(web_contents_); + DCHECK(tab_contents_); DCHECK(preferred_match); switch (form_for_autofill.scheme) { case PasswordForm::SCHEME_HTML: { @@ -230,7 +230,7 @@ void PasswordManager::Autofill( best_matches, preferred_match, action_mismatch, &fill_data); - web_contents_->render_view_host()->FillPasswordForm(fill_data); + tab_contents_->render_view_host()->FillPasswordForm(fill_data); return; } default: diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h index 392cad0..cfe5443 100644 --- a/chrome/browser/password_manager/password_manager.h +++ b/chrome/browser/password_manager/password_manager.h @@ -15,7 +15,7 @@ #include "webkit/glue/password_form_dom_manager.h" class PrefService; -class WebContents; +class TabContents; // Per-tab password manager. Handles creation and management of UI elements, // receiving password form data from the renderer and managing the password @@ -25,7 +25,7 @@ class PasswordManager : public views::LoginModel { public: static void RegisterUserPrefs(PrefService* prefs); - explicit PasswordManager(WebContents* web_contents); + explicit PasswordManager(TabContents* tab_contents); ~PasswordManager(); // Called by a PasswordFormManager when it decides a form can be autofilled @@ -88,8 +88,8 @@ class PasswordManager : public views::LoginModel { // time a user submits a login form and gets to the next page. scoped_ptr<PasswordFormManager> provisional_save_manager_; - // The containing WebContents - WebContents* web_contents_; + // The containing TabContents. + TabContents* tab_contents_; // The LoginModelObserver (i.e LoginView) requiring autofill. views::LoginModelObserver* observer_; diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc index 9f2938c..e8ba426 100644 --- a/chrome/browser/plugin_installer.cc +++ b/chrome/browser/plugin_installer.cc @@ -5,33 +5,33 @@ #include "chrome/browser/plugin_installer.h" #include "base/string_util.h" -#include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "webkit/default_plugin/default_plugin_shared.h" -PluginInstaller::PluginInstaller(WebContents* web_contents) - : ConfirmInfoBarDelegate(web_contents), - web_contents_(web_contents) { +PluginInstaller::PluginInstaller(TabContents* tab_contents) + : ConfirmInfoBarDelegate(tab_contents), + tab_contents_(tab_contents) { } PluginInstaller::~PluginInstaller() { // Remove any InfoBars we may be showing. - web_contents_->RemoveInfoBar(this); + tab_contents_->RemoveInfoBar(this); } void PluginInstaller::OnMissingPluginStatus(int status) { switch(status) { case default_plugin::MISSING_PLUGIN_AVAILABLE: { - web_contents_->AddInfoBar(this); + tab_contents_->AddInfoBar(this); break; } case default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { // Hide the InfoBar if user already started download/install of the // missing plugin. - web_contents_->RemoveInfoBar(this); + tab_contents_->RemoveInfoBar(this); break; } default: { @@ -61,6 +61,6 @@ std::wstring PluginInstaller::GetButtonLabel(InfoBarButton button) const { } bool PluginInstaller::Accept() { - web_contents_->render_view_host()->InstallMissingPlugin(); + tab_contents_->render_view_host()->InstallMissingPlugin(); return true; } diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer.h index 642e643..8760c4f 100644 --- a/chrome/browser/plugin_installer.h +++ b/chrome/browser/plugin_installer.h @@ -7,13 +7,13 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" -class WebContents; +class TabContents; // The main purpose for this class is to popup/close the infobar when there is // a missing plugin. class PluginInstaller : public ConfirmInfoBarDelegate { public: - explicit PluginInstaller(WebContents* web_contents); + explicit PluginInstaller(TabContents* tab_contents); ~PluginInstaller(); void OnMissingPluginStatus(int status); @@ -28,8 +28,8 @@ class PluginInstaller : public ConfirmInfoBarDelegate { virtual std::wstring GetButtonLabel(InfoBarButton button) const; virtual bool Accept(); - // The containing WebContents - WebContents* web_contents_; + // The containing TabContents + TabContents* tab_contents_; DISALLOW_COPY_AND_ASSIGN(PluginInstaller); }; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 252e2b2..fcf7bdd 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -95,9 +95,28 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) { } bool TabContents::SupportsURL(GURL* url) { + // TODO(brettw) remove this function. return true; } +AutofillManager* TabContents::GetAutofillManager() { + if (autofill_manager_.get() == NULL) + autofill_manager_.reset(new AutofillManager(this)); + return autofill_manager_.get(); +} + +PasswordManager* TabContents::GetPasswordManager() { + if (password_manager_.get() == NULL) + password_manager_.reset(new PasswordManager(this)); + return password_manager_.get(); +} + +PluginInstaller* TabContents::GetPluginInstaller() { + if (plugin_installer_.get() == NULL) + plugin_installer_.reset(new PluginInstaller(this)); + return plugin_installer_.get(); +} + const GURL& TabContents::GetURL() const { // We may not have a navigation entry yet NavigationEntry* entry = controller_.GetActiveEntry(); @@ -400,6 +419,46 @@ void TabContents::DidMoveOrResize(ConstrainedWindow* window) { #endif } +void TabContents::StartFinding(const string16& find_text, + bool forward_direction) { + // If find_text is empty, it means FindNext was pressed with a keyboard + // shortcut so unless we have something to search for we return early. + if (find_text.empty() && find_text_.empty()) + return; + + // This is a FindNext operation if we are searching for the same text again, + // or if the passed in search text is empty (FindNext keyboard shortcut). The + // exception to this is if the Find was aborted (then we don't want FindNext + // because the highlighting has been cleared and we need it to reappear). We + // therefore treat FindNext after an aborted Find operation as a full fledged + // Find. + bool find_next = (find_text_ == find_text || find_text.empty()) && + !find_op_aborted_; + if (!find_next) + current_find_request_id_ = find_request_id_counter_++; + + if (!find_text.empty()) + find_text_ = find_text; + + find_op_aborted_ = false; + + // Keep track of what the last search was across the tabs. + *find_prepopulate_text_ = find_text; + + render_view_host()->StartFinding(current_find_request_id_, + find_text_, + forward_direction, + false, // case sensitive + find_next); +} + +void TabContents::StopFinding(bool clear_selection) { + find_ui_active_ = false; + find_op_aborted_ = true; + find_result_ = FindNotificationDetails(); + render_view_host()->StopFinding(clear_selection); +} + #if defined(OS_WIN) // TODO(brettw) This should be on the TabContentsView. void TabContents::RepositionSupressedPopupsToFit(const gfx::Size& new_size) { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index a7d5833..8fe5529 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -7,6 +7,7 @@ #include "build/build_config.h" +#include <map> #include <string> #include <vector> @@ -34,7 +35,6 @@ #include "webkit/glue/password_form.h" #include "webkit/glue/webpreferences.h" - #if defined(OS_MACOSX) || defined(OS_LINUX) // Remove when we've finished porting the supporting classes. #include "chrome/common/temp_scaffolding_stubs.h" @@ -47,31 +47,47 @@ class Rect; class Size; } namespace views { -class RootView; class WindowDelegate; } +namespace base { +class WaitableEvent; +} +namespace webkit_glue { +struct WebApplicationInfo; +} +namespace IPC { +class Message; +} +class AutofillForm; class AutofillManager; class BlockedPopupContainer; +class DOMUI; class DOMUIContents; class DownloadItem; class DownloadShelf; -class InfoBarView; class LoadNotificationDetails; class PasswordManager; class PluginInstaller; class Profile; +class RenderViewHost; class TabContentsDelegate; class TabContentsFactory; class SkBitmap; class SiteInstance; class TabContentsView; +struct ThumbnailScore; +struct ViewHostMsg_FrameNavigate_Params; +struct ViewHostMsg_DidPrintPage_Params; class WebContents; // Describes what goes in the main content area of a tab. WebContents is // the only type of TabContents, and these should be merged together. class TabContents : public PageNavigator, - public NotificationObserver { + public NotificationObserver, + public RenderViewHostDelegate, + public RenderViewHostManager::Delegate, + public SelectFileDialog::Listener { public: // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it // what has changed. Combine them to update more than one thing. @@ -99,7 +115,7 @@ 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() { return NULL; } + virtual WebContents* AsWebContents() = 0; // Const version of above for situations where const TabContents*'s are used. WebContents* AsWebContents() const { @@ -125,6 +141,37 @@ class TabContents : public PageNavigator, // to the actual URL that will be used. It can be modified as needed. bool SupportsURL(GURL* url); + // Returns the AutofillManager, creating it if necessary. + AutofillManager* GetAutofillManager(); + + // 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 and RenderViewHost. Each of + // these may change over time. + RenderProcessHost* process() const { + return render_manager_.current_host()->process(); + } + RenderViewHost* render_view_host() const { + return render_manager_.current_host(); + } + + // The TabContentsView will never change and is guaranteed non-NULL. + TabContentsView* view() const { + return view_.get(); + } + +#ifdef UNIT_TEST + // Expose the render manager for testing. + RenderViewHostManager* render_manager() { return &render_manager_; } +#endif + // Tab navigation state ------------------------------------------------------ // Returns the current navigation properties, which if a navigation is @@ -185,6 +232,13 @@ class TabContents : public PageNavigator, // "waiting" or "loading." bool waiting_for_response() const { return waiting_for_response_; } + bool is_starred() const { return is_starred_; } + + const std::wstring& encoding() const { return encoding_; } + void set_encoding(const std::wstring& encoding) { + encoding_ = encoding; + } + // Internal state ------------------------------------------------------------ // This flag indicates whether the tab contents is currently being @@ -366,6 +420,75 @@ class TabContents : public PageNavigator, // Called when a ConstrainedWindow we own is moved or resized. void DidMoveOrResize(ConstrainedWindow* window); + // Interstitials ------------------------------------------------------------- + + // Various other systems need to know about our interstitials. + bool showing_interstitial_page() const { + return render_manager_.interstitial_page() != NULL; + } + + // Sets the passed passed interstitial as the currently showing interstitial. + // |interstitial_page| should be non NULL (use the remove_interstitial_page + // method to unset the interstitial) and no interstitial page should be set + // when there is already a non NULL interstitial page set. + void set_interstitial_page(InterstitialPage* interstitial_page) { + render_manager_.set_interstitial_page(interstitial_page); + } + + // Unsets the currently showing interstitial. + void remove_interstitial_page() { + render_manager_.remove_interstitial_page(); + } + + // Returns the currently showing interstitial, NULL if no interstitial is + // showing. + InterstitialPage* interstitial_page() const { + return render_manager_.interstitial_page(); + } + + // Find in Page -------------------------------------------------------------- + + // Starts the Find operation by calling StartFinding on the Tab. This function + // can be called from the outside as a result of hot-keys, so it uses the + // last remembered search string as specified with set_find_string(). This + // function does not block while a search is in progress. The controller will + // receive the results through the notification mechanism. See Observe(...) + // for details. + void StartFinding(const string16& find_text, bool forward_direction); + + // Stops the current Find operation. If |clear_selection| is true, it will + // also clear the selection on the focused frame. + void StopFinding(bool clear_selection); + + // Accessors/Setters for find_ui_active_. + bool find_ui_active() const { return find_ui_active_; } + void set_find_ui_active(bool find_ui_active) { + find_ui_active_ = find_ui_active; + } + + // Setter for find_op_aborted_. + void set_find_op_aborted(bool find_op_aborted) { + find_op_aborted_ = find_op_aborted; + } + + // Used _only_ by testing to set the current request ID, since it calls + // StartFinding on the RenderViewHost directly, rather than by using + // StartFinding's more limited API. + void set_current_find_request_id(int current_find_request_id) { + current_find_request_id_ = current_find_request_id; + } + + // Accessor for find_text_. Used to determine if this WebContents has any + // active searches. + string16 find_text() const { return find_text_; } + + // Accessor for find_prepopulate_text_. Used to access the last search + // string entered, whatever tab that search was performed in. + string16 find_prepopulate_text() const { return *find_prepopulate_text_; } + + // Accessor for find_result_. + const FindNotificationDetails& find_result() const { return find_result_; } + protected: friend class NavigationController; // Used to access the child_windows_ (ConstrainedWindowList) for testing diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index dcd566c..2832765 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -317,24 +317,6 @@ void WebContents::RegisterUserPrefs(PrefService* prefs) { IDS_STATIC_ENCODING_LIST); } -AutofillManager* WebContents::GetAutofillManager() { - if (autofill_manager_.get() == NULL) - autofill_manager_.reset(new AutofillManager(this)); - return autofill_manager_.get(); -} - -PasswordManager* WebContents::GetPasswordManager() { - if (password_manager_.get() == NULL) - password_manager_.reset(new PasswordManager(this)); - return password_manager_.get(); -} - -PluginInstaller* WebContents::GetPluginInstaller() { - if (plugin_installer_.get() == NULL) - plugin_installer_.reset(new PluginInstaller(this)); - return plugin_installer_.get(); -} - const string16& WebContents::GetTitle() const { DOMUI* our_dom_ui = render_manager_.pending_dom_ui() ? render_manager_.pending_dom_ui() : render_manager_.dom_ui(); @@ -637,46 +619,6 @@ void WebContents::CreateShortcut() { render_view_host()->GetApplicationInfo(pending_install_.page_id); } -void WebContents::StartFinding(const string16& find_text, - bool forward_direction) { - // If find_text is empty, it means FindNext was pressed with a keyboard - // shortcut so unless we have something to search for we return early. - if (find_text.empty() && find_text_.empty()) - return; - - // This is a FindNext operation if we are searching for the same text again, - // or if the passed in search text is empty (FindNext keyboard shortcut). The - // exception to this is if the Find was aborted (then we don't want FindNext - // because the highlighting has been cleared and we need it to reappear). We - // therefore treat FindNext after an aborted Find operation as a full fledged - // Find. - bool find_next = (find_text_ == find_text || find_text.empty()) && - !find_op_aborted_; - if (!find_next) - current_find_request_id_ = find_request_id_counter_++; - - if (!find_text.empty()) - find_text_ = find_text; - - find_op_aborted_ = false; - - // Keep track of what the last search was across the tabs. - *find_prepopulate_text_ = find_text; - - render_view_host()->StartFinding(current_find_request_id_, - find_text_, - forward_direction, - false, // case sensitive - find_next); -} - -void WebContents::StopFinding(bool clear_selection) { - find_ui_active_ = false; - find_op_aborted_ = true; - find_result_ = FindNotificationDetails(); - render_view_host()->StopFinding(clear_selection); -} - void WebContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success, const std::wstring& prompt) { diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h index a896bb6..dc239ad 100644 --- a/chrome/browser/tab_contents/web_contents.h +++ b/chrome/browser/tab_contents/web_contents.h @@ -5,41 +5,11 @@ #ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ #define CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_H_ -#include <map> -#include <string> -#include <vector> - #include "chrome/browser/tab_contents/tab_contents.h" -class AutofillForm; -class DOMUI; -class InterstitialPageDelegate; -class LoadNotificationDetails; -class RenderProcessHost; -class RenderViewHost; -class RenderWidgetHost; -struct ThumbnailScore; -struct ViewHostMsg_FrameNavigate_Params; -struct ViewHostMsg_DidPrintPage_Params; - -namespace base { -class WaitableEvent; -} - -namespace webkit_glue { -struct WebApplicationInfo; -} - -namespace IPC { -class Message; -} - // 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 SelectFileDialog::Listener { +class WebContents : public TabContents { public: // If instance is NULL, then creates a new process for this view. Otherwise // initialize with a process already created for a different WebContents. @@ -53,48 +23,6 @@ class WebContents : public TabContents, static void RegisterUserPrefs(PrefService* prefs); - // Getters ------------------------------------------------------------------- - - // Returns the AutofillManager, creating it if necessary. - AutofillManager* GetAutofillManager(); - - // 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 and RenderViewHost. Each of - // these may change over time. - RenderProcessHost* process() const { - return render_manager_.current_host()->process(); - } - RenderViewHost* render_view_host() const { - return render_manager_.current_host(); - } - - // The TabContentsView will never change and is guaranteed non-NULL. - TabContentsView* view() const { - return view_.get(); - } - -#ifdef UNIT_TEST - // Expose the render manager for testing. - RenderViewHostManager* render_manager() { return &render_manager_; } -#endif - - // Page state getters & setters ---------------------------------------------- - - bool is_starred() const { return is_starred_; } - - const std::wstring& encoding() const { return encoding_; } - void set_encoding(const std::wstring& encoding) { - encoding_ = encoding; - } - // Window stuff -------------------------------------------------------------- // Returns true if the location bar should be focused by default rather than @@ -138,75 +66,6 @@ class WebContents : public TabContents, // Tell Gears to create a shortcut for the current page. void CreateShortcut(); - // Interstitials ------------------------------------------------------------- - - // Various other systems need to know about our interstitials. - bool showing_interstitial_page() const { - return render_manager_.interstitial_page() != NULL; - } - - // Sets the passed passed interstitial as the currently showing interstitial. - // |interstitial_page| should be non NULL (use the remove_interstitial_page - // method to unset the interstitial) and no interstitial page should be set - // when there is already a non NULL interstitial page set. - void set_interstitial_page(InterstitialPage* interstitial_page) { - render_manager_.set_interstitial_page(interstitial_page); - } - - // Unsets the currently showing interstitial. - void remove_interstitial_page() { - render_manager_.remove_interstitial_page(); - } - - // Returns the currently showing interstitial, NULL if no interstitial is - // showing. - InterstitialPage* interstitial_page() const { - return render_manager_.interstitial_page(); - } - - // Find in Page -------------------------------------------------------------- - - // Starts the Find operation by calling StartFinding on the Tab. This function - // can be called from the outside as a result of hot-keys, so it uses the - // last remembered search string as specified with set_find_string(). This - // function does not block while a search is in progress. The controller will - // receive the results through the notification mechanism. See Observe(...) - // for details. - void StartFinding(const string16& find_text, bool forward_direction); - - // Stops the current Find operation. If |clear_selection| is true, it will - // also clear the selection on the focused frame. - void StopFinding(bool clear_selection); - - // Accessors/Setters for find_ui_active_. - bool find_ui_active() const { return find_ui_active_; } - void set_find_ui_active(bool find_ui_active) { - find_ui_active_ = find_ui_active; - } - - // Setter for find_op_aborted_. - void set_find_op_aborted(bool find_op_aborted) { - find_op_aborted_ = find_op_aborted; - } - - // Used _only_ by testing to set the current request ID, since it calls - // StartFinding on the RenderViewHost directly, rather than by using - // StartFinding's more limited API. - void set_current_find_request_id(int current_find_request_id) { - current_find_request_id_ = current_find_request_id; - } - - // Accessor for find_text_. Used to determine if this WebContents has any - // active searches. - string16 find_text() const { return find_text_; } - - // Accessor for find_prepopulate_text_. Used to access the last search - // string entered, whatever tab that search was performed in. - string16 find_prepopulate_text() const { return *find_prepopulate_text_; } - - // Accessor for find_result_. - const FindNotificationDetails& find_result() const { return find_result_; } - // Misc state & callbacks ---------------------------------------------------- // Set whether the contents should block javascript message boxes or not. |