Commit 3fd04007 authored by jrg@chromium.org's avatar jrg@chromium.org

External autofill delegates.


BUG=
TEST=


Review URL: http://codereview.chromium.org/8353025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107839 0039d316-1c4b-4281-b951-d872f2087c98
parent e8cdf353
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/autofill/credit_card.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -102,7 +103,8 @@ AutocompleteHistoryManager::AutocompleteHistoryManager( ...@@ -102,7 +103,8 @@ AutocompleteHistoryManager::AutocompleteHistoryManager(
TabContents* tab_contents) TabContents* tab_contents)
: TabContentsObserver(tab_contents), : TabContentsObserver(tab_contents),
pending_query_handle_(0), pending_query_handle_(0),
query_id_(0) { query_id_(0),
external_delegate_(NULL) {
profile_ = Profile::FromBrowserContext(tab_contents->browser_context()); profile_ = Profile::FromBrowserContext(tab_contents->browser_context());
// May be NULL in unit tests. // May be NULL in unit tests.
web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
...@@ -262,6 +264,15 @@ void AutocompleteHistoryManager::SendSuggestions( ...@@ -262,6 +264,15 @@ void AutocompleteHistoryManager::SendSuggestions(
} }
} }
if (external_delegate_) {
external_delegate_->OnSuggestionsReturned(
query_id_,
autofill_values_,
autofill_labels_,
autofill_icons_,
autofill_unique_ids_);
}
Send(new AutofillMsg_SuggestionsReturned(routing_id(), Send(new AutofillMsg_SuggestionsReturned(routing_id(),
query_id_, query_id_,
autofill_values_, autofill_values_,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "base/gtest_prod_util.h"
#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_data_service.h"
#include "content/browser/tab_contents/tab_contents_observer.h" #include "content/browser/tab_contents/tab_contents_observer.h"
...@@ -16,6 +17,7 @@ namespace webkit_glue { ...@@ -16,6 +17,7 @@ namespace webkit_glue {
struct FormData; struct FormData;
} // namespace webkit_glue } // namespace webkit_glue
class AutofillExternalDelegate;
class Profile; class Profile;
class TabContents; class TabContents;
...@@ -46,9 +48,16 @@ class AutocompleteHistoryManager : public TabContentsObserver, ...@@ -46,9 +48,16 @@ class AutocompleteHistoryManager : public TabContentsObserver,
const std::vector<int>& autofill_unique_ids); const std::vector<int>& autofill_unique_ids);
void OnFormSubmitted(const webkit_glue::FormData& form); void OnFormSubmitted(const webkit_glue::FormData& form);
// Sets our external delegate.
void SetExternalDelegate(AutofillExternalDelegate* delegate) {
external_delegate_ = delegate;
}
protected: protected:
friend class AutocompleteHistoryManagerTest; friend class AutocompleteHistoryManagerTest;
friend class AutofillManagerTest; friend class AutofillManagerTest;
FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestTabContents);
// For tests. // For tests.
AutocompleteHistoryManager(TabContents* tab_contents, AutocompleteHistoryManager(TabContents* tab_contents,
...@@ -58,6 +67,11 @@ class AutocompleteHistoryManager : public TabContentsObserver, ...@@ -58,6 +67,11 @@ class AutocompleteHistoryManager : public TabContentsObserver,
void SendSuggestions(const std::vector<string16>* suggestions); void SendSuggestions(const std::vector<string16>* suggestions);
void CancelPendingQuery(); void CancelPendingQuery();
// Exposed for testing.
AutofillExternalDelegate* external_delegate() {
return external_delegate_;
}
private: private:
void OnRemoveAutocompleteEntry(const string16& name, const string16& value); void OnRemoveAutocompleteEntry(const string16& name, const string16& value);
...@@ -76,6 +90,10 @@ class AutocompleteHistoryManager : public TabContentsObserver, ...@@ -76,6 +90,10 @@ class AutocompleteHistoryManager : public TabContentsObserver,
std::vector<string16> autofill_icons_; std::vector<string16> autofill_icons_;
std::vector<int> autofill_unique_ids_; std::vector<int> autofill_unique_ids_;
// Delegate to perform external processing (display, selection) on
// our behalf. Weak.
AutofillExternalDelegate* external_delegate_;
DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
}; };
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "base/task.h" #include "base/task.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_data_service.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
...@@ -132,3 +134,54 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) { ...@@ -132,3 +134,54 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) {
EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
autocomplete_manager_->OnFormSubmitted(form); autocomplete_manager_->OnFormSubmitted(form);
} }
namespace {
class MockAutofillExternalDelegate : public AutofillExternalDelegate {
public:
explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper)
: AutofillExternalDelegate(wrapper) {}
virtual ~MockAutofillExternalDelegate() {}
virtual void OnQuery(int query_id,
const webkit_glue::FormData& form,
const webkit_glue::FormField& field) {}
MOCK_METHOD5(OnSuggestionsReturned,
void(int query_id,
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
const std::vector<string16>& autofill_icons,
const std::vector<int>& autofill_unique_ids));
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
};
class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager {
public:
explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents,
Profile* profile,
WebDataService* wds)
: AutocompleteHistoryManager(tab_contents, profile, wds) {}
virtual bool Send(IPC::Message* message) { return true; } // intentional nop
};
} // namespace
// Make sure our external delegate is called at the right time.
TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
// Local version with a stubbed out Send()
AutocompleteHistoryManagerStubSend autocomplete_history_manager(
contents(),
&profile_, web_data_service_);
MockAutofillExternalDelegate external_delegate(
TabContentsWrapper::GetCurrentWrapperForContents(contents()));
EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
autocomplete_history_manager.SetExternalDelegate(&external_delegate);
// Should trigger a call to OnSuggestionsReturned, verified by the mock.
autocomplete_history_manager.SendSuggestions(NULL);
}
// Copyright (c) 2011 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/autofill_external_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/autofill_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
AutofillExternalDelegate::~AutofillExternalDelegate() {
}
AutofillExternalDelegate::AutofillExternalDelegate(
TabContentsWrapper* tab_contents_wrapper)
: tab_contents_wrapper_(tab_contents_wrapper) {
}
void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int listIndex) {
RenderViewHost* host = tab_contents_wrapper_->render_view_host();
host->Send(new AutofillMsg_SelectAutofillSuggestionAtIndex(
host->routing_id(),
listIndex));
}
// Add a "!defined(OS_YOUROS) for each platform that implements this
// in an autofill_external_delegate_YOUROS.cc. Currently there are
// none, so all platforms use the default.
#if !defined(OS_ANDROID)
AutofillExternalDelegate* AutofillExternalDelegate::Create(
TabContentsWrapper*, AutofillManager*) {
return NULL;
}
#endif
// Copyright (c) 2011 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.
#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
#pragma once
#include <vector>
#include "base/string16.h"
class AutofillManager;
class TabContentsWrapper;
namespace webkit_glue {
struct FormData;
struct FormField;
} // namespace webkit_glue
// Delegate for external processing of Autocomplete and Autofill
// display and selection.
class AutofillExternalDelegate {
public:
virtual ~AutofillExternalDelegate();
// When using an external Autofill delegate. Allows Chrome to tell
// WebKit which Autofill selection has been chosen.
// TODO(jrg): add feedback mechanism for hover on relevant platforms.
void SelectAutofillSuggestionAtIndex(int listIndex);
// Records and associates a query_id with web form data. Called
// when the renderer posts an Autofill query to the browser.
virtual void OnQuery(int query_id,
const webkit_glue::FormData& form,
const webkit_glue::FormField& field) = 0;
// Records query results. Displays them to the user with an external
// Autofill popup that lives completely in the browser. Called when
// an Autofill query result is available.
virtual void OnSuggestionsReturned(
int query_id,
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
const std::vector<string16>& autofill_icons,
const std::vector<int>& autofill_unique_ids) = 0;
// Platforms that wish to implement an external Autofill delegate
// MUST implement this. The 1st arg is the tab contents that owns
// this delegate; the second is the Autofill manager owned by the
// tab contents.
static AutofillExternalDelegate* Create(TabContentsWrapper*,
AutofillManager*);
protected:
explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper);
private:
TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
};
#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h" #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/autofill/autofill_field.h" #include "chrome/browser/autofill/autofill_field.h"
#include "chrome/browser/autofill/autofill_metrics.h" #include "chrome/browser/autofill/autofill_metrics.h"
#include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/autofill_profile.h"
...@@ -216,7 +217,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) ...@@ -216,7 +217,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents)
did_show_suggestions_(false), did_show_suggestions_(false),
user_did_type_(false), user_did_type_(false),
user_did_autofill_(false), user_did_autofill_(false),
user_did_edit_autofilled_field_(false) { user_did_edit_autofilled_field_(false),
external_delegate_(NULL) {
DCHECK(tab_contents); DCHECK(tab_contents);
// |personal_data_| is NULL when using TestTabContents. // |personal_data_| is NULL when using TestTabContents.
...@@ -380,6 +382,9 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, ...@@ -380,6 +382,9 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
std::vector<string16> icons; std::vector<string16> icons;
std::vector<int> unique_ids; std::vector<int> unique_ids;
if (external_delegate_)
external_delegate_->OnQuery(query_id, form, field);
RenderViewHost* host = NULL; RenderViewHost* host = NULL;
FormStructure* form_structure = NULL; FormStructure* form_structure = NULL;
AutofillField* autofill_field = NULL; AutofillField* autofill_field = NULL;
...@@ -733,7 +738,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, ...@@ -733,7 +738,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents,
did_show_suggestions_(false), did_show_suggestions_(false),
user_did_type_(false), user_did_type_(false),
user_did_autofill_(false), user_did_autofill_(false),
user_did_edit_autofilled_field_(false) { user_did_edit_autofilled_field_(false),
external_delegate_(NULL) {
DCHECK(tab_contents); DCHECK(tab_contents);
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "chrome/browser/autofill/form_structure.h" #include "chrome/browser/autofill/form_structure.h"
#include "content/browser/tab_contents/tab_contents_observer.h" #include "content/browser/tab_contents/tab_contents_observer.h"
class AutofillExternalDelegate;
class AutofillField; class AutofillField;
class AutofillProfile; class AutofillProfile;
class AutofillMetrics; class AutofillMetrics;
...@@ -54,6 +55,14 @@ class AutofillManager : public TabContentsObserver, ...@@ -54,6 +55,14 @@ class AutofillManager : public TabContentsObserver,
// Registers our Enable/Disable Autofill pref. // Registers our Enable/Disable Autofill pref.
static void RegisterUserPrefs(PrefService* prefs); static void RegisterUserPrefs(PrefService* prefs);
// Set our external delegate.
// TODO(jrg): consider passing delegate into the ctor. That won't
// work if the delegate has a pointer to the AutofillManager, but
// future directions may not need such a pointer.
void SetExternalDelegate(AutofillExternalDelegate* delegate) {
external_delegate_ = delegate;
}
protected: protected:
// Only test code should subclass AutofillManager. // Only test code should subclass AutofillManager.
...@@ -90,6 +99,17 @@ class AutofillManager : public TabContentsObserver, ...@@ -90,6 +99,17 @@ class AutofillManager : public TabContentsObserver,
ScopedVector<FormStructure>* form_structures() { return &form_structures_; } ScopedVector<FormStructure>* form_structures() { return &form_structures_; }
// Called from our external delegate so it cannot be private.
void OnFillAutoFillFormData(int query_id,
const webkit_glue::FormData& form,
const webkit_glue::FormField& field,
int unique_id);
// Exposed for testing.
AutofillExternalDelegate* external_delegate() {
return external_delegate_;
}
private: private:
// TabContentsObserver: // TabContentsObserver:
virtual void DidNavigateMainFramePostCommit( virtual void DidNavigateMainFramePostCommit(
...@@ -268,6 +288,10 @@ class AutofillManager : public TabContentsObserver, ...@@ -268,6 +288,10 @@ class AutofillManager : public TabContentsObserver,
mutable std::map<GUIDPair, int> guid_id_map_; mutable std::map<GUIDPair, int> guid_id_map_;
mutable std::map<int, GUIDPair> id_guid_map_; mutable std::map<int, GUIDPair> id_guid_map_;
// Delegate to perform external processing (display, selection) on
// our behalf. Weak.
AutofillExternalDelegate* external_delegate_;
friend class AutofillManagerTest; friend class AutofillManagerTest;
friend class FormStructureBrowserTest; friend class FormStructureBrowserTest;
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
...@@ -282,6 +306,9 @@ class AutofillManager : public TabContentsObserver, ...@@ -282,6 +306,9 @@ class AutofillManager : public TabContentsObserver,
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestExternalDelegate);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
TestTabContentsWithExternalDelegate);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
UserHappinessFormLoadAndSubmission); UserHappinessFormLoadAndSubmission);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/string16.h" #include "base/string16.h"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_common_test.h" #include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/autofill/autofill_manager.h"
#include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/autofill/credit_card.h"
...@@ -25,6 +27,7 @@ ...@@ -25,6 +27,7 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
#include "chrome/common/autofill_messages.h" #include "chrome/common/autofill_messages.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/browser/tab_contents/test_tab_contents.h" #include "content/browser/tab_contents/test_tab_contents.h"
...@@ -38,6 +41,7 @@ ...@@ -38,6 +41,7 @@
#include "webkit/glue/form_data.h" #include "webkit/glue/form_data.h"
#include "webkit/glue/form_field.h" #include "webkit/glue/form_field.h"
using testing::_;
using webkit_glue::FormData; using webkit_glue::FormData;
using webkit_glue::FormField; using webkit_glue::FormField;
...@@ -2834,3 +2838,68 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUploadStressTest) { ...@@ -2834,3 +2838,68 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUploadStressTest) {
EXPECT_TRUE(possible_types2.find(UNKNOWN_TYPE) != EXPECT_TRUE(possible_types2.find(UNKNOWN_TYPE) !=
possible_types2.end()); possible_types2.end());
} }
namespace {
class MockAutofillExternalDelegate : public AutofillExternalDelegate {
public:
explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper)
: AutofillExternalDelegate(wrapper) {}
virtual ~MockAutofillExternalDelegate() {}
MOCK_METHOD3(OnQuery, void(int query_id,
const webkit_glue::FormData& form,
const webkit_glue::FormField& field));
virtual void OnSuggestionsReturned(
int query_id,
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
const std::vector<string16>& autofill_icons,
const std::vector<int>& autofill_unique_ids) {}
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
};
} // namespace
// Test our external delegate is called at the right time.
TEST_F(AutofillManagerTest, TestExternalDelegate) {
MockAutofillExternalDelegate external_delegate(contents_wrapper());
EXPECT_CALL(external_delegate, OnQuery(_, _, _));
autofill_manager_->SetExternalDelegate(&external_delegate);
FormData form;
CreateTestAddressFormData(&form);
std::vector<FormData> forms(1, form);
FormsSeen(forms);
const FormField& field = form.fields[0];
GetAutofillSuggestions(form, field); // should call the delegate's OnQuery()
autofill_manager_->SetExternalDelegate(NULL);
}
#if defined(OS_ANDROID)
// Only OS_ANDROID defines an external delegate, but prerequisites for
// landing autofill_external_delegate_android.cc in the Chromium tree
// have not themselves landed.
// Turn on the external delegate. Recreate a TabContents. Make sure
// an external delegate was set in the proper structures.
TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kExternalAutofillPopup);
// Setting the contents creates a new TabContentsWrapper.
TestTabContents* contents = CreateTestTabContents();
SetContents(contents);
AutofillManager* autofill_manager = contents_wrapper()->autofill_manager();
EXPECT_TRUE(autofill_manager->external_delegate());
AutocompleteHistoryManager* autocomplete_history_manager =
contents_wrapper()->autocomplete_history_manager();
EXPECT_TRUE(autocomplete_history_manager->external_delegate());
}
#endif // OS_ANDROID
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/command_line.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/autofill/autofill_manager.h"
#include "chrome/browser/automation/automation_tab_helper.h" #include "chrome/browser/automation/automation_tab_helper.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -246,6 +248,14 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) ...@@ -246,6 +248,14 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents)
// Create the tab helpers. // Create the tab helpers.
autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents));
autofill_manager_.reset(new AutofillManager(this)); autofill_manager_.reset(new AutofillManager(this));
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExternalAutofillPopup)) {
autofill_external_delegate_.reset(
AutofillExternalDelegate::Create(this, autofill_manager_.get()));
autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get());
autocomplete_history_manager_->SetExternalDelegate(
autofill_external_delegate_.get());
}
automation_tab_helper_.reset(new AutomationTabHelper(contents)); automation_tab_helper_.reset(new AutomationTabHelper(contents));
blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this));
bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); bookmark_tab_helper_.reset(new BookmarkTabHelper(this));
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
class AutocompleteHistoryManager; class AutocompleteHistoryManager;
class AutofillManager; class AutofillManager;
class AutofillExternalDelegate;
class AutomationTabHelper; class AutomationTabHelper;
class BlockedContentTabHelper; class BlockedContentTabHelper;
class BookmarkTabHelper; class BookmarkTabHelper;
...@@ -274,6 +275,7 @@ class TabContentsWrapper : public TabContentsObserver, ...@@ -274,6 +275,7 @@ class TabContentsWrapper : public TabContentsObserver,
scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
scoped_ptr<AutofillManager> autofill_manager_; scoped_ptr<AutofillManager> autofill_manager_;
scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_;
scoped_ptr<AutomationTabHelper> automation_tab_helper_; scoped_ptr<AutomationTabHelper> automation_tab_helper_;
scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_;
scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_;
......
...@@ -138,6 +138,8 @@ ...@@ -138,6 +138,8 @@
'browser/autofill/autofill_country.h', 'browser/autofill/autofill_country.h',
'browser/autofill/autofill_download.cc', 'browser/autofill/autofill_download.cc',
'browser/autofill/autofill_download.h', 'browser/autofill/autofill_download.h',
'browser/autofill/autofill_external_delegate.cc',
'browser/autofill/autofill_external_delegate.h',
'browser/autofill/autofill_feedback_infobar_delegate.cc', 'browser/autofill/autofill_feedback_infobar_delegate.cc',
'browser/autofill/autofill_feedback_infobar_delegate.h', 'browser/autofill/autofill_feedback_infobar_delegate.h',
'browser/autofill/autofill_field.cc', 'browser/autofill/autofill_field.cc',
......
...@@ -88,6 +88,10 @@ IPC_MESSAGE_ROUTED1( ...@@ -88,6 +88,10 @@ IPC_MESSAGE_ROUTED1(
AutofillMsg_FieldTypePredictionsAvailable, AutofillMsg_FieldTypePredictionsAvailable,
std::vector<webkit_glue::FormDataPredictions> /* forms */) std::vector<webkit_glue::FormDataPredictions> /* forms */)
// Select an Autofill item when using an external delegate.
IPC_MESSAGE_ROUTED1(AutofillMsg_SelectAutofillSuggestionAtIndex,
int /* listIndex */)
// Autofill messages sent from the renderer to the browser. // Autofill messages sent from the renderer to the browser.
// Notification that forms have been seen that are candidates for // Notification that forms have been seen that are candidates for
......
...@@ -589,6 +589,9 @@ const char kExtensionProcess[] = "extension-process"; ...@@ -589,6 +589,9 @@ const char kExtensionProcess[] = "extension-process";
// Frequency in seconds for Extensions auto-update. // Frequency in seconds for Extensions auto-update.
const char kExtensionsUpdateFrequency[] = "extensions-update-frequency"; const char kExtensionsUpdateFrequency[] = "extensions-update-frequency";
// Should we use an external Autofill popup? Default is no.
const char kExternalAutofillPopup[] = "external-autofill-popup";
// These two flags are added around the switches about:flags adds to the // These two flags are added around the switches about:flags adds to the
// command line. This is useful to see which switches were added by about:flags // command line. This is useful to see which switches were added by about:flags
// on about:version. They don't have any effect. // on about:version. They don't have any effect.
......
...@@ -169,6 +169,7 @@ extern const char kExperimentalSpellcheckerFeatures[]; ...@@ -169,6 +169,7 @@ extern const char kExperimentalSpellcheckerFeatures[];
extern const char kExplicitlyAllowedPorts[]; extern const char kExplicitlyAllowedPorts[];
extern const char kExtensionProcess[]; extern const char kExtensionProcess[];
extern const char kExtensionsUpdateFrequency[]; extern const char kExtensionsUpdateFrequency[];
extern const char kExternalAutofillPopup[];
extern const char kFlagSwitchesBegin[]; extern const char kFlagSwitchesBegin[];
extern const char kFlagSwitchesEnd[]; extern const char kFlagSwitchesEnd[];
extern const char kFeedbackServer[]; extern const char kFeedbackServer[];
......
...@@ -72,6 +72,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { ...@@ -72,6 +72,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled)
IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable,
OnFieldTypePredictionsAvailable) OnFieldTypePredictionsAvailable)
IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex,
OnSelectAutofillSuggestionAtIndex)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; return handled;
...@@ -350,6 +352,12 @@ void AutofillAgent::OnFieldTypePredictionsAvailable( ...@@ -350,6 +352,12 @@ void AutofillAgent::OnFieldTypePredictionsAvailable(
} }
} }
void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) {
NOTIMPLEMENTED();
// TODO(jrg): enable once changes land in WebKit
// render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex);
}
void AutofillAgent::ShowSuggestions(const WebInputElement& element, void AutofillAgent::ShowSuggestions(const WebInputElement& element,
bool autofill_on_empty_values, bool autofill_on_empty_values,
bool requires_caret_at_end, bool requires_caret_at_end,
......
...@@ -100,6 +100,9 @@ class AutofillAgent : public content::RenderViewObserver, ...@@ -100,6 +100,9 @@ class AutofillAgent : public content::RenderViewObserver,
void OnFieldTypePredictionsAvailable( void OnFieldTypePredictionsAvailable(
const std::vector<webkit_glue::FormDataPredictions>& forms); const std::vector<webkit_glue::FormDataPredictions>& forms);
// For external Autofill selection.
void OnSelectAutofillSuggestionAtIndex(int listIndex);
// Called in a posted task by textFieldDidChange() to work-around a WebKit bug // Called in a posted task by textFieldDidChange() to work-around a WebKit bug
// http://bugs.webkit.org/show_bug.cgi?id=16976 // http://bugs.webkit.org/show_bug.cgi?id=16976
void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); void TextFieldDidChangeImpl(const WebKit::WebInputElement& element);
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
'common/appcache/appcache_dispatcher.cc', 'common/appcache/appcache_dispatcher.cc',
'common/appcache/appcache_dispatcher.h', 'common/appcache/appcache_dispatcher.h',
'common/appcache_messages.h', 'common/appcache_messages.h',
'common/autofill_messages.h',
'common/child_process.cc', 'common/child_process.cc',
'common/child_process.h', 'common/child_process.h',
'common/child_process_host.cc', 'common/child_process_host.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment