|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: FormFill |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <../bidi.h> |
|
21 #include "WebFormFill.h" |
|
22 #include "WebFormFillPopup.h" |
|
23 #include "WebView.h" |
|
24 #include "brctl.h" |
|
25 #include "SettingsContainer.h" |
|
26 #include "StaticObjectsContainer.h" |
|
27 #include "FormFillController.h" |
|
28 #include "FormState.h" |
|
29 #include "HtmlInputElement.h" |
|
30 #include <webkit.rsg> |
|
31 |
|
32 #include <StringLoader.h> |
|
33 |
|
34 |
|
35 using namespace WebCore; |
|
36 |
|
37 // EXTERNAL DATA STRUCTURES |
|
38 //extern ?external_data; |
|
39 |
|
40 // EXTERNAL FUNCTION PROTOTYPES |
|
41 //extern ?external_function( ?arg_type,?arg_type ); |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 |
|
46 |
|
47 // ============================= LOCAL FUNCTIONS =============================== |
|
48 |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // WebFormFill::WebFormFill |
|
54 // C++ default constructor can NOT contain any code, that |
|
55 // might leave. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 WebFormFill::WebFormFill( WebView* view ) |
|
59 : m_webView(view) |
|
60 { |
|
61 } |
|
62 |
|
63 // Destructor |
|
64 WebFormFill::~WebFormFill() |
|
65 { |
|
66 } |
|
67 |
|
68 void WebFormFill::willSubmitForm(FormState* formState) |
|
69 { |
|
70 int formDataType = m_webView->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsAutoFormFillEnabled); |
|
71 if (formDataType != TBrCtlDefs::EFormDataOff) { |
|
72 StaticObjectsContainer::instance()->formFillController()->saveFormData(formState->form(), this, formDataType == TBrCtlDefs::EFormDataPlusPassword); |
|
73 } |
|
74 } |
|
75 |
|
76 void WebFormFill::queryUserAboutAutoFillL(bool& saveNow, bool& neverSave) |
|
77 { |
|
78 MBrCtlDialogsProvider* dialogProvider = m_webView->brCtl()->brCtlDialogsProvider(); |
|
79 saveNow = false; |
|
80 neverSave = false; |
|
81 if(dialogProvider) { |
|
82 HBufC* leftkey = StringLoader::LoadLC(R_TEXT_SOFTKEY_YES); |
|
83 HBufC* rightkey = StringLoader::LoadLC(R_TEXT_SOFTKEY_NO); |
|
84 HBufC* saveQuery = StringLoader::LoadLC(R_BROWSER_FORM_AUTOFILL_SAVE); |
|
85 HBufC* blockQuery = StringLoader::LoadLC(R_BROWSER_FORM_AUTOFILL_ASK_LATER); |
|
86 saveNow = dialogProvider->DialogConfirmL(_L(" "),*saveQuery,*leftkey,*rightkey); |
|
87 if (!saveNow) { |
|
88 neverSave = !dialogProvider->DialogConfirmL(_L(" "),*blockQuery,*leftkey,*rightkey); |
|
89 } |
|
90 CleanupStack::PopAndDestroy(4); // leftKey, rightKey, saveQuery, blockQuery |
|
91 } |
|
92 } |
|
93 |
|
94 MFormFillPopup* WebFormFill::createFormFillPopup(CFont* font) |
|
95 { |
|
96 WebFormFillPopup* popup = NULL; |
|
97 TRAP_IGNORE(popup = WebFormFillPopup::NewL(m_webView, font, this)); |
|
98 return popup; |
|
99 } |
|
100 |
|
101 void WebFormFill::autoComplete(TPtrC text) |
|
102 { |
|
103 FormFillController* formfill = StaticObjectsContainer::instance()->formFillController(); |
|
104 HTMLInputElement* inputNode = formfill->inputElement(); |
|
105 if( inputNode ) { |
|
106 inputNode->setValue(text); |
|
107 if (m_webView->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsAutoFormFillEnabled) == TBrCtlDefs::EFormDataPlusPassword) { |
|
108 formfill->fillPasswordIfExists(inputNode); |
|
109 } |
|
110 } |
|
111 formfill->stopSearch(); |
|
112 } |
|
113 |
|
114 void WebFormFill::cancelPopup() |
|
115 { |
|
116 StaticObjectsContainer::instance()->formFillController()->clearInputElement(); |
|
117 //m_webView->setEditable(ETrue); |
|
118 } |
|
119 |
|
120 void WebFormFill::textChanged(Element* inputElement) |
|
121 { |
|
122 int formDataType = m_webView->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsAutoFormFillEnabled); |
|
123 if (formDataType != TBrCtlDefs::EFormDataOff) { |
|
124 if (StaticObjectsContainer::instance()->formFillController()->inputElement() != inputElement) { |
|
125 StaticObjectsContainer::instance()->formFillController()->setInputElement(this, static_cast<HTMLInputElement*>(inputElement)); |
|
126 } |
|
127 else { |
|
128 StaticObjectsContainer::instance()->formFillController()->startSearch(); |
|
129 } |
|
130 } |
|
131 } |
|
132 |
|
133 void WebFormFill::updatePopupView() |
|
134 { |
|
135 StaticObjectsContainer::instance()->formFillController()->updatePopupView(); |
|
136 } |
|
137 |
|
138 // End of File |