diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 00:51:04 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 00:51:04 +0000 |
commit | 3fd040071e5049e06953031ab98644ac26734a86 (patch) | |
tree | cd4bf7a48cbfaebe2e70b469c350ff9981f2ba01 | |
parent | e8cdf3530e9b892f63a25e6366af15e146260dcd (diff) | |
download | chromium_src-3fd040071e5049e06953031ab98644ac26734a86.zip chromium_src-3fd040071e5049e06953031ab98644ac26734a86.tar.gz chromium_src-3fd040071e5049e06953031ab98644ac26734a86.tar.bz2 |
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
-rw-r--r-- | chrome/browser/autocomplete_history_manager.cc | 13 | ||||
-rw-r--r-- | chrome/browser/autocomplete_history_manager.h | 18 | ||||
-rw-r--r-- | chrome/browser/autocomplete_history_manager_unittest.cc | 53 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_external_delegate.cc | 37 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_external_delegate.h | 64 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 10 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 27 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager_unittest.cc | 69 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents_wrapper.h | 2 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/autofill_messages.h | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.h | 3 | ||||
-rw-r--r-- | content/content_common.gypi | 1 |
17 files changed, 322 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc index 7ba40f0..ea4e399 100644 --- a/chrome/browser/autocomplete_history_manager.cc +++ b/chrome/browser/autocomplete_history_manager.cc @@ -9,6 +9,7 @@ #include "base/string16.h" #include "base/string_number_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/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -102,7 +103,8 @@ AutocompleteHistoryManager::AutocompleteHistoryManager( TabContents* tab_contents) : TabContentsObserver(tab_contents), pending_query_handle_(0), - query_id_(0) { + query_id_(0), + external_delegate_(NULL) { profile_ = Profile::FromBrowserContext(tab_contents->browser_context()); // May be NULL in unit tests. web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); @@ -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(), query_id_, autofill_values_, diff --git a/chrome/browser/autocomplete_history_manager.h b/chrome/browser/autocomplete_history_manager.h index 4f8b8f3..f3923d2 100644 --- a/chrome/browser/autocomplete_history_manager.h +++ b/chrome/browser/autocomplete_history_manager.h @@ -8,6 +8,7 @@ #include <vector> +#include "base/gtest_prod_util.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/webdata/web_data_service.h" #include "content/browser/tab_contents/tab_contents_observer.h" @@ -16,6 +17,7 @@ namespace webkit_glue { struct FormData; } // namespace webkit_glue +class AutofillExternalDelegate; class Profile; class TabContents; @@ -46,9 +48,16 @@ class AutocompleteHistoryManager : public TabContentsObserver, const std::vector<int>& autofill_unique_ids); void OnFormSubmitted(const webkit_glue::FormData& form); + // Sets our external delegate. + void SetExternalDelegate(AutofillExternalDelegate* delegate) { + external_delegate_ = delegate; + } + protected: friend class AutocompleteHistoryManagerTest; friend class AutofillManagerTest; + FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate); + FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestTabContents); // For tests. AutocompleteHistoryManager(TabContents* tab_contents, @@ -58,6 +67,11 @@ class AutocompleteHistoryManager : public TabContentsObserver, void SendSuggestions(const std::vector<string16>* suggestions); void CancelPendingQuery(); + // Exposed for testing. + AutofillExternalDelegate* external_delegate() { + return external_delegate_; + } + private: void OnRemoveAutocompleteEntry(const string16& name, const string16& value); @@ -76,6 +90,10 @@ class AutocompleteHistoryManager : public TabContentsObserver, std::vector<string16> autofill_icons_; 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); }; diff --git a/chrome/browser/autocomplete_history_manager_unittest.cc b/chrome/browser/autocomplete_history_manager_unittest.cc index 0267142..df255f2 100644 --- a/chrome/browser/autocomplete_history_manager_unittest.cc +++ b/chrome/browser/autocomplete_history_manager_unittest.cc @@ -9,6 +9,8 @@ #include "base/task.h" #include "base/utf_string_conversions.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/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_browser_process.h" @@ -132,3 +134,54 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) { EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); 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); +} + diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc new file mode 100644 index 0000000..457f86d --- /dev/null +++ b/chrome/browser/autofill/autofill_external_delegate.cc @@ -0,0 +1,37 @@ +// 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 diff --git a/chrome/browser/autofill/autofill_external_delegate.h b/chrome/browser/autofill/autofill_external_delegate.h new file mode 100644 index 0000000..7a88c98 --- /dev/null +++ b/chrome/browser/autofill/autofill_external_delegate.h @@ -0,0 +1,64 @@ +// 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_ diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 0bc082a..9b8ec0b 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -19,6 +19,7 @@ #include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autofill/autofill_cc_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_metrics.h" #include "chrome/browser/autofill/autofill_profile.h" @@ -216,7 +217,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) did_show_suggestions_(false), user_did_type_(false), user_did_autofill_(false), - user_did_edit_autofilled_field_(false) { + user_did_edit_autofilled_field_(false), + external_delegate_(NULL) { DCHECK(tab_contents); // |personal_data_| is NULL when using TestTabContents. @@ -380,6 +382,9 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, std::vector<string16> icons; std::vector<int> unique_ids; + if (external_delegate_) + external_delegate_->OnQuery(query_id, form, field); + RenderViewHost* host = NULL; FormStructure* form_structure = NULL; AutofillField* autofill_field = NULL; @@ -733,7 +738,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, did_show_suggestions_(false), user_did_type_(false), user_did_autofill_(false), - user_did_edit_autofilled_field_(false) { + user_did_edit_autofilled_field_(false), + external_delegate_(NULL) { DCHECK(tab_contents); } diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index e4fd014..f81e964 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -23,6 +23,7 @@ #include "chrome/browser/autofill/form_structure.h" #include "content/browser/tab_contents/tab_contents_observer.h" +class AutofillExternalDelegate; class AutofillField; class AutofillProfile; class AutofillMetrics; @@ -54,6 +55,14 @@ class AutofillManager : public TabContentsObserver, // Registers our Enable/Disable Autofill pref. 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: // Only test code should subclass AutofillManager. @@ -90,6 +99,17 @@ class AutofillManager : public TabContentsObserver, 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: // TabContentsObserver: virtual void DidNavigateMainFramePostCommit( @@ -268,6 +288,10 @@ class AutofillManager : public TabContentsObserver, mutable std::map<GUIDPair, int> guid_id_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 FormStructureBrowserTest; FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, @@ -282,6 +306,9 @@ class AutofillManager : public TabContentsObserver, FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); + FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestExternalDelegate); + FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, + TestTabContentsWithExternalDelegate); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormLoadAndSubmission); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index e9d1720..7c777b5 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -4,6 +4,7 @@ #include <vector> +#include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/string16.h" @@ -14,6 +15,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete_history_manager.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_profile.h" #include "chrome/browser/autofill/credit_card.h" @@ -25,6 +27,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/autofill_messages.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/tab_contents/test_tab_contents.h" @@ -38,6 +41,7 @@ #include "webkit/glue/form_data.h" #include "webkit/glue/form_field.h" +using testing::_; using webkit_glue::FormData; using webkit_glue::FormField; @@ -2834,3 +2838,68 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUploadStressTest) { EXPECT_TRUE(possible_types2.find(UNKNOWN_TYPE) != 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 diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index de074c1..78843dc 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -6,9 +6,11 @@ #include "base/utf_string_conversions.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/stringprintf.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/automation/automation_tab_helper.h" #include "chrome/browser/browser_process.h" @@ -246,6 +248,14 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) // Create the tab helpers. autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); 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)); blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index d5c935b..09fe200 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -20,6 +20,7 @@ class AutocompleteHistoryManager; class AutofillManager; +class AutofillExternalDelegate; class AutomationTabHelper; class BlockedContentTabHelper; class BookmarkTabHelper; @@ -274,6 +275,7 @@ class TabContentsWrapper : public TabContentsObserver, scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; scoped_ptr<AutofillManager> autofill_manager_; + scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; scoped_ptr<AutomationTabHelper> automation_tab_helper_; scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6d53b5b..ec8ed64 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -138,6 +138,8 @@ 'browser/autofill/autofill_country.h', 'browser/autofill/autofill_download.cc', '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.h', 'browser/autofill/autofill_field.cc', diff --git a/chrome/common/autofill_messages.h b/chrome/common/autofill_messages.h index 3bccb6d..c5a1ddd 100644 --- a/chrome/common/autofill_messages.h +++ b/chrome/common/autofill_messages.h @@ -88,6 +88,10 @@ IPC_MESSAGE_ROUTED1( AutofillMsg_FieldTypePredictionsAvailable, 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. // Notification that forms have been seen that are candidates for diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 24611b8..06c120b 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -589,6 +589,9 @@ const char kExtensionProcess[] = "extension-process"; // Frequency in seconds for Extensions auto-update. 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 // command line. This is useful to see which switches were added by about:flags // on about:version. They don't have any effect. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 212c369..19a09d8 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -169,6 +169,7 @@ extern const char kExperimentalSpellcheckerFeatures[]; extern const char kExplicitlyAllowedPorts[]; extern const char kExtensionProcess[]; extern const char kExtensionsUpdateFrequency[]; +extern const char kExternalAutofillPopup[]; extern const char kFlagSwitchesBegin[]; extern const char kFlagSwitchesEnd[]; extern const char kFeedbackServer[]; diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc index cd94919..91d3fd1 100644 --- a/chrome/renderer/autofill/autofill_agent.cc +++ b/chrome/renderer/autofill/autofill_agent.cc @@ -72,6 +72,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, OnFieldTypePredictionsAvailable) + IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex, + OnSelectAutofillSuggestionAtIndex) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -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, bool autofill_on_empty_values, bool requires_caret_at_end, diff --git a/chrome/renderer/autofill/autofill_agent.h b/chrome/renderer/autofill/autofill_agent.h index 0fa29dd..b7e4fb4 100644 --- a/chrome/renderer/autofill/autofill_agent.h +++ b/chrome/renderer/autofill/autofill_agent.h @@ -100,6 +100,9 @@ class AutofillAgent : public content::RenderViewObserver, void OnFieldTypePredictionsAvailable( 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 // http://bugs.webkit.org/show_bug.cgi?id=16976 void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); diff --git a/content/content_common.gypi b/content/content_common.gypi index 832f636..1a276bb 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -62,6 +62,7 @@ 'common/appcache/appcache_dispatcher.cc', 'common/appcache/appcache_dispatcher.h', 'common/appcache_messages.h', + 'common/autofill_messages.h', 'common/child_process.cc', 'common/child_process.h', 'common/child_process_host.cc', |