blob: af8589bc754b3b598a94e89b1996a5ccc74317c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill_manager.h"
#include "base/string_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/web_contents.h"
AutofillManager::~AutofillManager() {
ClearPendingQuery();
}
void AutofillManager::ClearPendingQuery() {
pending_query_name_.clear();
pending_query_prefix_.clear();
if (query_is_pending_) {
WebDataService* web_data_service =
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service) {
NOTREACHED();
return;
}
web_data_service->CancelRequest(pending_query_handle_);
}
pending_query_handle_ = 0;
query_is_pending_ = false;
}
void AutofillManager::AutofillFormSubmitted(const AutofillForm& form) {
StoreFormEntriesInWebDatabase(form);
}
void AutofillManager::FetchValuesForName(const std::wstring& name,
const std::wstring& prefix,
int limit) {
WebDataService* web_data_service =
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service) {
NOTREACHED();
return;
}
ClearPendingQuery();
pending_query_handle_ = web_data_service->
GetFormValuesForElementName(name, prefix, limit, this);
pending_query_name_ = name;
pending_query_prefix_ = prefix;
}
void AutofillManager::OnWebDataServiceRequestDone(WebDataService::Handle h,
const WDTypedResult* result) {
DCHECK(query_is_pending_);
DCHECK(result);
if (!result)
return;
switch (result->GetType()) {
case AUTOFILL_VALUE_RESULT: {
break;
}
default:
NOTREACHED();
break;
}
ClearPendingQuery();
}
void AutofillManager::StoreFormEntriesInWebDatabase(
const AutofillForm& form) {
if (profile()->IsOffTheRecord())
return;
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS)->
AddAutofillFormElements(form.elements);
}
|