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

Side by Side Diff: webkit/glue/webframeloaderclient_impl.cc

Issue 8885: Implementation of the UI part of the autofill (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webframeloaderclient_impl.h ('k') | webkit/glue/webplugin_impl_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
11 MSVC_PUSH_WARNING_LEVEL(0); 11 MSVC_PUSH_WARNING_LEVEL(0);
12 #include "Chrome.h" 12 #include "Chrome.h"
13 #include "CString.h" 13 #include "CString.h"
14 #include "Document.h" 14 #include "Document.h"
15 #include "DocumentLoader.h" 15 #include "DocumentLoader.h"
16 #include "Element.h" 16 #include "Element.h"
17 #include "HistoryItem.h" 17 #include "HistoryItem.h"
18 #include "HTMLFormElement.h" // needed by FormState.h 18 #include "HTMLFormElement.h" // needed by FormState.h
19 #include "HTMLFormControlElement.h"
20 #include "HTMLInputElement.h"
21 #include "HTMLNames.h"
19 #include "FormState.h" 22 #include "FormState.h"
20 #include "FrameLoader.h" 23 #include "FrameLoader.h"
21 #include "FrameLoadRequest.h" 24 #include "FrameLoadRequest.h"
22 #include "FrameView.h" 25 #include "FrameView.h"
23 #include "MIMETypeRegistry.h" 26 #include "MIMETypeRegistry.h"
24 #include "MouseEvent.h" 27 #include "MouseEvent.h"
25 #include "Page.h" 28 #include "Page.h"
26 #include "PlatformString.h" 29 #include "PlatformString.h"
27 #include "PluginInfoStore.h" 30 #include "PluginInfoStore.h"
28 #include "RefPtr.h" 31 #include "RefPtr.h"
29 #include "WindowFeatures.h" 32 #include "WindowFeatures.h"
30 MSVC_POP_WARNING(); 33 MSVC_POP_WARNING();
31 34
32 #undef LOG 35 #undef LOG
33 #include "base/basictypes.h" 36 #include "base/basictypes.h"
34 #include "base/command_line.h" 37 #include "base/command_line.h"
35 #include "base/logging.h" 38 #include "base/logging.h"
36 #include "base/string_util.h" 39 #include "base/string_util.h"
37 #include "net/base/mime_util.h" 40 #include "net/base/mime_util.h"
38 #include "net/base/net_errors.h" 41 #include "net/base/net_errors.h"
39 #if defined(OS_WIN) 42 #if defined(OS_WIN)
40 #include "webkit/activex_shim/activex_shared.h" 43 #include "webkit/activex_shim/activex_shared.h"
41 #endif 44 #endif
42 #include "webkit/glue/webframeloaderclient_impl.h"
43 #include "webkit/glue/alt_404_page_resource_fetcher.h" 45 #include "webkit/glue/alt_404_page_resource_fetcher.h"
46 #include "webkit/glue/autocomplete_input_listener.h"
47 #include "webkit/glue/form_autocomplete_listener.h"
44 #include "webkit/glue/glue_util.h" 48 #include "webkit/glue/glue_util.h"
45 #include "webkit/glue/password_form_dom_manager.h" 49 #include "webkit/glue/password_form_dom_manager.h"
46 #include "webkit/glue/plugins/plugin_list.h" 50 #include "webkit/glue/plugins/plugin_list.h"
47 #include "webkit/glue/searchable_form_data.h" 51 #include "webkit/glue/searchable_form_data.h"
48 #include "webkit/glue/webdatasource_impl.h" 52 #include "webkit/glue/webdatasource_impl.h"
49 #include "webkit/glue/webdocumentloader_impl.h" 53 #include "webkit/glue/webdocumentloader_impl.h"
50 #include "webkit/glue/weberror_impl.h" 54 #include "webkit/glue/weberror_impl.h"
55 #include "webkit/glue/webframeloaderclient_impl.h"
51 #include "webkit/glue/webhistoryitem_impl.h" 56 #include "webkit/glue/webhistoryitem_impl.h"
52 #include "webkit/glue/webkit_glue.h" 57 #include "webkit/glue/webkit_glue.h"
53 #include "webkit/glue/webplugin_impl.h" 58 #include "webkit/glue/webplugin_impl.h"
54 #include "webkit/glue/webresponse_impl.h" 59 #include "webkit/glue/webresponse_impl.h"
55 #include "webkit/glue/webview_delegate.h" 60 #include "webkit/glue/webview_delegate.h"
56 #include "webkit/glue/webview_impl.h" 61 #include "webkit/glue/webview_impl.h"
57 #include "webkit/glue/weburlrequest.h" 62 #include "webkit/glue/weburlrequest.h"
58 63
59 using namespace WebCore; 64 using namespace WebCore;
60 65
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Strange but true, sometimes item can be NULL. 349 // Strange but true, sometimes item can be NULL.
345 WebCore::Node* item = forms->item(i); 350 WebCore::Node* item = forms->item(i);
346 if (item) { 351 if (item) {
347 WebCore::HTMLFormElement* form = 352 WebCore::HTMLFormElement* form =
348 static_cast<WebCore::HTMLFormElement*>(item); 353 static_cast<WebCore::HTMLFormElement*>(item);
349 354
350 // Honour autocomplete=off. 355 // Honour autocomplete=off.
351 if (!form->autoComplete()) 356 if (!form->autoComplete())
352 continue; 357 continue;
353 358
359 std::set<std::wstring> password_related_fields;
354 scoped_ptr<PasswordForm> data( 360 scoped_ptr<PasswordForm> data(
355 PasswordFormDomManager::CreatePasswordForm(form)); 361 PasswordFormDomManager::CreatePasswordForm(form));
356 if (data.get()) 362 if (data.get()) {
357 actions.push_back(*data); 363 actions.push_back(*data);
364 // Let's remember the names of password related fields so we do not
365 // autofill them with the regular form autofill.
366 DCHECK(!data->username_element.empty());
367 DCHECK(!data->password_element.empty());
368 password_related_fields.insert(data->username_element);
369 password_related_fields.insert(data->password_element);
370 if (!data->old_password_element.empty())
371 password_related_fields.insert(data->old_password_element);
372 }
373
374 // Now let's register for any text input.
375 // TODO(jcampan): bug #3847 merge password and form autofill so we
376 // traverse the form elements only once.
377 RegisterAutofillListeners(form, password_related_fields);
358 } 378 }
359 } 379 }
380
360 if (d && (actions.size() > 0)) 381 if (d && (actions.size() > 0))
361 d->OnPasswordFormsSeen(webview, actions); 382 d->OnPasswordFormsSeen(webview, actions);
362 if (d) 383 if (d)
363 d->DidFinishDocumentLoadForFrame(webview, webframe_); 384 d->DidFinishDocumentLoadForFrame(webview, webframe_);
364 } 385 }
365 386
366 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( 387 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(
367 DocumentLoader* loader, 388 DocumentLoader* loader,
368 const ResourceRequest& request, 389 const ResourceRequest& request,
369 const ResourceResponse& response, 390 const ResourceResponse& response,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() { 699 NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() {
679 // TODO(timsteele): userGestureHint returns too many false positives 700 // TODO(timsteele): userGestureHint returns too many false positives
680 // (see bug 1051891) to trust it and assign NavigationGestureUser, so 701 // (see bug 1051891) to trust it and assign NavigationGestureUser, so
681 // for now we assign Unknown in those cases and Auto otherwise. 702 // for now we assign Unknown in those cases and Auto otherwise.
682 // (Issue 874811 known false negative as well). 703 // (Issue 874811 known false negative as well).
683 return webframe_->frame()->loader()->userGestureHint() ? 704 return webframe_->frame()->loader()->userGestureHint() ?
684 NavigationGestureUnknown : 705 NavigationGestureUnknown :
685 NavigationGestureAuto; 706 NavigationGestureAuto;
686 } 707 }
687 708
709 void WebFrameLoaderClient::RegisterAutofillListeners(
710 WebCore::HTMLFormElement* form,
711 const std::set<std::wstring>& excluded_fields) {
712
713 WebViewDelegate* webview_delegate = webframe_->webview_impl()->delegate();
714 if (!webview_delegate)
715 return;
716
717 for (size_t i = 0; i < form->formElements.size(); i++) {
718 WebCore::HTMLFormControlElement* form_element = form->formElements[i];
719 if (!form_element->hasLocalName(WebCore::HTMLNames::inputTag))
720 continue;
721
722 WebCore::HTMLInputElement* input_element =
723 static_cast<WebCore::HTMLInputElement*>(form_element);
724 if (!input_element->isEnabled() || !input_element->isTextField() ||
725 input_element->isPasswordField() || !input_element->autoComplete()) {
726 continue;
727 }
728
729 std::wstring name = webkit_glue::StringToStdWString(input_element->name());
730 if (excluded_fields.find(name) != excluded_fields.end())
731 continue;
732
733 #if !defined(OS_MACOSX)
734 // FIXME on Mac
735 webkit_glue::FormAutocompleteListener* listener =
736 new webkit_glue::FormAutocompleteListener(webview_delegate,
737 input_element);
738 webkit_glue::AttachForInlineAutocomplete(input_element, listener);
739 #endif
740 }
741 }
742
688 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { 743 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) {
689 WebViewImpl* webview = webframe_->webview_impl(); 744 WebViewImpl* webview = webframe_->webview_impl();
690 WebViewDelegate* d = webview->delegate(); 745 WebViewDelegate* d = webview->delegate();
691 if (d) { 746 if (d) {
692 d->DidReceiveTitle(webview, webkit_glue::StringToStdWString(title), 747 d->DidReceiveTitle(webview, webkit_glue::StringToStdWString(title),
693 webframe_); 748 webframe_);
694 } 749 }
695 } 750 }
696 751
697 void WebFrameLoaderClient::dispatchDidCommitLoad() { 752 void WebFrameLoaderClient::dispatchDidCommitLoad() {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 if (!middle_or_ctrl && !shift && !alt) 1525 if (!middle_or_ctrl && !shift && !alt)
1471 return false; 1526 return false;
1472 1527
1473 DCHECK(disposition); 1528 DCHECK(disposition);
1474 if (middle_or_ctrl) 1529 if (middle_or_ctrl)
1475 *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; 1530 *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
1476 else 1531 else
1477 *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; 1532 *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK;
1478 return true; 1533 return true;
1479 } 1534 }
1480
OLDNEW
« no previous file with comments | « webkit/glue/webframeloaderclient_impl.h ('k') | webkit/glue/webplugin_impl_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698