summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/lib/main/webview_stubs.cc7
-rw-r--r--chrome/android/testshell/testshell_stubs.cc7
-rw-r--r--chrome/browser/autofill/autocomplete_history_manager_unittest.cc7
-rw-r--r--chrome/browser/autofill/autofill_external_delegate.cc30
-rw-r--r--chrome/browser/autofill/autofill_external_delegate.h41
-rw-r--r--chrome/browser/autofill/autofill_external_delegate_unittest.cc6
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc6
-rw-r--r--chrome/browser/autofill/test_autofill_external_delegate.cc6
-rw-r--r--chrome/browser/autofill/test_autofill_external_delegate.h3
-rw-r--r--chrome/browser/autofill/test_autofill_external_delegate_android.cc13
-rw-r--r--chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.cc25
-rw-r--r--chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h2
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents.cc11
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc15
-rw-r--r--chrome/browser/ui/views/autofill/autofill_external_delegate_views.h2
-rw-r--r--chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc15
17 files changed, 106 insertions, 92 deletions
diff --git a/android_webview/lib/main/webview_stubs.cc b/android_webview/lib/main/webview_stubs.cc
index 4a8f894..50179d2 100644
--- a/android_webview/lib/main/webview_stubs.cc
+++ b/android_webview/lib/main/webview_stubs.cc
@@ -18,13 +18,12 @@ TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
}
// static
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents* tab_contents,
- AutofillManager* manager) {
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
+ AutofillManager* autofill_manager) {
// We don't need to return a real AutofillExternalDelegate yet.
// Eventually, WebView will need an implementation (probably shared with
// Chrome).
- return NULL;
}
// static
diff --git a/chrome/android/testshell/testshell_stubs.cc b/chrome/android/testshell/testshell_stubs.cc
index 948a71f..67edc68 100644
--- a/chrome/android/testshell/testshell_stubs.cc
+++ b/chrome/android/testshell/testshell_stubs.cc
@@ -18,10 +18,9 @@ TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
}
// static
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents* tab_contents,
- AutofillManager* manager) {
- return NULL;
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
+ AutofillManager* autofill_manager) {
}
InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
diff --git a/chrome/browser/autofill/autocomplete_history_manager_unittest.cc b/chrome/browser/autofill/autocomplete_history_manager_unittest.cc
index 9cc9ade..8355e6b 100644
--- a/chrome/browser/autofill/autocomplete_history_manager_unittest.cc
+++ b/chrome/browser/autofill/autocomplete_history_manager_unittest.cc
@@ -149,8 +149,8 @@ namespace {
class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
public:
- explicit MockAutofillExternalDelegate(TabContents* tab_contents)
- : TestAutofillExternalDelegate(tab_contents, NULL) {}
+ explicit MockAutofillExternalDelegate(content::WebContents* web_contents)
+ : TestAutofillExternalDelegate(web_contents, NULL) {}
virtual ~MockAutofillExternalDelegate() {}
virtual void ApplyAutofillSuggestions(
@@ -193,8 +193,7 @@ TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
scoped_ptr<AutofillWebDataService>(
new AutofillWebDataServiceImpl(web_data_service_)));
- MockAutofillExternalDelegate external_delegate(
- TabContents::FromWebContents(contents()));
+ MockAutofillExternalDelegate external_delegate(contents());
EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
autocomplete_history_manager.SetExternalDelegate(&external_delegate);
diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc
index 109523c..933241e 100644
--- a/chrome/browser/autofill/autofill_external_delegate.cc
+++ b/chrome/browser/autofill/autofill_external_delegate.cc
@@ -18,15 +18,16 @@
using content::RenderViewHost;
using WebKit::WebAutofillClient;
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(AutofillExternalDelegate)
+
AutofillExternalDelegate::~AutofillExternalDelegate() {}
AutofillExternalDelegate::AutofillExternalDelegate(
- TabContents* tab_contents,
+ content::WebContents* web_contents,
AutofillManager* autofill_manager)
- : tab_contents_(tab_contents),
+ : web_contents_(web_contents),
autofill_manager_(autofill_manager),
- password_autofill_manager_(
- tab_contents ? tab_contents->web_contents() : NULL),
+ password_autofill_manager_(web_contents),
autofill_query_id_(0),
display_warning_if_disabled_(false),
has_shown_autofill_popup_for_current_edit_(false),
@@ -110,7 +111,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
popup_visible_ = true;
ApplyAutofillSuggestions(values, labels, icons, ids);
- AutofillManager::FromWebContents(tab_contents_->web_contents())->
+ AutofillManager::FromWebContents(web_contents_)->
OnDidShowAutofillSuggestions(
has_autofill_item && !has_shown_autofill_popup_for_current_edit_);
has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
@@ -153,8 +154,8 @@ void AutofillExternalDelegate::SetCurrentDataListValues(
}
void AutofillExternalDelegate::RemoveAutocompleteEntry(const string16& value) {
- if (tab_contents_) {
- AutocompleteHistoryManager::FromWebContents(tab_contents_->web_contents())->
+ if (web_contents_) {
+ AutocompleteHistoryManager::FromWebContents(web_contents_)->
OnRemoveAutocompleteEntry(autofill_query_field_.name, value);
}
}
@@ -179,8 +180,7 @@ bool AutofillExternalDelegate::DidAcceptAutofillSuggestions(
if (unique_id == WebAutofillClient::MenuItemIDWarningMessage)
return false;
- RenderViewHost* host =
- tab_contents_->web_contents()->GetRenderViewHost();
+ RenderViewHost* host = web_contents_->GetRenderViewHost();
if (unique_id == WebAutofillClient::MenuItemIDAutofillOptions) {
// User selected 'Autofill Options'.
@@ -211,8 +211,8 @@ bool AutofillExternalDelegate::DidAcceptAutofillSuggestions(
}
void AutofillExternalDelegate::ClearPreviewedForm() {
- if (tab_contents_ && tab_contents_->web_contents()) {
- RenderViewHost* host = tab_contents_->web_contents()->GetRenderViewHost();
+ if (web_contents_) {
+ RenderViewHost* host = web_contents_->GetRenderViewHost();
if (host)
host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
@@ -239,7 +239,7 @@ void AutofillExternalDelegate::AddPasswordFormMapping(
void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
bool is_preview) {
- RenderViewHost* host = tab_contents_->web_contents()->GetRenderViewHost();
+ RenderViewHost* host = web_contents_->GetRenderViewHost();
if (is_preview) {
host->Send(new AutofillMsg_SetAutofillActionPreview(
@@ -350,9 +350,9 @@ void AutofillExternalDelegate::InsertDataListValues(
#if defined(OS_MACOSX)
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents*, AutofillManager*) {
- return NULL;
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
+ AutofillManager* autofill_manager) {
}
#endif
diff --git a/chrome/browser/autofill/autofill_external_delegate.h b/chrome/browser/autofill/autofill_external_delegate.h
index 423860a..3d88ffb 100644
--- a/chrome/browser/autofill/autofill_external_delegate.h
+++ b/chrome/browser/autofill/autofill_external_delegate.h
@@ -14,6 +14,7 @@
#include "chrome/common/form_data.h"
#include "chrome/common/form_field_data.h"
#include "chrome/common/password_form_fill_data.h"
+#include "content/public/browser/web_contents_user_data.h"
class AutofillManager;
@@ -31,8 +32,17 @@ class WebContents;
// Delegate for external processing of Autocomplete and Autofill
// display and selection.
-class AutofillExternalDelegate {
+class AutofillExternalDelegate
+ : public content::WebContentsUserData<AutofillExternalDelegate> {
public:
+ // Creates an AutofillExternalDelegate and attaches it to the specified
+ // contents; the second argument is an AutofillManager managing Autofill for
+ // that WebContents.
+ //
+ // This call is implemented per-platform.
+ static void CreateForWebContentsAndManager(content::WebContents* web_contents,
+ AutofillManager* autofill_manager);
+
virtual ~AutofillExternalDelegate();
// When using an external Autofill delegate. Allows Chrome to tell
@@ -78,11 +88,11 @@ class AutofillExternalDelegate {
// Remove the given Autofill profile or credit credit.
virtual void RemoveAutofillProfileOrCreditCard(int unique_id);
- // Inform the delegate that the text field editing has ended, this is
+ // Inform the delegate that the text field editing has ended. This is
// used to help record the metrics of when a new popup is shown.
void DidEndTextFieldEditing();
- // Inform the delegate that an autofill suggestion have been chosen. Returns
+ // Inform the delegate that an Autofill suggestion has been chosen. Returns
// true if the suggestion was selected.
bool DidAcceptAutofillSuggestions(const string16& value,
int unique_id,
@@ -103,19 +113,14 @@ class AutofillExternalDelegate {
const FormFieldData& form,
const PasswordFormFillData& fill_data);
- // 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(TabContents*,
- AutofillManager*);
protected:
- explicit AutofillExternalDelegate(TabContents* tab_contents,
- AutofillManager* autofill_manager);
+ friend class content::WebContentsUserData<AutofillExternalDelegate>;
+ AutofillExternalDelegate(content::WebContents* web_contents,
+ AutofillManager* autofill_manager);
- // Displays the the Autofill results to the user with an external
- // Autofill popup that lives completely in the browser. The suggestions
- // have be correctly formatted by this point.
+ // Displays the Autofill results to the user with an external Autofill popup
+ // that lives completely in the browser. The suggestions have been correctly
+ // formatted by this point.
virtual void ApplyAutofillSuggestions(
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
@@ -134,11 +139,9 @@ class AutofillExternalDelegate {
// Set the bounds of the Autofill element being worked with.
virtual void SetBounds(const gfx::Rect& bounds) = 0;
- // Return the profile that this autofill delegate is currently working with.
- Profile* profile() { return tab_contents_->profile(); }
- // Return the web_contents assoicated with this delegate.
- content::WebContents* web_contents() { return tab_contents_->web_contents(); }
+ // Return the web_contents associated with this delegate.
+ content::WebContents* web_contents() { return web_contents_; }
private:
// Fills the form with the Autofill data corresponding to |unique_id|.
@@ -168,7 +171,7 @@ class AutofillExternalDelegate {
std::vector<string16>* autofill_icons,
std::vector<int>* autofill_unique_ids);
- TabContents* tab_contents_; // weak; owns me.
+ content::WebContents* web_contents_; // weak; owns me.
AutofillManager* autofill_manager_; // weak.
// Password Autofill manager, handles all password-related Autofilling.
diff --git a/chrome/browser/autofill/autofill_external_delegate_unittest.cc b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
index b0515570..116a314 100644
--- a/chrome/browser/autofill/autofill_external_delegate_unittest.cc
+++ b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
@@ -34,9 +34,9 @@ const int kAutofillProfileId = 1;
class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
public:
- MockAutofillExternalDelegate(TabContents* tab_contents,
+ MockAutofillExternalDelegate(content::WebContents* web_contents,
AutofillManager* autofill_manger)
- : TestAutofillExternalDelegate(tab_contents, autofill_manger) {}
+ : TestAutofillExternalDelegate(web_contents, autofill_manger) {}
~MockAutofillExternalDelegate() {}
MOCK_METHOD4(ApplyAutofillSuggestions, void(
@@ -93,7 +93,7 @@ class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
web_contents(),
TabAutofillManagerDelegate::FromWebContents(web_contents()));
external_delegate_.reset(new MockAutofillExternalDelegate(
- tab_contents(),
+ web_contents(),
autofill_manager_));
}
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 1452a7c..284bf9b 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -3075,9 +3075,9 @@ namespace {
class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
public:
- explicit MockAutofillExternalDelegate(TabContents* tab_contents,
+ explicit MockAutofillExternalDelegate(content::WebContents* web_contents,
AutofillManager* autofill_manager)
- : TestAutofillExternalDelegate(tab_contents, autofill_manager) {}
+ : TestAutofillExternalDelegate(web_contents, autofill_manager) {}
virtual ~MockAutofillExternalDelegate() {}
MOCK_METHOD5(OnQuery, void(int query_id,
@@ -3099,7 +3099,7 @@ class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
// Test our external delegate is called at the right time.
TEST_F(AutofillManagerTest, TestExternalDelegate) {
- MockAutofillExternalDelegate external_delegate(tab_contents(),
+ MockAutofillExternalDelegate external_delegate(web_contents(),
autofill_manager_);
EXPECT_CALL(external_delegate, OnQuery(_, _, _, _, _));
autofill_manager_->SetExternalDelegate(&external_delegate);
diff --git a/chrome/browser/autofill/test_autofill_external_delegate.cc b/chrome/browser/autofill/test_autofill_external_delegate.cc
index f5f6a74..19acdd3 100644
--- a/chrome/browser/autofill/test_autofill_external_delegate.cc
+++ b/chrome/browser/autofill/test_autofill_external_delegate.cc
@@ -5,8 +5,10 @@
#include "chrome/browser/autofill/test_autofill_external_delegate.h"
TestAutofillExternalDelegate::TestAutofillExternalDelegate(
- TabContents* tab_contents, AutofillManager* autofill_manager) :
- AutofillExternalDelegate(tab_contents, autofill_manager) {}
+ content::WebContents* web_contents,
+ AutofillManager* autofill_manager)
+ : AutofillExternalDelegate(web_contents, autofill_manager) {
+}
TestAutofillExternalDelegate::~TestAutofillExternalDelegate() {}
diff --git a/chrome/browser/autofill/test_autofill_external_delegate.h b/chrome/browser/autofill/test_autofill_external_delegate.h
index f06b3f9..1fa7ac3 100644
--- a/chrome/browser/autofill/test_autofill_external_delegate.h
+++ b/chrome/browser/autofill/test_autofill_external_delegate.h
@@ -8,14 +8,13 @@
#include "chrome/browser/autofill/autofill_external_delegate.h"
class AutofillManager;
-class TabContents;
// This test class is meant to give tests a base AutofillExternalDelegate
// class that requires no additional work to compile with (i.e. all the
// pure virtual functions have been giving empty methods).
class TestAutofillExternalDelegate : public AutofillExternalDelegate {
public:
- TestAutofillExternalDelegate(TabContents* tab_contents,
+ TestAutofillExternalDelegate(content::WebContents* web_contents,
AutofillManager* autofill_manager);
virtual ~TestAutofillExternalDelegate();
diff --git a/chrome/browser/autofill/test_autofill_external_delegate_android.cc b/chrome/browser/autofill/test_autofill_external_delegate_android.cc
index d50b1f1..972f021 100644
--- a/chrome/browser/autofill/test_autofill_external_delegate_android.cc
+++ b/chrome/browser/autofill/test_autofill_external_delegate_android.cc
@@ -4,8 +4,13 @@
#include "chrome/browser/autofill/test_autofill_external_delegate.h"
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents* tab_contents,
- AutofillManager* manager) {
- return new TestAutofillExternalDelegate(tab_contents, manager);
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
+ AutofillManager* autofill_manager) {
+ if (FromWebContents(web_contents))
+ return;
+
+ web_contents->SetUserData(
+ &kLocatorKey,
+ new TestAutofillExternalDelegate(web_contents, autofill_manager));
}
diff --git a/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.cc b/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.cc
index 4323414..17c3a38 100644
--- a/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.cc
+++ b/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.cc
@@ -4,24 +4,29 @@
#include "chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents* tab_contents,
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
AutofillManager* autofill_manager) {
- return new AutofillExternalDelegateGtk(tab_contents, autofill_manager);
+ if (FromWebContents(web_contents))
+ return;
+
+ web_contents->SetUserData(
+ &kLocatorKey,
+ new AutofillExternalDelegateGtk(web_contents, autofill_manager));
}
AutofillExternalDelegateGtk::AutofillExternalDelegateGtk(
- TabContents* tab_contents,
+ content::WebContents* web_contents,
AutofillManager* autofill_manager)
- : AutofillExternalDelegate(tab_contents, autofill_manager),
+ : AutofillExternalDelegate(web_contents, autofill_manager),
event_handler_id_(0) {
- tab_native_view_ = web_contents()->GetView()->GetNativeView();
+ tab_native_view_ = web_contents->GetView()->GetNativeView();
}
AutofillExternalDelegateGtk::~AutofillExternalDelegateGtk() {
@@ -67,8 +72,10 @@ void AutofillExternalDelegateGtk::CreateViewIfNeeded() {
if (view_.get())
return;
- view_.reset(new AutofillPopupViewGtk(web_contents(),
- GtkThemeService::GetFrom(profile()),
+ content::WebContents* contents = web_contents();
+ Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
+ view_.reset(new AutofillPopupViewGtk(contents,
+ GtkThemeService::GetFrom(profile),
this,
tab_native_view_));
diff --git a/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h b/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h
index 0425fa9..5eff5f9 100644
--- a/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h
+++ b/chrome/browser/ui/gtk/autofill/autofill_external_delegate_gtk.h
@@ -16,7 +16,7 @@ class AutofillPopupViewGtk;
class AutofillExternalDelegateGtk : public AutofillExternalDelegate {
public:
- AutofillExternalDelegateGtk(TabContents* tab_contents,
+ AutofillExternalDelegateGtk(content::WebContents* web_contents,
AutofillManager* autofill_manager);
virtual ~AutofillExternalDelegateGtk();
diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc
index 1ec0697..e6c0a53 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents.cc
@@ -116,16 +116,15 @@ TabContents::TabContents(WebContents* contents)
AutocompleteHistoryManager::CreateForWebContents(contents);
TabAutofillManagerDelegate::CreateForWebContents(contents);
AutofillManager::CreateForWebContentsAndDelegate(
- contents,
- TabAutofillManagerDelegate::FromWebContents(contents));
+ contents, TabAutofillManagerDelegate::FromWebContents(contents));
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExternalAutofillPopup)) {
- autofill_external_delegate_.reset(AutofillExternalDelegate::Create(
- this, AutofillManager::FromWebContents(contents)));
+ AutofillExternalDelegate::CreateForWebContentsAndManager(
+ contents, AutofillManager::FromWebContents(contents));
AutofillManager::FromWebContents(contents)->SetExternalDelegate(
- autofill_external_delegate_.get());
+ AutofillExternalDelegate::FromWebContents(contents));
AutocompleteHistoryManager::FromWebContents(contents)->SetExternalDelegate(
- autofill_external_delegate_.get());
+ AutofillExternalDelegate::FromWebContents(contents));
}
BlockedContentTabHelper::CreateForWebContents(contents);
BookmarkTabHelper::CreateForWebContents(contents);
diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h
index 42ceae3..ba1bb1e 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.h
+++ b/chrome/browser/ui/tab_contents/tab_contents.h
@@ -11,7 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/web_contents_observer.h"
-class AutofillExternalDelegate;
class BasePanelBrowserTest;
class Browser;
class BrowserCommandsTabContentsCreator;
@@ -158,7 +157,6 @@ class TabContents : public content::WebContentsObserver {
// (These provide API for callers and have a getter function listed in the
// "Tab Helpers" section in the member functions area, above.)
- scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_;
scoped_ptr<InfoBarTabHelper> infobar_tab_helper_;
// WebContents (MUST BE LAST) ------------------------------------------------
diff --git a/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc
index 0685399..f040feb 100644
--- a/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc
@@ -6,16 +6,21 @@
#include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
-AutofillExternalDelegate* AutofillExternalDelegate::Create(
- TabContents* tab_contents,
+void AutofillExternalDelegate::CreateForWebContentsAndManager(
+ content::WebContents* web_contents,
AutofillManager* autofill_manager) {
- return new AutofillExternalDelegateViews(tab_contents, autofill_manager);
+ if (FromWebContents(web_contents))
+ return;
+
+ web_contents->SetUserData(
+ &kLocatorKey,
+ new AutofillExternalDelegateViews(web_contents, autofill_manager));
}
AutofillExternalDelegateViews::AutofillExternalDelegateViews(
- TabContents* tab_contents,
+ content::WebContents* web_contents,
AutofillManager* autofill_manager)
- : AutofillExternalDelegate(tab_contents, autofill_manager),
+ : AutofillExternalDelegate(web_contents, autofill_manager),
popup_view_(NULL) {
}
diff --git a/chrome/browser/ui/views/autofill/autofill_external_delegate_views.h b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.h
index 9628571..dacda4b 100644
--- a/chrome/browser/ui/views/autofill/autofill_external_delegate_views.h
+++ b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.h
@@ -16,7 +16,7 @@ class AutofillPopupViewViews;
// selection and the popup that shows the values.
class AutofillExternalDelegateViews : public AutofillExternalDelegate {
public:
- AutofillExternalDelegateViews(TabContents* tab_contents,
+ AutofillExternalDelegateViews(content::WebContents* web_contents,
AutofillManager* autofill_manager);
virtual ~AutofillExternalDelegateViews();
diff --git a/chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc b/chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc
index be56a02..5b3fa0d 100644
--- a/chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc
+++ b/chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ui/views/autofill/autofill_external_delegate_views.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -17,9 +16,9 @@ namespace {
class MockAutofillExternalDelegateViews : public AutofillExternalDelegateViews {
public:
- explicit MockAutofillExternalDelegateViews(TabContents* tab_contents) :
- AutofillExternalDelegateViews(tab_contents, NULL),
- popup_hidden_(false) {}
+ explicit MockAutofillExternalDelegateViews(content::WebContents* web_contents)
+ : AutofillExternalDelegateViews(web_contents, NULL),
+ popup_hidden_(false) {}
~MockAutofillExternalDelegateViews() {}
void HideAutofillPopupInternal() OVERRIDE {
@@ -42,11 +41,11 @@ class AutofillExternalDelegateViewsBrowserTest : public InProcessBrowserTest {
virtual ~AutofillExternalDelegateViewsBrowserTest() {}
virtual void SetUpOnMainThread() OVERRIDE {
- tab_contents_ = chrome::GetActiveTabContents(browser());
- ASSERT_TRUE(tab_contents_ != NULL);
+ web_contents_ = chrome::GetActiveWebContents(browser());
+ ASSERT_TRUE(web_contents_ != NULL);
autofill_external_delegate_.reset(
- new MockAutofillExternalDelegateViews(tab_contents_));
+ new MockAutofillExternalDelegateViews(web_contents_));
}
void GeneratePopup() {
@@ -70,7 +69,7 @@ class AutofillExternalDelegateViewsBrowserTest : public InProcessBrowserTest {
}
protected:
- TabContents* tab_contents_;
+ content::WebContents* web_contents_;
scoped_ptr<MockAutofillExternalDelegateViews> autofill_external_delegate_;
};