diff options
Diffstat (limited to 'webkit/glue/webframeloaderclient_impl.cc')
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 133 |
1 files changed, 40 insertions, 93 deletions
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 698d1a7..8138900 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -16,9 +16,6 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Element.h" #include "HistoryItem.h" #include "HTMLFormElement.h" // needed by FormState.h -#include "HTMLFormControlElement.h" -#include "HTMLInputElement.h" -#include "HTMLNames.h" #include "FormState.h" #include "FrameLoader.h" #include "FrameLoadRequest.h" @@ -42,9 +39,8 @@ MSVC_POP_WARNING(); #if defined(OS_WIN) #include "webkit/activex_shim/activex_shared.h" #endif +#include "webkit/glue/webframeloaderclient_impl.h" #include "webkit/glue/alt_404_page_resource_fetcher.h" -#include "webkit/glue/autocomplete_input_listener.h" -#include "webkit/glue/form_autocomplete_listener.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/plugins/plugin_list.h" @@ -52,7 +48,6 @@ MSVC_POP_WARNING(); #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webdocumentloader_impl.h" #include "webkit/glue/weberror_impl.h" -#include "webkit/glue/webframeloaderclient_impl.h" #include "webkit/glue/webhistoryitem_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin_impl.h" @@ -248,7 +243,7 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, }*/ // When the frame request first 404's, chrome may replace it with the alternate - // 404 page's contents. It does this using substitute data in the document + // 404 page's contents. It does this using substitute data in the document // loader, so the original response and url of the request can be preserved. // We need to avoid replacing the current page, if it has already been // replaced (otherwise could loop on setting alt-404 page!) @@ -351,34 +346,19 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { if (item) { WebCore::HTMLFormElement* form = static_cast<WebCore::HTMLFormElement*>(item); - + // Honour autocomplete=off. if (!form->autoComplete()) continue; - std::set<std::wstring> password_related_fields; scoped_ptr<PasswordForm> data( PasswordFormDomManager::CreatePasswordForm(form)); - if (data.get()) { + if (data.get()) actions.push_back(*data); - // Let's remember the names of password related fields so we do not - // autofill them with the regular form autofill. - if (!data->username_element.empty()) - password_related_fields.insert(data->username_element); - DCHECK(!data->password_element.empty()); - password_related_fields.insert(data->password_element); - if (!data->old_password_element.empty()) - password_related_fields.insert(data->old_password_element); - } - - // Now let's register for any text input. - // TODO(jcampan): bug #3847 merge password and form autofill so we - // traverse the form elements only once. - RegisterAutofillListeners(form, password_related_fields); } } - if (d && (actions.size() > 0)) + if (d && (actions.size() > 0)) d->OnPasswordFormsSeen(webview, actions); if (d) d->DidFinishDocumentLoadForFrame(webview, webframe_); @@ -445,15 +425,15 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { // dispatchDidCancelClientRedirect() -> clears expected redirect // dispatchDidCommitLoad() -> DISPATCHES // -// Client redirect (cancelled) +// Client redirect (cancelled) // (e.g meta-refresh trumped by manual doc.location change, or just cancelled // because a link was clicked that requires the meta refresh to be rescheduled // (the SOURCE URL may have changed). // --------------------------- // dispatchDidCancelClientRedirect() -> clears expected redirect -// dispatchDidStartProvisionalLoad() -> adds only URL to redirect list -// dispatchDidCommitLoad() -> DISPATCHES & clears list -// rescheduled ? dispatchWillPerformClientRedirect() -> saves expected redirect +// dispatchDidStartProvisionalLoad() -> adds only URL to redirect list +// dispatchDidCommitLoad() -> DISPATCHES & clears list +// rescheduled ? dispatchWillPerformClientRedirect() -> saves expected redirect // : nothing // Client redirect (failure) @@ -489,7 +469,7 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { // dispatchDidStartProvisionalLoad() -> adds 1#anchor source // dispatchDidCommitLoad() -> DISPATCHES 1#anchor // dispatchWillPerformClientRedirect() -> saves exp. source (1#anchor) -// -- redirect timer fires +// -- redirect timer fires // dispatchDidStartProvisionalLoad() -> appends 1#anchor (src) and 1 (dest) // dispatchDidCancelClientRedirect() -> clears expected redirect // dispatchDidCommitLoad() -> DISPATCHES 1#anchor + 1 @@ -580,20 +560,20 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { GURL url = ds->GetRequest().GetURL(); GURL chain_end = ds->GetRedirectChain().back(); ds->ClearRedirectChain(); - + // Figure out if this location change is because of a JS-initiated client - // redirect (e.g onload/setTimeout document.location.href=). + // redirect (e.g onload/setTimeout document.location.href=). // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect // performed/cancelled notifications across anchor navigations, so the - // other redirect-tracking code in this class (see dispatch*ClientRedirect() - // and dispatchDidStartProvisionalLoad) is insufficient to catch and - // properly flag these transitions. Once a proper fix for this bug is + // other redirect-tracking code in this class (see dispatch*ClientRedirect() + // and dispatchDidStartProvisionalLoad) is insufficient to catch and + // properly flag these transitions. Once a proper fix for this bug is // identified and applied the following block may no longer be required. bool was_client_redirect = ((url == expected_client_redirect_dest_) && (chain_end == expected_client_redirect_src_)) || (NavigationGestureForLastLoad() == NavigationGestureAuto); - + if (was_client_redirect) { if (d) d->DidCompleteClientRedirect(webview, webframe_, chain_end); @@ -602,7 +582,7 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { // completed it. expected_client_redirect_src_ = GURL(); expected_client_redirect_dest_ = GURL(); - } + } // Regardless of how we got here, we are navigating to a URL so we need to // add it to the redirect chain. @@ -668,10 +648,10 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { // cleared by DidCancelClientRedirect. bool completing_client_redirect = false; if (expected_client_redirect_src_.is_valid()) { - // expected_client_redirect_dest_ could be something like + // expected_client_redirect_dest_ could be something like // "javascript:history.go(-1)" thus we need to exclude url starts with // "javascript:". See bug: 1080873 - DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") || + DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") || expected_client_redirect_dest_ == url); ds->AppendRedirect(expected_client_redirect_src_); completing_client_redirect = true; @@ -687,7 +667,7 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { d->DidStartProvisionalLoadForFrame(webview, webframe_, NavigationGestureForLastLoad()); if (completing_client_redirect) - d->DidCompleteClientRedirect(webview, webframe_, + d->DidCompleteClientRedirect(webview, webframe_, expected_client_redirect_src_); } @@ -699,47 +679,13 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() { // TODO(timsteele): userGestureHint returns too many false positives // (see bug 1051891) to trust it and assign NavigationGestureUser, so - // for now we assign Unknown in those cases and Auto otherwise. + // for now we assign Unknown in those cases and Auto otherwise. // (Issue 874811 known false negative as well). - return webframe_->frame()->loader()->userGestureHint() ? - NavigationGestureUnknown : + return webframe_->frame()->loader()->userGestureHint() ? + NavigationGestureUnknown : NavigationGestureAuto; } -void WebFrameLoaderClient::RegisterAutofillListeners( - WebCore::HTMLFormElement* form, - const std::set<std::wstring>& excluded_fields) { - - WebViewDelegate* webview_delegate = webframe_->webview_impl()->delegate(); - if (!webview_delegate) - return; - - for (size_t i = 0; i < form->formElements.size(); i++) { - WebCore::HTMLFormControlElement* form_element = form->formElements[i]; - if (!form_element->hasLocalName(WebCore::HTMLNames::inputTag)) - continue; - - WebCore::HTMLInputElement* input_element = - static_cast<WebCore::HTMLInputElement*>(form_element); - if (!input_element->isEnabled() || !input_element->isTextField() || - input_element->isPasswordField() || !input_element->autoComplete()) { - continue; - } - - std::wstring name = webkit_glue::StringToStdWString(input_element->name()); - if (excluded_fields.find(name) != excluded_fields.end()) - continue; - -#if !defined(OS_MACOSX) - // FIXME on Mac - webkit_glue::FormAutocompleteListener* listener = - new webkit_glue::FormAutocompleteListener(webview_delegate, - input_element); - webkit_glue::AttachForInlineAutocomplete(input_element, listener); -#endif - } -} - void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { WebViewImpl* webview = webframe_->webview_impl(); WebViewDelegate* d = webview->delegate(); @@ -965,7 +911,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( disposition = d->DispositionForNavigationAction( wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirect); - + if (disposition != IGNORE_ACTION) { if (disposition == CURRENT_TAB) { policy_action = PolicyUse; @@ -1008,7 +954,7 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, // Don't free the SearchableFormData, the loader will do that. loader->set_searchable_form_data(form_data); - PasswordForm* pass_data = + PasswordForm* pass_data = PasswordFormDomManager::CreatePasswordForm(form_ref->form()); // Don't free the PasswordFormData, the loader will do that. loader->set_password_form_data(pass_data); @@ -1026,7 +972,7 @@ void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) { has_representation_ = true; } -void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, +void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error) { if (plugin_widget_) { if (sent_initial_response_to_plugin_) { @@ -1106,7 +1052,7 @@ void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat webframe_->frame()->loader()->activeDocumentLoader()->response()); } plugin_widget_->didReceiveData(data, length); - } + } } void WebFrameLoaderClient::finishedLoading(DocumentLoader* dl) { @@ -1292,7 +1238,7 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedPage(WebCore::CachedPa } // Called when the FrameLoader goes into a state in which a new page load -// will occur. +// will occur. void WebFrameLoaderClient::transitionToCommittedForNewPage() { WebViewImpl* webview = webframe_->webview_impl(); WebViewDelegate* d = webview->delegate(); @@ -1319,16 +1265,16 @@ void WebFrameLoaderClient::download(ResourceHandle* handle, PassRefPtr<Frame> WebFrameLoaderClient::createFrame( const KURL& url, - const String& name, + const String& name, HTMLFrameOwnerElement* owner_element, - const String& referrer, + const String& referrer, bool allows_scrolling, - int margin_width, + int margin_width, int margin_height) { FrameLoadRequest frame_request(ResourceRequest(url, referrer), name); Frame* new_frame = NULL; - if (webframe_) + if (webframe_) webframe_->CreateChildFrame(frame_request, owner_element, allows_scrolling, margin_width, margin_height, new_frame); return new_frame; @@ -1393,7 +1339,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, // TODO(erikkay) // We only allowed specific ActiveX controls to run from certain websites. if (!activex_shim::IsActiveXAllowed(clsid, url)) return NULL; - // We need to pass the combined clsid + version to PluginsList, so that it + // We need to pass the combined clsid + version to PluginsList, so that it // would detect if the requested version is installed. If not, it needs // to use the default plugin to update the control. if (!version.empty()) @@ -1419,7 +1365,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, // TODO(erikkay) char **argv = NULL; int argc = 0; // There is a bug in Webkit which occurs when a plugin instance is defined - // with an OBJECT tag containing the "DATA" attribute". Please refer to the + // with an OBJECT tag containing the "DATA" attribute". Please refer to the // webkit issue http://bugs.webkit.org/show_bug.cgi?id=15457 for more info. // The code below is a patch which should be taken out when a fix is // available in webkit. The logic is to add the "src" attribute to the list @@ -1450,7 +1396,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, // TODO(erikkay) } Widget* result = WebPluginImpl::Create(gurl, argn, argv, argc, element, - webframe_, plugin_delegate, + webframe_, plugin_delegate, load_manually); DeleteToArray(argn); @@ -1467,19 +1413,19 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { } Widget* WebFrameLoaderClient::createJavaAppletWidget( - const IntSize& size, + const IntSize& size, Element *element, const KURL &url, const Vector<String> ¶m_names, const Vector<String> ¶m_values) { - return createPlugin(size, element, url, param_names, param_values, + return createPlugin(size, element, url, param_names, param_values, "application/x-java-applet", false); } ObjectContentType WebFrameLoaderClient::objectContentType( - const KURL& url, + const KURL& url, const String& explicit_mime_type) { // This code is based on Apple's implementation from - // WebCoreSupport/WebFrameBridge.mm. + // WebCoreSupport/WebFrameBridge.mm. String mime_type = explicit_mime_type; if (mime_type.isEmpty()) { @@ -1532,3 +1478,4 @@ bool WebFrameLoaderClient::ActionSpecifiesDisposition( *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; return true; } + |