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

Unified Diff: components/autofill/browser/autocomplete_history_manager.cc

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nit Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/autocomplete_history_manager.cc
diff --git a/components/autofill/browser/autocomplete_history_manager.cc b/components/autofill/browser/autocomplete_history_manager.cc
index 2f6ce6356e20b0887005d98542ec8c9338fdc875..bff521cb899e66bb35c281fd15efe4a00eceaa55 100644
--- a/components/autofill/browser/autocomplete_history_manager.cc
+++ b/components/autofill/browser/autocomplete_history_manager.cc
@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/browser/autofill_driver.h"
#include "components/autofill/browser/autofill_external_delegate.h"
#include "components/autofill/browser/validation.h"
#include "components/autofill/common/autofill_messages.h"
@@ -18,6 +19,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "ipc/ipc_message_macros.h"
using content::BrowserContext;
using content::WebContents;
@@ -42,14 +44,15 @@ bool IsTextField(const FormFieldData& field) {
} // namespace
AutocompleteHistoryManager::AutocompleteHistoryManager(
- WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
- browser_context_(web_contents->GetBrowserContext()),
+ AutofillDriver* driver)
Ilya Sherman 2013/06/12 00:07:46 nit: Looks like this fits on the previous line.
blundell 2013/06/12 16:29:37 Done.
+ : browser_context_(driver->GetWebContents()->GetBrowserContext()),
+ driver_(driver),
autofill_data_(
AutofillWebDataService::FromBrowserContext(browser_context_)),
pending_query_handle_(0),
query_id_(0),
- external_delegate_(NULL) {
+ external_delegate_(NULL),
+ send_IPC_(true) {
autofill_enabled_.Init(
prefs::kAutofillEnabled,
user_prefs::UserPrefs::Get(browser_context_));
@@ -59,17 +62,6 @@ AutocompleteHistoryManager::~AutocompleteHistoryManager() {
CancelPendingQuery();
}
-bool AutocompleteHistoryManager::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(AutocompleteHistoryManager, message)
- IPC_MESSAGE_HANDLER(AutofillHostMsg_RemoveAutocompleteEntry,
- OnRemoveAutocompleteEntry)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
void AutocompleteHistoryManager::OnWebDataServiceRequestDone(
WebDataServiceBase::Handle h,
const WDTypedResult* result) {
@@ -207,12 +199,16 @@ void AutocompleteHistoryManager::SendSuggestions(
autofill_icons_,
autofill_unique_ids_);
} else {
- Send(new AutofillMsg_SuggestionsReturned(routing_id(),
- query_id_,
- autofill_values_,
- autofill_labels_,
- autofill_icons_,
- autofill_unique_ids_));
+ WebContents* web_contents = driver_->GetWebContents();
+ if (web_contents) {
blundell 2013/06/12 16:29:37 This is where send_ipc_ should have been used (and
+ web_contents->Send(
+ new AutofillMsg_SuggestionsReturned(web_contents->GetRoutingID(),
+ query_id_,
+ autofill_values_,
+ autofill_labels_,
+ autofill_icons_,
+ autofill_unique_ids_));
+ }
}
query_id_ = 0;

Powered by Google App Engine
This is Rietveld 408576698