diff options
62 files changed, 629 insertions, 671 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwAutofillManagerDelegate.java b/android_webview/java/src/org/chromium/android_webview/AwAutofillClient.java index 286d8c1..840f6d8 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwAutofillManagerDelegate.java +++ b/android_webview/java/src/org/chromium/android_webview/AwAutofillClient.java @@ -1,4 +1,4 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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. @@ -13,24 +13,24 @@ import org.chromium.ui.autofill.AutofillPopup; import org.chromium.ui.autofill.AutofillSuggestion; /** - * Java counterpart to the AwAutofillManagerDelegate. This class is owned by AwContents and has + * Java counterpart to the AwAutofillClient. This class is owned by AwContents and has * a weak reference from native side. */ @JNINamespace("android_webview") -public class AwAutofillManagerDelegate { +public class AwAutofillClient { - private final long mNativeAwAutofillManagerDelegate; + private final long mNativeAwAutofillClient; private AutofillPopup mAutofillPopup; private ViewGroup mContainerView; private ContentViewCore mContentViewCore; @CalledByNative - public static AwAutofillManagerDelegate create(long nativeDelegate) { - return new AwAutofillManagerDelegate(nativeDelegate); + public static AwAutofillClient create(long nativeClient) { + return new AwAutofillClient(nativeClient); } - private AwAutofillManagerDelegate(long nativeAwAutofillManagerDelegate) { - mNativeAwAutofillManagerDelegate = nativeAwAutofillManagerDelegate; + private AwAutofillClient(long nativeAwAutofillClient) { + mNativeAwAutofillClient = nativeAwAutofillClient; } public void init(ContentViewCore contentViewCore) { @@ -53,7 +53,7 @@ public class AwAutofillManagerDelegate { public void requestHide() { } @Override public void suggestionSelected(int listIndex) { - nativeSuggestionSelected(mNativeAwAutofillManagerDelegate, listIndex); + nativeSuggestionSelected(mNativeAwAutofillClient, listIndex); } }); } @@ -87,6 +87,6 @@ public class AwAutofillManagerDelegate { array[index] = new AutofillSuggestion(name, label, uniqueId); } - private native void nativeSuggestionSelected(long nativeAwAutofillManagerDelegate, + private native void nativeSuggestionSelected(long nativeAwAutofillClient, int position); } diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 3d2282f..d43b0bf 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -215,7 +215,7 @@ public class AwContents { private float mContentWidthDip; private float mContentHeightDip; - private AwAutofillManagerDelegate mAwAutofillManagerDelegate; + private AwAutofillClient mAwAutofillClient; private ComponentCallbacks2 mComponentCallbacks; @@ -1796,8 +1796,8 @@ public class AwContents { * @see android.webkit.WebView#clearFormData() */ public void hideAutofillPopup() { - if (mAwAutofillManagerDelegate != null) { - mAwAutofillManagerDelegate.hideAutofillPopup(); + if (mAwAutofillClient != null) { + mAwAutofillClient.hideAutofillPopup(); } } @@ -1978,9 +1978,9 @@ public class AwContents { } @CalledByNative - private void setAwAutofillManagerDelegate(AwAutofillManagerDelegate delegate) { - mAwAutofillManagerDelegate = delegate; - delegate.init(mContentViewCore); + private void setAwAutofillClient(AwAutofillClient client) { + mAwAutofillClient = client; + client.init(mContentViewCore); } @CalledByNative diff --git a/android_webview/native/android_webview_jni_registrar.cc b/android_webview/native/android_webview_jni_registrar.cc index d219810..3f2e85b 100644 --- a/android_webview/native/android_webview_jni_registrar.cc +++ b/android_webview/native/android_webview_jni_registrar.cc @@ -5,7 +5,7 @@ #include "android_webview/native/android_webview_jni_registrar.h" #include "android_webview/native/android_protocol_handler.h" -#include "android_webview/native/aw_autofill_manager_delegate.h" +#include "android_webview/native/aw_autofill_client.h" #include "android_webview/native/aw_contents.h" #include "android_webview/native/aw_contents_client_bridge.h" #include "android_webview/native/aw_contents_io_thread_client_impl.h" @@ -34,7 +34,7 @@ namespace android_webview { static base::android::RegistrationMethod kWebViewRegisteredMethods[] = { // Register JNI for android_webview classes. { "AndroidProtocolHandler", RegisterAndroidProtocolHandler }, - { "AwAutofillManagerDelegate", RegisterAwAutofillManagerDelegate }, + { "AwAutofillClient", RegisterAwAutofillClient }, { "AwContents", RegisterAwContents }, { "AwContentsClientBridge", RegisterAwContentsClientBridge }, { "AwContentsIoThreadClientImpl", RegisterAwContentsIoThreadClientImpl }, diff --git a/android_webview/native/aw_autofill_manager_delegate.cc b/android_webview/native/aw_autofill_client.cc index 93e04be..20ee46e 100644 --- a/android_webview/native/aw_autofill_manager_delegate.cc +++ b/android_webview/native/aw_autofill_client.cc @@ -1,8 +1,8 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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 "android_webview/native/aw_autofill_manager_delegate.h" +#include "android_webview/native/aw_autofill_client.h" #include "android_webview/browser/aw_browser_context.h" #include "android_webview/browser/aw_content_browser_client.h" @@ -21,14 +21,14 @@ #include "components/autofill/core/common/autofill_pref_names.h" #include "components/user_prefs/user_prefs.h" #include "content/public/browser/web_contents.h" -#include "jni/AwAutofillManagerDelegate_jni.h" +#include "jni/AwAutofillClient_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF16ToJavaString; using base::android::ScopedJavaLocalRef; using content::WebContents; -DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillManagerDelegate); +DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); namespace android_webview { @@ -36,51 +36,48 @@ namespace android_webview { // AwContents. The native object creates the java peer which handles most // autofill functionality at the java side. The java peer is owned by Java // AwContents. The native object only maintains a weak ref to it. -AwAutofillManagerDelegate::AwAutofillManagerDelegate(WebContents* contents) - : web_contents_(contents), - save_form_data_(false) { +AwAutofillClient::AwAutofillClient(WebContents* contents) + : web_contents_(contents), save_form_data_(false) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> delegate; delegate.Reset( - Java_AwAutofillManagerDelegate_create( - env, reinterpret_cast<intptr_t>(this))); + Java_AwAutofillClient_create(env, reinterpret_cast<intptr_t>(this))); AwContents* aw_contents = AwContents::FromWebContents(web_contents_); - aw_contents->SetAwAutofillManagerDelegate(delegate.obj()); + aw_contents->SetAwAutofillClient(delegate.obj()); java_ref_ = JavaObjectWeakGlobalRef(env, delegate.obj()); } -AwAutofillManagerDelegate::~AwAutofillManagerDelegate() { +AwAutofillClient::~AwAutofillClient() { HideAutofillPopup(); } -void AwAutofillManagerDelegate::SetSaveFormData(bool enabled) { +void AwAutofillClient::SetSaveFormData(bool enabled) { save_form_data_ = enabled; } -bool AwAutofillManagerDelegate::GetSaveFormData() { +bool AwAutofillClient::GetSaveFormData() { return save_form_data_; } -PrefService* AwAutofillManagerDelegate::GetPrefs() { +PrefService* AwAutofillClient::GetPrefs() { return user_prefs::UserPrefs::Get( AwContentBrowserClient::GetAwBrowserContext()); } -autofill::PersonalDataManager* -AwAutofillManagerDelegate::GetPersonalDataManager() { +autofill::PersonalDataManager* AwAutofillClient::GetPersonalDataManager() { return NULL; } scoped_refptr<autofill::AutofillWebDataService> -AwAutofillManagerDelegate::GetDatabase() { +AwAutofillClient::GetDatabase() { android_webview::AwFormDatabaseService* service = static_cast<android_webview::AwBrowserContext*>( web_contents_->GetBrowserContext())->GetFormDatabaseService(); return service->get_autofill_webdata_service(); } -void AwAutofillManagerDelegate::ShowAutofillPopup( +void AwAutofillClient::ShowAutofillPopup( const gfx::RectF& element_bounds, base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, @@ -88,7 +85,6 @@ void AwAutofillManagerDelegate::ShowAutofillPopup( const std::vector<base::string16>& icons, const std::vector<int>& identifiers, base::WeakPtr<autofill::AutofillPopupDelegate> delegate) { - values_ = values; identifiers_ = identifiers; delegate_ = delegate; @@ -98,13 +94,11 @@ void AwAutofillManagerDelegate::ShowAutofillPopup( gfx::RectF element_bounds_in_screen_space = element_bounds + client_area.OffsetFromOrigin(); - ShowAutofillPopupImpl(element_bounds_in_screen_space, - values, - labels, - identifiers); + ShowAutofillPopupImpl( + element_bounds_in_screen_space, values, labels, identifiers); } -void AwAutofillManagerDelegate::ShowAutofillPopupImpl( +void AwAutofillClient::ShowAutofillPopupImpl( const gfx::RectF& element_bounds, const std::vector<base::string16>& values, const std::vector<base::string16>& labels, @@ -118,30 +112,26 @@ void AwAutofillManagerDelegate::ShowAutofillPopupImpl( size_t count = values.size(); ScopedJavaLocalRef<jobjectArray> data_array = - Java_AwAutofillManagerDelegate_createAutofillSuggestionArray(env, count); + Java_AwAutofillClient_createAutofillSuggestionArray(env, count); for (size_t i = 0; i < count; ++i) { ScopedJavaLocalRef<jstring> name = ConvertUTF16ToJavaString(env, values[i]); ScopedJavaLocalRef<jstring> label = ConvertUTF16ToJavaString(env, labels[i]); - Java_AwAutofillManagerDelegate_addToAutofillSuggestionArray( - env, - data_array.obj(), - i, - name.obj(), - label.obj(), - identifiers[i]); + Java_AwAutofillClient_addToAutofillSuggestionArray( + env, data_array.obj(), i, name.obj(), label.obj(), identifiers[i]); } - Java_AwAutofillManagerDelegate_showAutofillPopup( - env, - obj.obj(), - element_bounds.x(), - element_bounds.y(), element_bounds.width(), - element_bounds.height(), data_array.obj()); + Java_AwAutofillClient_showAutofillPopup(env, + obj.obj(), + element_bounds.x(), + element_bounds.y(), + element_bounds.width(), + element_bounds.height(), + data_array.obj()); } -void AwAutofillManagerDelegate::UpdateAutofillPopupDataListValues( +void AwAutofillClient::UpdateAutofillPopupDataListValues( const std::vector<base::string16>& values, const std::vector<base::string16>& labels) { // Leaving as an empty method since updating autofill popup window @@ -149,56 +139,58 @@ void AwAutofillManagerDelegate::UpdateAutofillPopupDataListValues( // See crrev.com/18102002 if need to implement. } -void AwAutofillManagerDelegate::HideAutofillPopup() { +void AwAutofillClient::HideAutofillPopup() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) return; delegate_.reset(); - Java_AwAutofillManagerDelegate_hideAutofillPopup(env, obj.obj()); + Java_AwAutofillClient_hideAutofillPopup(env, obj.obj()); } -bool AwAutofillManagerDelegate::IsAutocompleteEnabled() { +bool AwAutofillClient::IsAutocompleteEnabled() { return GetSaveFormData(); } -void AwAutofillManagerDelegate::DetectAccountCreationForms( - const std::vector<autofill::FormStructure*>& forms) {} +void AwAutofillClient::DetectAccountCreationForms( + const std::vector<autofill::FormStructure*>& forms) { +} -void AwAutofillManagerDelegate::DidFillOrPreviewField( +void AwAutofillClient::DidFillOrPreviewField( const base::string16& autofilled_value, - const base::string16& profile_full_name) {} + const base::string16& profile_full_name) { +} -void AwAutofillManagerDelegate::SuggestionSelected(JNIEnv* env, - jobject object, - jint position) { +void AwAutofillClient::SuggestionSelected(JNIEnv* env, + jobject object, + jint position) { if (delegate_) delegate_->DidAcceptSuggestion(values_[position], identifiers_[position]); } -void AwAutofillManagerDelegate::HideRequestAutocompleteDialog() { +void AwAutofillClient::HideRequestAutocompleteDialog() { NOTIMPLEMENTED(); } -void AwAutofillManagerDelegate::ShowAutofillSettings() { +void AwAutofillClient::ShowAutofillSettings() { NOTIMPLEMENTED(); } -void AwAutofillManagerDelegate::ConfirmSaveCreditCard( +void AwAutofillClient::ConfirmSaveCreditCard( const autofill::AutofillMetrics& metric_logger, const base::Closure& save_card_callback) { NOTIMPLEMENTED(); } -void AwAutofillManagerDelegate::ShowRequestAutocompleteDialog( +void AwAutofillClient::ShowRequestAutocompleteDialog( const autofill::FormData& form, const GURL& source_url, const ResultCallback& callback) { NOTIMPLEMENTED(); } -bool RegisterAwAutofillManagerDelegate(JNIEnv* env) { +bool RegisterAwAutofillClient(JNIEnv* env) { return RegisterNativesImpl(env); } -} // namespace android_webview +} // namespace android_webview diff --git a/android_webview/native/aw_autofill_manager_delegate.h b/android_webview/native/aw_autofill_client.h index 159ff08..4e1de75 100644 --- a/android_webview/native/aw_autofill_manager_delegate.h +++ b/android_webview/native/aw_autofill_client.h @@ -1,9 +1,9 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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 ANDROID_WEBVIEW_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ -#define ANDROID_WEBVIEW_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ +#ifndef ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ +#define ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ #include <jni.h> #include <vector> @@ -13,7 +13,7 @@ #include "base/compiler_specific.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service_factory.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "content/public/browser/web_contents_user_data.h" namespace autofill { @@ -46,20 +46,18 @@ namespace android_webview { // context, we cannot enable this feature via UserPrefs. Rather, we always // keep the feature enabled at the pref service, and control it via // the delegates. -class AwAutofillManagerDelegate - : public autofill::AutofillManagerDelegate, - public content::WebContentsUserData<AwAutofillManagerDelegate> { - +class AwAutofillClient : public autofill::AutofillClient, + public content::WebContentsUserData<AwAutofillClient> { public: - virtual ~AwAutofillManagerDelegate(); + virtual ~AwAutofillClient(); void SetSaveFormData(bool enabled); bool GetSaveFormData(); - // AutofillManagerDelegate implementation. + // AutofillClient: virtual autofill::PersonalDataManager* GetPersonalDataManager() OVERRIDE; - virtual scoped_refptr<autofill::AutofillWebDataService> - GetDatabase() OVERRIDE; + virtual scoped_refptr<autofill::AutofillWebDataService> GetDatabase() + OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; virtual void HideRequestAutocompleteDialog() OVERRIDE; virtual void ShowAutofillSettings() OVERRIDE; @@ -69,8 +67,7 @@ class AwAutofillManagerDelegate virtual void ShowRequestAutocompleteDialog( const autofill::FormData& form, const GURL& source_url, - const ResultCallback& callback) - OVERRIDE; + const ResultCallback& callback) OVERRIDE; virtual void ShowAutofillPopup( const gfx::RectF& element_bounds, base::i18n::TextDirection text_direction, @@ -90,12 +87,11 @@ class AwAutofillManagerDelegate const base::string16& autofilled_value, const base::string16& profile_full_name) OVERRIDE; - void SuggestionSelected(JNIEnv* env, - jobject obj, - jint position); + void SuggestionSelected(JNIEnv* env, jobject obj, jint position); + private: - AwAutofillManagerDelegate(content::WebContents* web_contents); - friend class content::WebContentsUserData<AwAutofillManagerDelegate>; + AwAutofillClient(content::WebContents* web_contents); + friend class content::WebContentsUserData<AwAutofillClient>; void ShowAutofillPopupImpl(const gfx::RectF& element_bounds, const std::vector<base::string16>& values, @@ -112,11 +108,11 @@ class AwAutofillManagerDelegate std::vector<int> identifiers_; base::WeakPtr<autofill::AutofillPopupDelegate> delegate_; - DISALLOW_COPY_AND_ASSIGN(AwAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(AwAutofillClient); }; -bool RegisterAwAutofillManagerDelegate(JNIEnv* env); +bool RegisterAwAutofillClient(JNIEnv* env); } // namespace android_webview -#endif // ANDROID_WEBVIEW_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ +#endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 18ff50f..f712354 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -20,7 +20,7 @@ #include "android_webview/common/aw_hit_test_data.h" #include "android_webview/common/aw_switches.h" #include "android_webview/common/devtools_instrumentation.h" -#include "android_webview/native/aw_autofill_manager_delegate.h" +#include "android_webview/native/aw_autofill_client.h" #include "android_webview/native/aw_browser_dependency_factory.h" #include "android_webview/native/aw_contents_client_bridge.h" #include "android_webview/native/aw_contents_io_thread_client_impl.h" @@ -174,8 +174,8 @@ AwContents::AwContents(scoped_ptr<WebContents> web_contents) permission_request_handler_.reset( new PermissionRequestHandler(this, web_contents_.get())); - AwAutofillManagerDelegate* autofill_manager_delegate = - AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); + AwAutofillClient* autofill_manager_delegate = + AwAutofillClient::FromWebContents(web_contents_.get()); InitDataReductionProxyIfNecessary(); if (autofill_manager_delegate) InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); @@ -220,7 +220,7 @@ void AwContents::SetSaveFormData(bool enabled) { // We need to check for the existence, since autofill_manager_delegate // may not be created when the setting is false. if (ContentAutofillDriver::FromWebContents(web_contents_.get())) { - AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> + AwAutofillClient::FromWebContents(web_contents_.get())-> SetSaveFormData(enabled); } } @@ -242,21 +242,21 @@ void AwContents::InitAutofillIfNecessary(bool enabled) { AwBrowserContext::FromWebContents(web_contents)-> CreateUserPrefServiceIfNecessary(); - AwAutofillManagerDelegate::CreateForWebContents(web_contents); + AwAutofillClient::CreateForWebContents(web_contents); ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents, - AwAutofillManagerDelegate::FromWebContents(web_contents), + AwAutofillClient::FromWebContents(web_contents), l10n_util::GetDefaultLocale(), AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); } -void AwContents::SetAwAutofillManagerDelegate(jobject delegate) { +void AwContents::SetAwAutofillClient(jobject client) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) return; - Java_AwContents_setAwAutofillManagerDelegate(env, obj.obj(), delegate); + Java_AwContents_setAwAutofillClient(env, obj.obj(), client); } AwContents::~AwContents() { diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index 5521567..05b6fb6 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -208,8 +208,8 @@ class AwContents : public FindHelper::Listener, jint height_dip); void SetSaveFormData(bool enabled); - // Sets the java delegate - void SetAwAutofillManagerDelegate(jobject delegate); + // Sets the java client + void SetAwAutofillClient(jobject client); void SetJsOnlineProperty(JNIEnv* env, jobject obj, jboolean network_up); void TrimMemory(JNIEnv* env, jobject obj, jint level, jboolean visible); diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index 854bd85..aaeda65 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -36,8 +36,8 @@ 'android_protocol_handler.h', 'android_webview_jni_registrar.cc', 'android_webview_jni_registrar.h', - 'aw_autofill_manager_delegate.cc', - 'aw_autofill_manager_delegate.h', + 'aw_autofill_client.cc', + 'aw_autofill_client.h', 'aw_browser_dependency_factory.cc', 'aw_browser_dependency_factory.h', 'aw_contents.cc', @@ -126,7 +126,7 @@ 'type': 'none', 'sources': [ '../java/src/org/chromium/android_webview/AndroidProtocolHandler.java', - '../java/src/org/chromium/android_webview/AwAutofillManagerDelegate.java', + '../java/src/org/chromium/android_webview/AwAutofillClient.java', '../java/src/org/chromium/android_webview/AwContents.java', '../java/src/org/chromium/android_webview/AwContentsClientBridge.java', '../java/src/org/chromium/android_webview/AwContentsIoThreadClient.java', diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index b915123..1f2315f 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -126,7 +126,7 @@ class AutofillTest : public InProcessBrowserTest { browser()->tab_strip_model()->GetActiveWebContents(); AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( web_contents)->autofill_manager(); - autofill_manager->delegate()->HideAutofillPopup(); + autofill_manager->client()->HideAutofillPopup(); } PersonalDataManager* personal_data_manager() { diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc index 5dc05c3..653dc63 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc @@ -6,7 +6,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/autofill/core/browser/autofill_metrics.h" @@ -70,16 +70,16 @@ void AutofillCCInfobarDelegateTest::SetUp() { ChromeRenderViewHostTestHarness::SetUp(); // Ensure Mac OS X does not pop up a modal dialog for the Address Book. - autofill::test::DisableSystemServices(profile()->GetPrefs()); + test::DisableSystemServices(profile()->GetPrefs()); PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL); - TabAutofillManagerDelegate::CreateForWebContents(web_contents()); - autofill::TabAutofillManagerDelegate* manager_delegate = - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()); + ChromeAutofillClient::CreateForWebContents(web_contents()); + ChromeAutofillClient* autofill_client = + ChromeAutofillClient::FromWebContents(web_contents()); personal_data_.reset(new TestPersonalDataManager()); - personal_data_->set_database(manager_delegate->GetDatabase()); + personal_data_->set_database(autofill_client->GetDatabase()); personal_data_->SetPrefService(profile()->GetPrefs()); } diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index 1e0092b..961c8a3 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc @@ -220,7 +220,7 @@ class AutofillInteractiveTest : public InProcessBrowserTest { content::WebContents* web_contents = GetWebContents(); AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( web_contents)->autofill_manager(); - autofill_manager->delegate()->HideAutofillPopup(); + autofill_manager->client()->HideAutofillPopup(); } PersonalDataManager* GetPersonalDataManager() { diff --git a/chrome/browser/autofill/content_autofill_driver_browsertest.cc b/chrome/browser/autofill/content_autofill_driver_browsertest.cc index 1df9234..968eb9e 100644 --- a/chrome/browser/autofill/content_autofill_driver_browsertest.cc +++ b/chrome/browser/autofill/content_autofill_driver_browsertest.cc @@ -12,7 +12,7 @@ #include "chrome/test/base/testing_pref_service_syncable.h" #include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_manager.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/web_contents.h" @@ -26,11 +26,10 @@ namespace autofill { namespace { -class MockAutofillManagerDelegate - : public autofill::TestAutofillManagerDelegate { +class MockAutofillClient : public TestAutofillClient { public: - MockAutofillManagerDelegate() {} - virtual ~MockAutofillManagerDelegate() {} + MockAutofillClient() {} + virtual ~MockAutofillClient() {} virtual PrefService* GetPrefs() { return &prefs_; } @@ -52,7 +51,7 @@ class MockAutofillManagerDelegate private: TestingPrefServiceSyncable prefs_; - DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); }; // Subclass ContentAutofillDriver so we can create an ContentAutofillDriver @@ -60,10 +59,10 @@ class MockAutofillManagerDelegate class TestContentAutofillDriver : public ContentAutofillDriver { public: TestContentAutofillDriver(content::WebContents* web_contents, - AutofillManagerDelegate* delegate) + AutofillClient* client) : ContentAutofillDriver( web_contents, - delegate, + client, g_browser_process->GetApplicationLocale(), AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {} virtual ~TestContentAutofillDriver() {} @@ -85,10 +84,10 @@ class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents != NULL); Observe(web_contents); - AutofillManager::RegisterProfilePrefs(manager_delegate_.GetPrefRegistry()); + AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry()); autofill_driver_.reset( - new TestContentAutofillDriver(web_contents, &manager_delegate_)); + new TestContentAutofillDriver(web_contents, &autofill_client_)); } // Normally the WebContents will automatically delete the driver, but here @@ -114,7 +113,7 @@ class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, base::Closure web_contents_hidden_callback_; base::Closure nav_entry_committed_callback_; - testing::NiceMock<MockAutofillManagerDelegate> manager_delegate_; + testing::NiceMock<MockAutofillClient> autofill_client_; scoped_ptr<TestContentAutofillDriver> autofill_driver_; }; @@ -122,8 +121,7 @@ IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, SwitchTabAndHideAutofillPopup) { // Notification is different on platforms. On linux this will be called twice, // while on windows only once. - EXPECT_CALL(manager_delegate_, HideAutofillPopup()) - .Times(testing::AtLeast(1)); + EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(testing::AtLeast(1)); scoped_refptr<content::MessageLoopRunner> runner = new content::MessageLoopRunner; @@ -139,8 +137,7 @@ IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, TestPageNavigationHidingAutofillPopup) { // Notification is different on platforms. On linux this will be called twice, // while on windows only once. - EXPECT_CALL(manager_delegate_, HideAutofillPopup()) - .Times(testing::AtLeast(1)); + EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(testing::AtLeast(1)); scoped_refptr<content::MessageLoopRunner> runner = new content::MessageLoopRunner; diff --git a/chrome/browser/chromeos/login/ui/simple_web_view_dialog.cc b/chrome/browser/chromeos/login/ui/simple_web_view_dialog.cc index 8296449..820919d 100644 --- a/chrome/browser/chromeos/login/ui/simple_web_view_dialog.cc +++ b/chrome/browser/chromeos/login/ui/simple_web_view_dialog.cc @@ -14,7 +14,7 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delegate.h" #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" @@ -154,9 +154,9 @@ void SimpleWebViewDialog::StartLoad(const GURL& url) { DCHECK(web_contents); // Create the password manager that is needed for the proxy. - ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( + ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents, - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents)); + autofill::ChromeAutofillClient::FromWebContents(web_contents)); } void SimpleWebViewDialog::Init() { diff --git a/chrome/browser/chromeos/login/ui/webui_login_view.cc b/chrome/browser/chromeos/login/ui/webui_login_view.cc index 259bddd..5baefbf 100644 --- a/chrome/browser/chromeos/login/ui/webui_login_view.cc +++ b/chrome/browser/chromeos/login/ui/webui_login_view.cc @@ -23,7 +23,7 @@ #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/sessions/session_tab_helper.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #include "chrome/common/render_messages.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -178,9 +178,9 @@ void WebUILoginView::Init() { SessionTabHelper::CreateForWebContents(web_contents); // Create the password manager that is needed for the proxy. - ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( + ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents, - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents)); + autofill::ChromeAutofillClient::FromWebContents(web_contents)); // LoginHandlerViews uses a constrained window for the password manager view. WebContentsModalDialogManager::CreateForWebContents(web_contents); diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index ff3a90c..518a64b 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc @@ -61,23 +61,23 @@ bool IsTheHotNewBubbleUIEnabled() { DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); // static -void -ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( +void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( content::WebContents* contents, - autofill::AutofillManagerDelegate* delegate) { + autofill::AutofillClient* autofill_client) { if (FromWebContents(contents)) return; - contents->SetUserData(UserDataKey(), - new ChromePasswordManagerClient(contents, delegate)); + contents->SetUserData( + UserDataKey(), + new ChromePasswordManagerClient(contents, autofill_client)); } ChromePasswordManagerClient::ChromePasswordManagerClient( content::WebContents* web_contents, - autofill::AutofillManagerDelegate* autofill_manager_delegate) + autofill::AutofillClient* autofill_client) : content::WebContentsObserver(web_contents), profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), - driver_(web_contents, this, autofill_manager_delegate), + driver_(web_contents, this, autofill_client), observer_(NULL), weak_factory_(this), can_use_log_router_(false) { diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h index 4fad507..b4bae5b 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.h +++ b/chrome/browser/password_manager/chrome_password_manager_client.h @@ -60,9 +60,9 @@ class ChromePasswordManagerClient // Hides any visible generation UI. void HidePasswordGenerationPopup(); - static void CreateForWebContentsWithAutofillManagerDelegate( + static void CreateForWebContentsWithAutofillClient( content::WebContents* contents, - autofill::AutofillManagerDelegate* delegate); + autofill::AutofillClient* autofill_client); // Convenience method to allow //chrome code easy access to a PasswordManager // from a WebContents instance. @@ -78,9 +78,8 @@ class ChromePasswordManagerClient void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); private: - ChromePasswordManagerClient( - content::WebContents* web_contents, - autofill::AutofillManagerDelegate* autofill_manager_delegate); + ChromePasswordManagerClient(content::WebContents* web_contents, + autofill::AutofillClient* autofill_client); friend class content::WebContentsUserData<ChromePasswordManagerClient>; // content::WebContentsObserver overrides. diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc index b7d7f0a..87c2239 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc @@ -59,7 +59,7 @@ ChromePasswordManagerClientTest::ChromePasswordManagerClientTest() void ChromePasswordManagerClientTest::SetUp() { ChromeRenderViewHostTestHarness::SetUp(); - ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( + ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents(), NULL); service_ = password_manager::PasswordManagerInternalsServiceFactory:: GetForBrowserContext(profile()); diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc index 0f4808f..90db854 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc @@ -182,7 +182,7 @@ base::WeakPtr<AutofillDialogController> AutofillDialogControllerAndroid::Create( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) { + const AutofillClient::ResultCallback& callback) { // AutofillDialogControllerAndroid owns itself. AutofillDialogControllerAndroid* autofill_dialog_controller = new AutofillDialogControllerAndroid(contents, @@ -199,7 +199,7 @@ AutofillDialogController::Create( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) { + const AutofillClient::ResultCallback& callback) { return AutofillDialogControllerAndroid::Create(contents, form_structure, source_url, @@ -244,7 +244,7 @@ void AutofillDialogControllerAndroid::Show() { env, invoked_from_same_origin_)) { callback_.Run( - AutofillManagerDelegate::AutocompleteResultErrorDisabled, + AutofillClient::AutocompleteResultErrorDisabled, base::ASCIIToUTF16("Cross-origin form invocations are not supported."), NULL); delete this; @@ -261,7 +261,7 @@ void AutofillDialogControllerAndroid::Show() { // if the dialog shouldn't be shown in a given circumstances. if (!has_types) { callback_.Run( - AutofillManagerDelegate::AutocompleteResultErrorDisabled, + AutofillClient::AutocompleteResultErrorDisabled, base::ASCIIToUTF16("Form is missing autocomplete attributes."), NULL); delete this; @@ -281,7 +281,7 @@ void AutofillDialogControllerAndroid::Show() { if (!has_credit_card_field) { callback_.Run( - AutofillManagerDelegate::AutocompleteResultErrorDisabled, + AutofillClient::AutocompleteResultErrorDisabled, base::ASCIIToUTF16("Form is not a payment form (must contain " "some autocomplete=\"cc-*\" fields). "), NULL); @@ -432,7 +432,7 @@ bool AutofillDialogControllerAndroid:: void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env, jobject obj) { LogOnCancelMetrics(); - callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, + callback_.Run(AutofillClient::AutocompleteResultErrorCancel, base::string16(), NULL); } @@ -490,7 +490,7 @@ void AutofillDialogControllerAndroid::DialogContinue( LogOnFinishSubmitMetrics(); // Callback should be called as late as possible. - callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, + callback_.Run(AutofillClient::AutocompleteResultSuccess, base::string16(), &form_structure_); @@ -502,7 +502,7 @@ AutofillDialogControllerAndroid::AutofillDialogControllerAndroid( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) + const AutofillClient::ResultCallback& callback) : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), contents_(contents), initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.h b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.h index d1ffb3a1..92957b8 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.h +++ b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.h @@ -12,7 +12,7 @@ #include "base/time/time.h" #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" class Profile; @@ -27,7 +27,7 @@ class AutofillDialogControllerAndroid : public AutofillDialogController { content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + const AutofillClient::ResultCallback& callback); virtual ~AutofillDialogControllerAndroid(); @@ -55,7 +55,7 @@ class AutofillDialogControllerAndroid : public AutofillDialogController { content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + const AutofillClient::ResultCallback& callback); const AutofillMetrics& GetMetricLogger() const { return metric_logger_; @@ -88,7 +88,7 @@ class AutofillDialogControllerAndroid : public AutofillDialogController { GURL source_url_; // The callback via which we return the collected data. - AutofillManagerDelegate::ResultCallback callback_; + AutofillClient::ResultCallback callback_; // Whether |form_structure_| has asked for any details that would indicate // we should show a shipping section. diff --git a/chrome/browser/ui/autofill/account_chooser_model.h b/chrome/browser/ui/autofill/account_chooser_model.h index 7a73332..8765b33 100644 --- a/chrome/browser/ui/autofill/account_chooser_model.h +++ b/chrome/browser/ui/autofill/account_chooser_model.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/strings/string16.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "ui/base/models/simple_menu_model.h" class AutofillMetrics; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller.h b/chrome/browser/ui/autofill/autofill_dialog_controller.h index 9b04d63..364852c 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller.h @@ -11,7 +11,7 @@ #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/form_structure.h" class GURL; @@ -37,7 +37,7 @@ class AutofillDialogController { content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + const AutofillClient::ResultCallback& callback); // Registers device preferences. static void RegisterPrefs(PrefRegistrySimple* registry); diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index 1ebd14e..21ec3d1 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -18,9 +18,9 @@ #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" #include "chrome/browser/ui/autofill/autofill_dialog_view.h" #include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/autofill/data_model_wrapper.h" #include "chrome/browser/ui/autofill/mock_address_validator.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controller.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" @@ -83,9 +83,10 @@ using testing::Return; using testing::_; using ::i18n::addressinput::AddressValidator; -void MockCallback(AutofillManagerDelegate::RequestAutocompleteResult, +void MockCallback(AutofillClient::RequestAutocompleteResult, const base::string16& message, - const FormStructure*) {} + const FormStructure*) { +} class MockAutofillMetrics : public AutofillMetrics { public: @@ -403,9 +404,9 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { AutofillDialogControllerImpl* SetUpHtmlAndInvoke( const std::string& form_inner_html) { content::WebContents* contents = GetActiveWebContents(); - TabAutofillManagerDelegate* delegate = - TabAutofillManagerDelegate::FromWebContents(contents); - CHECK(!delegate->GetDialogControllerForTesting()); + ChromeAutofillClient* client = + ChromeAutofillClient::FromWebContents(contents); + CHECK(!client->GetDialogControllerForTesting()); ui_test_utils::NavigateToURL( browser(), GURL(std::string("data:text/html,") + @@ -462,7 +463,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { InitiateDialog(); AutofillDialogControllerImpl* controller = static_cast<AutofillDialogControllerImpl*>( - delegate->GetDialogControllerForTesting()); + client->GetDialogControllerForTesting()); return controller; } @@ -488,11 +489,11 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { InitiateDialog(); - TabAutofillManagerDelegate* delegate = - TabAutofillManagerDelegate::FromWebContents(contents); + ChromeAutofillClient* client = + ChromeAutofillClient::FromWebContents(contents); AutofillDialogControllerImpl* controller = static_cast<AutofillDialogControllerImpl*>( - delegate->GetDialogControllerForTesting()); + client->GetDialogControllerForTesting()); return !!controller; } @@ -1422,8 +1423,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, RefreshOnManageTabClose) { wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); content::WebContents* dialog_invoker = controller()->GetWebContents(); - TabAutofillManagerDelegate::FromWebContents(dialog_invoker)-> - SetDialogControllerForTesting(controller()->AsWeakPtr()); + ChromeAutofillClient::FromWebContents(dialog_invoker) + ->SetDialogControllerForTesting(controller()->AsWeakPtr()); // Open a new tab by selecting "Manage my shipping details..." in Wallet mode. EXPECT_EQ(1, browser()->tab_strip_model()->count()); diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index edaee4f..ce0e728 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -667,11 +667,11 @@ bool CountryFilter(const std::set<base::string16>& possible_values, // static base::WeakPtr<AutofillDialogControllerImpl> - AutofillDialogControllerImpl::Create( +AutofillDialogControllerImpl::Create( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) { + const AutofillClient::ResultCallback& callback) { // AutofillDialogControllerImpl owns itself. AutofillDialogControllerImpl* autofill_dialog_controller = new AutofillDialogControllerImpl(contents, @@ -711,7 +711,7 @@ base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) { + const AutofillClient::ResultCallback& callback) { return AutofillDialogControllerImpl::Create(contents, form_structure, source_url, @@ -730,7 +730,7 @@ void AutofillDialogControllerImpl::Show() { // Fail if the author didn't specify autocomplete types. if (!has_types) { callback_.Run( - AutofillManagerDelegate::AutocompleteResultErrorDisabled, + AutofillClient::AutocompleteResultErrorDisabled, base::ASCIIToUTF16("Form is missing autocomplete attributes."), NULL); delete this; @@ -749,11 +749,11 @@ void AutofillDialogControllerImpl::Show() { } if (!has_credit_card_field) { - callback_.Run( - AutofillManagerDelegate::AutocompleteResultErrorDisabled, - base::ASCIIToUTF16("Form is not a payment form (must contain " - "some autocomplete=\"cc-*\" fields). "), - NULL); + callback_.Run(AutofillClient::AutocompleteResultErrorDisabled, + base::ASCIIToUTF16( + "Form is not a payment form (must contain " + "some autocomplete=\"cc-*\" fields). "), + NULL); delete this; return; } @@ -2284,9 +2284,8 @@ bool AutofillDialogControllerImpl::OnCancel() { HidePopup(); if (!is_submitting_) LogOnCancelMetrics(); - callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, - base::string16(), - NULL); + callback_.Run( + AutofillClient::AutocompleteResultErrorCancel, base::string16(), NULL); return true; } @@ -2766,7 +2765,7 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl( content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) + const AutofillClient::ResultCallback& callback) : WebContentsObserver(contents), profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), @@ -3895,7 +3894,7 @@ void AutofillDialogControllerImpl::DoFinishSubmit() { LogOnFinishSubmitMetrics(); // Callback should be called as late as possible. - callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, + callback_.Run(AutofillClient::AutocompleteResultSuccess, base::string16(), &form_structure_); data_was_passed_back_ = true; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index fb92f35..afd84e2 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -24,7 +24,7 @@ #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" #include "components/autofill/content/browser/wallet/wallet_items.h" #include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_popup_delegate.h" #include "components/autofill/core/browser/field_types.h" @@ -87,7 +87,7 @@ class AutofillDialogControllerImpl content::WebContents* contents, const FormData& form_structure, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + const AutofillClient::ResultCallback& callback); // AutofillDialogController implementation. virtual void Show() OVERRIDE; @@ -233,11 +233,10 @@ class AutofillDialogControllerImpl }; // Exposed for testing. - AutofillDialogControllerImpl( - content::WebContents* contents, - const FormData& form_structure, - const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + AutofillDialogControllerImpl(content::WebContents* contents, + const FormData& form_structure, + const GURL& source_url, + const AutofillClient::ResultCallback& callback); // Exposed for testing. AutofillDialogView* view() { return view_.get(); } @@ -640,7 +639,7 @@ class AutofillDialogControllerImpl GURL source_url_; // The callback via which we return the collected data. - AutofillManagerDelegate::ResultCallback callback_; + AutofillClient::ResultCallback callback_; // The AccountChooserModel acts as the MenuModel for the account chooser, // and also tracks which data source the dialog is using. diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 769ffaa..9d894ee 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -255,7 +255,7 @@ class TestAutofillDialogController const FormData& form_structure, const GURL& source_url, const AutofillMetrics& metric_logger, - const AutofillManagerDelegate::ResultCallback& callback, + const AutofillClient::ResultCallback& callback, MockNewCreditCardBubbleController* mock_new_card_bubble_controller) : AutofillDialogControllerImpl(contents, form_structure, @@ -263,8 +263,10 @@ class TestAutofillDialogController callback), metric_logger_(metric_logger), mock_wallet_client_( - Profile::FromBrowserContext(contents->GetBrowserContext())-> - GetRequestContext(), this, source_url), + Profile::FromBrowserContext(contents->GetBrowserContext()) + ->GetRequestContext(), + this, + source_url), mock_new_card_bubble_controller_(mock_new_card_bubble_controller), submit_button_delay_count_(0) {} @@ -445,7 +447,7 @@ class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { if (controller_) controller_->ViewClosed(); - AutofillManagerDelegate::ResultCallback callback = + AutofillClient::ResultCallback callback = base::Bind(&AutofillDialogControllerTest::FinishedCallback, base::Unretained(this)); controller_ = (new testing::NiceMock<TestAutofillDialogController>( @@ -644,10 +646,9 @@ class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { } private: - void FinishedCallback( - AutofillManagerDelegate::RequestAutocompleteResult result, - const base::string16& debug_message, - const FormStructure* form_structure) { + void FinishedCallback(AutofillClient::RequestAutocompleteResult result, + const base::string16& debug_message, + const FormStructure* form_structure) { form_structure_ = form_structure; } diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc index b320deb..e0e4f85 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc @@ -17,8 +17,8 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/popup_item_ids.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_external_delegate.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "grit/component_scaled_resources.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -53,20 +53,17 @@ class MockAutofillExternalDelegate : public AutofillExternalDelegate { } }; -class MockAutofillManagerDelegate - : public autofill::TestAutofillManagerDelegate { +class MockAutofillClient : public autofill::TestAutofillClient { public: - MockAutofillManagerDelegate() - : prefs_(autofill::test::PrefServiceForTesting()) { - } - virtual ~MockAutofillManagerDelegate() {} + MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {} + virtual ~MockAutofillClient() {} virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); } private: scoped_ptr<PrefService> prefs_; - DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); }; class TestAutofillPopupController : public AutofillPopupControllerImpl { @@ -126,7 +123,7 @@ class TestAutofillPopupController : public AutofillPopupControllerImpl { class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { public: AutofillPopupControllerUnitTest() - : manager_delegate_(new MockAutofillManagerDelegate()), + : autofill_client_(new MockAutofillClient()), autofill_popup_controller_(NULL) {} virtual ~AutofillPopupControllerUnitTest() {} @@ -135,7 +132,7 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents(), - manager_delegate_.get(), + autofill_client_.get(), "en-US", AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); ContentAutofillDriver* driver = @@ -169,7 +166,7 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { } protected: - scoped_ptr<MockAutofillManagerDelegate> manager_delegate_; + scoped_ptr<MockAutofillClient> autofill_client_; scoped_ptr<NiceMock<MockAutofillExternalDelegate> > external_delegate_; testing::NiceMock<TestAutofillPopupController>* autofill_popup_controller_; }; diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc index 0e1c45d..945cee7 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "base/logging.h" #include "base/prefs/pref_service.h" @@ -30,18 +30,16 @@ #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" #endif -DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::TabAutofillManagerDelegate); +DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); namespace autofill { -TabAutofillManagerDelegate::TabAutofillManagerDelegate( - content::WebContents* web_contents) - : content::WebContentsObserver(web_contents), - web_contents_(web_contents) { +ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) + : content::WebContentsObserver(web_contents), web_contents_(web_contents) { DCHECK(web_contents); } -TabAutofillManagerDelegate::~TabAutofillManagerDelegate() { +ChromeAutofillClient::~ChromeAutofillClient() { // NOTE: It is too late to clean up the autofill popup; that cleanup process // requires that the WebContents instance still be valid and it is not at // this point (in particular, the WebContentsImpl destructor has already @@ -49,32 +47,31 @@ TabAutofillManagerDelegate::~TabAutofillManagerDelegate() { DCHECK(!popup_controller_); } -void TabAutofillManagerDelegate::TabActivated() { +void ChromeAutofillClient::TabActivated() { if (dialog_controller_.get()) dialog_controller_->TabActivated(); } -PersonalDataManager* TabAutofillManagerDelegate::GetPersonalDataManager() { +PersonalDataManager* ChromeAutofillClient::GetPersonalDataManager() { Profile* profile = Profile::FromBrowserContext(web_contents_->GetBrowserContext()); return PersonalDataManagerFactory::GetForProfile( profile->GetOriginalProfile()); } -scoped_refptr<AutofillWebDataService> - TabAutofillManagerDelegate::GetDatabase() { +scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() { Profile* profile = Profile::FromBrowserContext(web_contents_->GetBrowserContext()); return WebDataServiceFactory::GetAutofillWebDataForProfile( profile, Profile::EXPLICIT_ACCESS); } -PrefService* TabAutofillManagerDelegate::GetPrefs() { - return Profile::FromBrowserContext(web_contents_->GetBrowserContext())-> - GetPrefs(); +PrefService* ChromeAutofillClient::GetPrefs() { + return Profile::FromBrowserContext(web_contents_->GetBrowserContext()) + ->GetPrefs(); } -void TabAutofillManagerDelegate::ShowAutofillSettings() { +void ChromeAutofillClient::ShowAutofillSettings() { #if defined(OS_ANDROID) NOTIMPLEMENTED(); #else @@ -84,7 +81,7 @@ void TabAutofillManagerDelegate::ShowAutofillSettings() { #endif // #if defined(OS_ANDROID) } -void TabAutofillManagerDelegate::ConfirmSaveCreditCard( +void ChromeAutofillClient::ConfirmSaveCreditCard( const AutofillMetrics& metric_logger, const base::Closure& save_card_callback) { InfoBarService* infobar_service = @@ -93,27 +90,25 @@ void TabAutofillManagerDelegate::ConfirmSaveCreditCard( infobar_service, &metric_logger, save_card_callback); } -void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( +void ChromeAutofillClient::ShowRequestAutocompleteDialog( const FormData& form, const GURL& source_url, const ResultCallback& callback) { HideRequestAutocompleteDialog(); - dialog_controller_ = AutofillDialogController::Create(web_contents_, - form, - source_url, - callback); + dialog_controller_ = AutofillDialogController::Create( + web_contents_, form, source_url, callback); if (dialog_controller_) { dialog_controller_->Show(); } else { - callback.Run(AutofillManagerDelegate::AutocompleteResultErrorDisabled, + callback.Run(AutofillClient::AutocompleteResultErrorDisabled, base::string16(), NULL); NOTIMPLEMENTED(); } } -void TabAutofillManagerDelegate::ShowAutofillPopup( +void ChromeAutofillClient::ShowAutofillPopup( const gfx::RectF& element_bounds, base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, @@ -127,25 +122,25 @@ void TabAutofillManagerDelegate::ShowAutofillPopup( element_bounds + client_area.OffsetFromOrigin(); // Will delete or reuse the old |popup_controller_|. - popup_controller_ = AutofillPopupControllerImpl::GetOrCreate( - popup_controller_, - delegate, - web_contents(), - web_contents()->GetNativeView(), - element_bounds_in_screen_space, - text_direction); + popup_controller_ = + AutofillPopupControllerImpl::GetOrCreate(popup_controller_, + delegate, + web_contents(), + web_contents()->GetNativeView(), + element_bounds_in_screen_space, + text_direction); popup_controller_->Show(values, labels, icons, identifiers); } -void TabAutofillManagerDelegate::UpdateAutofillPopupDataListValues( +void ChromeAutofillClient::UpdateAutofillPopupDataListValues( const std::vector<base::string16>& values, const std::vector<base::string16>& labels) { if (popup_controller_.get()) popup_controller_->UpdateDataListValues(values, labels); } -void TabAutofillManagerDelegate::HideAutofillPopup() { +void ChromeAutofillClient::HideAutofillPopup() { if (popup_controller_.get()) popup_controller_->Hide(); @@ -157,21 +152,21 @@ void TabAutofillManagerDelegate::HideAutofillPopup() { password_client->HidePasswordGenerationPopup(); } -bool TabAutofillManagerDelegate::IsAutocompleteEnabled() { +bool ChromeAutofillClient::IsAutocompleteEnabled() { // For browser, Autocomplete is always enabled as part of Autofill. return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); } -void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() { +void ChromeAutofillClient::HideRequestAutocompleteDialog() { if (dialog_controller_.get()) dialog_controller_->Hide(); } -void TabAutofillManagerDelegate::WebContentsDestroyed() { +void ChromeAutofillClient::WebContentsDestroyed() { HideAutofillPopup(); } -void TabAutofillManagerDelegate::DetectAccountCreationForms( +void ChromeAutofillClient::DetectAccountCreationForms( const std::vector<autofill::FormStructure*>& forms) { password_manager::PasswordGenerationManager* manager = ChromePasswordManagerClient::GetGenerationManagerFromWebContents( @@ -180,12 +175,12 @@ void TabAutofillManagerDelegate::DetectAccountCreationForms( manager->DetectAccountCreationForms(forms); } -void TabAutofillManagerDelegate::DidFillOrPreviewField( +void ChromeAutofillClient::DidFillOrPreviewField( const base::string16& autofilled_value, const base::string16& profile_full_name) { #if defined(OS_ANDROID) - AutofillLoggerAndroid::DidFillOrPreviewField( - autofilled_value, profile_full_name); + AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, + profile_full_name); #endif // defined(OS_ANDROID) } diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h b/chrome/browser/ui/autofill/chrome_autofill_client.h index 6c48706..57a19de 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h +++ b/chrome/browser/ui/autofill/chrome_autofill_client.h @@ -1,15 +1,15 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ -#define CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ +#ifndef CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ +#define CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ #include "base/callback.h" #include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" @@ -25,21 +25,20 @@ class AutofillDialogController; class AutofillPopupControllerImpl; struct FormData; -// Chrome implementation of AutofillManagerDelegate. -class TabAutofillManagerDelegate - : public AutofillManagerDelegate, - public content::WebContentsUserData<TabAutofillManagerDelegate>, +// Chrome implementation of AutofillClient. +class ChromeAutofillClient + : public AutofillClient, + public content::WebContentsUserData<ChromeAutofillClient>, public content::WebContentsObserver { public: - virtual ~TabAutofillManagerDelegate(); + virtual ~ChromeAutofillClient(); // Called when the tab corresponding to |this| instance is activated. void TabActivated(); - // AutofillManagerDelegate implementation. + // AutofillClient: virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE; - virtual scoped_refptr<AutofillWebDataService> - GetDatabase() OVERRIDE; + virtual scoped_refptr<AutofillWebDataService> GetDatabase() OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; virtual void HideRequestAutocompleteDialog() OVERRIDE; virtual void ShowAutofillSettings() OVERRIDE; @@ -82,16 +81,16 @@ class TabAutofillManagerDelegate } private: - explicit TabAutofillManagerDelegate(content::WebContents* web_contents); - friend class content::WebContentsUserData<TabAutofillManagerDelegate>; + explicit ChromeAutofillClient(content::WebContents* web_contents); + friend class content::WebContentsUserData<ChromeAutofillClient>; content::WebContents* const web_contents_; base::WeakPtr<AutofillDialogController> dialog_controller_; base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; - DISALLOW_COPY_AND_ASSIGN(TabAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(ChromeAutofillClient); }; } // namespace autofill -#endif // CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ +#endif // CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ diff --git a/chrome/browser/ui/autofill/generated_credit_card_bubble_controller.cc b/chrome/browser/ui/autofill/generated_credit_card_bubble_controller.cc index af42b87..d5179d8 100644 --- a/chrome/browser/ui/autofill/generated_credit_card_bubble_controller.cc +++ b/chrome/browser/ui/autofill/generated_credit_card_bubble_controller.cc @@ -11,8 +11,8 @@ #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/autofill/generated_credit_card_bubble_view.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 8800ae0..2c07e91 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -85,7 +85,7 @@ #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/translate/chrome_translate_client.h" #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_utils.h" @@ -1034,8 +1034,7 @@ void Browser::ActiveTabChanged(WebContents* old_contents, if (instant_controller_) instant_controller_->ActiveTabChanged(); - autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)-> - TabActivated(); + autofill::ChromeAutofillClient::FromWebContents(new_contents)->TabActivated(); SearchTabHelper::FromWebContents(new_contents)->OnTabActivated(); } diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm index 546dd98..cec7285 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm @@ -22,9 +22,10 @@ namespace autofill { namespace { -void MockCallback(AutofillManagerDelegate::RequestAutocompleteResult result, +void MockCallback(AutofillClient::RequestAutocompleteResult result, const base::string16&, - const FormStructure*) {} + const FormStructure*) { +} class TestAutofillDialogController : public AutofillDialogControllerImpl { public: diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc index 32ef625..ee5a729 100644 --- a/chrome/browser/ui/tab_helpers.cc +++ b/chrome/browser/ui/tab_helpers.cc @@ -17,7 +17,7 @@ #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" #include "chrome/browser/translate/chrome_translate_client.h" -#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" +#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" @@ -112,17 +112,17 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { // --- Common tab helpers --- - autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents); + autofill::ChromeAutofillClient::CreateForWebContents(web_contents); autofill::ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents, - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents), + autofill::ChromeAutofillClient::FromWebContents(web_contents), g_browser_process->GetApplicationLocale(), autofill::AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); BookmarkTabHelper::CreateForWebContents(web_contents); chrome_browser_net::NetErrorTabHelper::CreateForWebContents(web_contents); - ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( + ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents, - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents)); + autofill::ChromeAutofillClient::FromWebContents(web_contents)); CoreTabHelper::CreateForWebContents(web_contents); extensions::TabHelper::CreateForWebContents(web_contents); FaviconTabHelper::CreateForWebContents(web_contents); diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 3c05432..55e7bb3 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -407,6 +407,8 @@ 'browser/ui/autofill/autofill_popup_controller_impl.h', 'browser/ui/autofill/autofill_popup_view.h', 'browser/ui/autofill/autofill_popup_view_delegate.h', + 'browser/ui/autofill/chrome_autofill_client.cc', + 'browser/ui/autofill/chrome_autofill_client.h', 'browser/ui/autofill/country_combobox_model.cc', 'browser/ui/autofill/country_combobox_model.h', 'browser/ui/autofill/data_model_wrapper.cc', @@ -429,8 +431,6 @@ 'browser/ui/autofill/password_generation_popup_view.h', 'browser/ui/autofill/popup_controller_common.cc', 'browser/ui/autofill/popup_controller_common.h', - 'browser/ui/autofill/tab_autofill_manager_delegate.cc', - 'browser/ui/autofill/tab_autofill_manager_delegate.h', 'browser/ui/auto_login_infobar_delegate.cc', 'browser/ui/auto_login_infobar_delegate.h', 'browser/ui/blocked_content/blocked_window_params.cc', diff --git a/components/autofill.gypi b/components/autofill.gypi index d691ae3..777284f 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -136,7 +136,7 @@ 'autofill/core/browser/autofill_ie_toolbar_import_win.h', 'autofill/core/browser/autofill_manager.cc', 'autofill/core/browser/autofill_manager.h', - 'autofill/core/browser/autofill_manager_delegate.h', + 'autofill/core/browser/autofill_client.h', 'autofill/core/browser/autofill_manager_test_delegate.h', 'autofill/core/browser/autofill_metrics.cc', 'autofill/core/browser/autofill_metrics.h', @@ -258,12 +258,12 @@ 'autofill/core/browser/autofill_test_utils.h', 'autofill/core/browser/data_driven_test.cc', 'autofill/core/browser/data_driven_test.h', + 'autofill/core/browser/test_autofill_client.cc', + 'autofill/core/browser/test_autofill_client.h', 'autofill/core/browser/test_autofill_driver.cc', 'autofill/core/browser/test_autofill_driver.h', 'autofill/core/browser/test_autofill_external_delegate.cc', 'autofill/core/browser/test_autofill_external_delegate.h', - 'autofill/core/browser/test_autofill_manager_delegate.cc', - 'autofill/core/browser/test_autofill_manager_delegate.h', 'autofill/core/browser/test_personal_data_manager.cc', 'autofill/core/browser/test_personal_data_manager.h', ], diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc index 54b095e..6707177 100644 --- a/components/autofill/content/browser/content_autofill_driver.cc +++ b/components/autofill/content/browser/content_autofill_driver.cc @@ -7,9 +7,9 @@ #include "base/command_line.h" #include "base/threading/sequenced_worker_pool.h" #include "components/autofill/content/common/autofill_messages.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/common/autofill_switches.h" #include "content/public/browser/browser_context.h" @@ -33,7 +33,7 @@ const char kContentAutofillDriverWebContentsUserDataKey[] = // static void ContentAutofillDriver::CreateForWebContentsAndDelegate( content::WebContents* contents, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager) { if (FromWebContents(contents)) @@ -42,7 +42,7 @@ void ContentAutofillDriver::CreateForWebContentsAndDelegate( contents->SetUserData( kContentAutofillDriverWebContentsUserDataKey, new ContentAutofillDriver( - contents, delegate, app_locale, enable_download_manager)); + contents, client, app_locale, enable_download_manager)); } // static @@ -54,12 +54,12 @@ ContentAutofillDriver* ContentAutofillDriver::FromWebContents( ContentAutofillDriver::ContentAutofillDriver( content::WebContents* web_contents, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager) : content::WebContentsObserver(web_contents), autofill_manager_(new AutofillManager(this, - delegate, + client, app_locale, enable_download_manager)), autofill_external_delegate_(autofill_manager_.get(), this), @@ -229,11 +229,11 @@ void ContentAutofillDriver::SetAutofillManager( void ContentAutofillDriver::NavigationEntryCommitted( const content::LoadCommittedDetails& load_details) { - autofill_manager_->delegate()->HideAutofillPopup(); + autofill_manager_->client()->HideAutofillPopup(); } void ContentAutofillDriver::WasHidden() { - autofill_manager_->delegate()->HideAutofillPopup(); + autofill_manager_->client()->HideAutofillPopup(); } } // namespace autofill diff --git a/components/autofill/content/browser/content_autofill_driver.h b/components/autofill/content/browser/content_autofill_driver.h index 5fde045..e0294f5 100644 --- a/components/autofill/content/browser/content_autofill_driver.h +++ b/components/autofill/content/browser/content_autofill_driver.h @@ -26,7 +26,7 @@ class Message; namespace autofill { class AutofillContext; -class AutofillManagerDelegate; +class AutofillClient; // Class that drives autofill flow in the browser process based on // communication from the renderer and from the external world. There is one @@ -37,7 +37,7 @@ class ContentAutofillDriver : public AutofillDriver, public: static void CreateForWebContentsAndDelegate( content::WebContents* contents, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager); static ContentAutofillDriver* FromWebContents(content::WebContents* contents); @@ -74,7 +74,7 @@ class ContentAutofillDriver : public AutofillDriver, protected: ContentAutofillDriver( content::WebContents* web_contents, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager); virtual ~ContentAutofillDriver(); diff --git a/components/autofill/content/browser/content_autofill_driver_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc index 24e54f1..d2849ff 100644 --- a/components/autofill/content/browser/content_autofill_driver_unittest.cc +++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc @@ -13,7 +13,7 @@ #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_test_utils.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/form_data_predictions.h" #include "content/public/browser/browser_context.h" @@ -38,8 +38,8 @@ const AutofillManager::AutofillDownloadManagerState kDownloadState = class MockAutofillManager : public AutofillManager { public: - MockAutofillManager(AutofillDriver* driver, AutofillManagerDelegate* delegate) - : AutofillManager(driver, delegate, kAppLocale, kDownloadState) {} + MockAutofillManager(AutofillDriver* driver, AutofillClient* client) + : AutofillManager(driver, client, kAppLocale, kDownloadState) {} virtual ~MockAutofillManager() {} MOCK_METHOD0(Reset, void()); @@ -48,10 +48,10 @@ class MockAutofillManager : public AutofillManager { class TestContentAutofillDriver : public ContentAutofillDriver { public: TestContentAutofillDriver(content::WebContents* contents, - AutofillManagerDelegate* delegate) - : ContentAutofillDriver(contents, delegate, kAppLocale, kDownloadState) { + AutofillClient* client) + : ContentAutofillDriver(contents, client, kAppLocale, kDownloadState) { scoped_ptr<AutofillManager> autofill_manager( - new MockAutofillManager(this, delegate)); + new MockAutofillManager(this, client)); SetAutofillManager(autofill_manager.Pass()); } virtual ~TestContentAutofillDriver() {} @@ -68,9 +68,9 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness { virtual void SetUp() OVERRIDE { content::RenderViewHostTestHarness::SetUp(); - test_manager_delegate_.reset(new TestAutofillManagerDelegate()); + test_autofill_client_.reset(new TestAutofillClient()); driver_.reset(new TestContentAutofillDriver(web_contents(), - test_manager_delegate_.get())); + test_autofill_client_.get())); } virtual void TearDown() OVERRIDE { @@ -191,7 +191,7 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness { return true; } - scoped_ptr<TestAutofillManagerDelegate> test_manager_delegate_; + scoped_ptr<TestAutofillClient> test_autofill_client_; scoped_ptr<TestContentAutofillDriver> driver_; }; diff --git a/components/autofill/content/browser/request_autocomplete_manager.cc b/components/autofill/content/browser/request_autocomplete_manager.cc index 8d6dc5a..31f20f1 100644 --- a/components/autofill/content/browser/request_autocomplete_manager.cc +++ b/components/autofill/content/browser/request_autocomplete_manager.cc @@ -19,15 +19,15 @@ namespace autofill { namespace { blink::WebFormElement::AutocompleteResult ToWebkitAutocompleteResult( - AutofillManagerDelegate::RequestAutocompleteResult result) { + AutofillClient::RequestAutocompleteResult result) { switch(result) { - case AutofillManagerDelegate::AutocompleteResultSuccess: + case AutofillClient::AutocompleteResultSuccess: return blink::WebFormElement::AutocompleteResultSuccess; - case AutofillManagerDelegate::AutocompleteResultErrorDisabled: + case AutofillClient::AutocompleteResultErrorDisabled: return blink::WebFormElement::AutocompleteResultErrorDisabled; - case AutofillManagerDelegate::AutocompleteResultErrorCancel: + case AutofillClient::AutocompleteResultErrorCancel: return blink::WebFormElement::AutocompleteResultErrorCancel; - case AutofillManagerDelegate::AutocompleteResultErrorInvalid: + case AutofillClient::AutocompleteResultErrorInvalid: return blink::WebFormElement::AutocompleteResultErrorInvalid; } @@ -51,19 +51,19 @@ void RequestAutocompleteManager::OnRequestAutocomplete( if (!IsValidFormData(form)) return; - AutofillManagerDelegate::ResultCallback callback = + AutofillClient::ResultCallback callback = base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult, weak_ptr_factory_.GetWeakPtr()); ShowRequestAutocompleteDialog(form, frame_url, callback); } void RequestAutocompleteManager::OnCancelRequestAutocomplete() { - autofill_driver_->autofill_manager()->delegate()-> - HideRequestAutocompleteDialog(); + autofill_driver_->autofill_manager()->client() + ->HideRequestAutocompleteDialog(); } void RequestAutocompleteManager::ReturnAutocompleteResult( - AutofillManagerDelegate::RequestAutocompleteResult result, + AutofillClient::RequestAutocompleteResult result, const base::string16& debug_message, const FormStructure* form_structure) { // autofill_driver_->GetWebContents() will be NULL when the interactive @@ -95,10 +95,9 @@ void RequestAutocompleteManager::ReturnAutocompleteResult( void RequestAutocompleteManager::ShowRequestAutocompleteDialog( const FormData& form, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback) { - AutofillManagerDelegate* delegate = - autofill_driver_->autofill_manager()->delegate(); - delegate->ShowRequestAutocompleteDialog(form, source_url, callback); + const AutofillClient::ResultCallback& callback) { + AutofillClient* client = autofill_driver_->autofill_manager()->client(); + client->ShowRequestAutocompleteDialog(form, source_url, callback); } } // namespace autofill diff --git a/components/autofill/content/browser/request_autocomplete_manager.h b/components/autofill/content/browser/request_autocomplete_manager.h index aa5d250..648fae7 100644 --- a/components/autofill/content/browser/request_autocomplete_manager.h +++ b/components/autofill/content/browser/request_autocomplete_manager.h @@ -7,7 +7,7 @@ #include "base/callback_forward.h" #include "base/memory/weak_ptr.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" class GURL; @@ -36,7 +36,7 @@ class RequestAutocompleteManager { // |form_structure| containing the filled form data. |debug_message| will // be printed to the developer console. void ReturnAutocompleteResult( - AutofillManagerDelegate::RequestAutocompleteResult result, + AutofillClient::RequestAutocompleteResult result, const base::string16& debug_message, const FormStructure* form_structure); @@ -45,7 +45,7 @@ class RequestAutocompleteManager { void ShowRequestAutocompleteDialog( const FormData& form, const GURL& source_url, - const AutofillManagerDelegate::ResultCallback& callback); + const AutofillClient::ResultCallback& callback); // The autofill driver owns and outlives |this|. ContentAutofillDriver* const autofill_driver_; // weak. diff --git a/components/autofill/content/browser/request_autocomplete_manager_unittest.cc b/components/autofill/content/browser/request_autocomplete_manager_unittest.cc index 8d38434..d9a9fb3 100644 --- a/components/autofill/content/browser/request_autocomplete_manager_unittest.cc +++ b/components/autofill/content/browser/request_autocomplete_manager_unittest.cc @@ -5,7 +5,7 @@ #include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/browser/request_autocomplete_manager.h" #include "components/autofill/content/common/autofill_messages.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,11 +20,9 @@ const AutofillManager::AutofillDownloadManagerState kDownloadState = class TestAutofillManager : public AutofillManager { public: - TestAutofillManager(AutofillDriver* driver, - AutofillManagerDelegate* delegate) - : AutofillManager(driver, delegate, kAppLocale, kDownloadState), - autofill_enabled_(true) { - } + TestAutofillManager(AutofillDriver* driver, AutofillClient* client) + : AutofillManager(driver, client, kAppLocale, kDownloadState), + autofill_enabled_(true) {} virtual ~TestAutofillManager() {} virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } @@ -39,47 +37,46 @@ class TestAutofillManager : public AutofillManager { DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); }; -class CustomTestAutofillManagerDelegate : public TestAutofillManagerDelegate { - public: - CustomTestAutofillManagerDelegate() : should_simulate_success_(true) {} - - virtual ~CustomTestAutofillManagerDelegate() {} - - virtual void ShowRequestAutocompleteDialog( - const FormData& form, - const GURL& source_url, - const ResultCallback& callback) OVERRIDE { - if (should_simulate_success_) { - FormStructure form_structure(form); - callback.Run(AutocompleteResultSuccess, - base::string16(), - &form_structure); - } else { - callback.Run(AutofillManagerDelegate::AutocompleteResultErrorDisabled, - base::string16(), - NULL); - } +class CustomTestAutofillClient : public TestAutofillClient { + public: + CustomTestAutofillClient() : should_simulate_success_(true) {} + + virtual ~CustomTestAutofillClient() {} + + virtual void ShowRequestAutocompleteDialog( + const FormData& form, + const GURL& source_url, + const ResultCallback& callback) OVERRIDE { + if (should_simulate_success_) { + FormStructure form_structure(form); + callback.Run( + AutocompleteResultSuccess, base::string16(), &form_structure); + } else { + callback.Run(AutofillClient::AutocompleteResultErrorDisabled, + base::string16(), + NULL); } + } - void set_should_simulate_success(bool should_simulate_success) { - should_simulate_success_ = should_simulate_success; - } + void set_should_simulate_success(bool should_simulate_success) { + should_simulate_success_ = should_simulate_success; + } - private: - // Enable testing the path where a callback is called without a - // valid FormStructure. - bool should_simulate_success_; + private: + // Enable testing the path where a callback is called without a + // valid FormStructure. + bool should_simulate_success_; - DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillClient); }; class TestContentAutofillDriver : public ContentAutofillDriver { public: TestContentAutofillDriver(content::WebContents* contents, - AutofillManagerDelegate* delegate) - : ContentAutofillDriver(contents, delegate, kAppLocale, kDownloadState) { + AutofillClient* client) + : ContentAutofillDriver(contents, client, kAppLocale, kDownloadState) { SetAutofillManager(make_scoped_ptr<AutofillManager>( - new TestAutofillManager(this, delegate))); + new TestAutofillManager(this, client))); } virtual ~TestContentAutofillDriver() {} @@ -103,7 +100,7 @@ class RequestAutocompleteManagerTest : content::RenderViewHostTestHarness::SetUp(); driver_.reset( - new TestContentAutofillDriver(web_contents(), &manager_delegate_)); + new TestContentAutofillDriver(web_contents(), &autofill_client_)); request_autocomplete_manager_.reset( new RequestAutocompleteManager(driver_.get())); } @@ -136,7 +133,7 @@ class RequestAutocompleteManagerTest : } protected: - CustomTestAutofillManagerDelegate manager_delegate_; + CustomTestAutofillClient autofill_client_; scoped_ptr<TestContentAutofillDriver> driver_; scoped_ptr<RequestAutocompleteManager> request_autocomplete_manager_; @@ -152,7 +149,7 @@ TEST_F(RequestAutocompleteManagerTest, OnRequestAutocompleteSuccess) { TEST_F(RequestAutocompleteManagerTest, OnRequestAutocompleteCancel) { blink::WebFormElement::AutocompleteResult result; - manager_delegate_.set_should_simulate_success(false); + autofill_client_.set_should_simulate_success(false); request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); EXPECT_TRUE(GetAutocompleteResultMessage(&result)); EXPECT_EQ(blink::WebFormElement::AutocompleteResultErrorDisabled, result); diff --git a/components/autofill/content/browser/risk/fingerprint.h b/components/autofill/content/browser/risk/fingerprint.h index 6cef2f9..8ecbe9f 100644 --- a/components/autofill/content/browser/risk/fingerprint.h +++ b/components/autofill/content/browser/risk/fingerprint.h @@ -17,7 +17,7 @@ #include "base/basictypes.h" #include "base/callback_forward.h" #include "base/memory/scoped_ptr.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" class PrefService; diff --git a/components/autofill/content/browser/wallet/wallet_client.h b/components/autofill/content/browser/wallet/wallet_client.h index 1a4dd90..08f944c 100644 --- a/components/autofill/content/browser/wallet/wallet_client.h +++ b/components/autofill/content/browser/wallet/wallet_client.h @@ -16,7 +16,7 @@ #include "base/values.h" #include "components/autofill/content/browser/wallet/full_wallet.h" #include "components/autofill/content/browser/wallet/wallet_items.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "net/url_request/url_fetcher_delegate.h" #include "testing/gtest/include/gtest/gtest_prod.h" diff --git a/components/autofill/content/browser/wallet/wallet_client_delegate.h b/components/autofill/content/browser/wallet/wallet_client_delegate.h index 8380fbf..4a37899 100644 --- a/components/autofill/content/browser/wallet/wallet_client_delegate.h +++ b/components/autofill/content/browser/wallet/wallet_client_delegate.h @@ -10,7 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "components/autofill/content/browser/wallet/form_field_error.h" #include "components/autofill/content/browser/wallet/wallet_client.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" class AutofillMetrics; diff --git a/components/autofill/core/browser/autocomplete_history_manager.cc b/components/autofill/core/browser/autocomplete_history_manager.cc index d473763..ccd4b5e 100644 --- a/components/autofill/core/browser/autocomplete_history_manager.cc +++ b/components/autofill/core/browser/autocomplete_history_manager.cc @@ -9,9 +9,9 @@ #include "base/prefs/pref_service.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_driver.h" #include "components/autofill/core/browser/autofill_external_delegate.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" #include "components/autofill/core/browser/validation.h" #include "components/autofill/core/common/autofill_pref_names.h" #include "components/autofill/core/common/form_data.h" @@ -36,14 +36,14 @@ bool IsTextField(const FormFieldData& field) { AutocompleteHistoryManager::AutocompleteHistoryManager( AutofillDriver* driver, - AutofillManagerDelegate* manager_delegate) + AutofillClient* autofill_client) : driver_(driver), - database_(manager_delegate->GetDatabase()), + database_(autofill_client->GetDatabase()), pending_query_handle_(0), query_id_(0), external_delegate_(NULL), - manager_delegate_(manager_delegate) { - DCHECK(manager_delegate_); + autofill_client_(autofill_client) { + DCHECK(autofill_client_); } AutocompleteHistoryManager::~AutocompleteHistoryManager() { @@ -56,7 +56,7 @@ void AutocompleteHistoryManager::OnWebDataServiceRequestDone( DCHECK(pending_query_handle_); pending_query_handle_ = 0; - if (!manager_delegate_->IsAutocompleteEnabled()) { + if (!autofill_client_->IsAutocompleteEnabled()) { SendSuggestions(NULL); return; } @@ -93,7 +93,7 @@ void AutocompleteHistoryManager::OnGetAutocompleteSuggestions( autofill_labels_ = autofill_labels; autofill_icons_ = autofill_icons; autofill_unique_ids_ = autofill_unique_ids; - if (!manager_delegate_->IsAutocompleteEnabled() || + if (!autofill_client_->IsAutocompleteEnabled() || form_control_type == "textarea") { SendSuggestions(NULL); return; @@ -106,7 +106,7 @@ void AutocompleteHistoryManager::OnGetAutocompleteSuggestions( } void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) { - if (!manager_delegate_->IsAutocompleteEnabled()) + if (!autofill_client_->IsAutocompleteEnabled()) return; if (driver_->IsOffTheRecord()) diff --git a/components/autofill/core/browser/autocomplete_history_manager.h b/components/autofill/core/browser/autocomplete_history_manager.h index 50ad599..0320034 100644 --- a/components/autofill/core/browser/autocomplete_history_manager.h +++ b/components/autofill/core/browser/autocomplete_history_manager.h @@ -16,7 +16,7 @@ namespace autofill { class AutofillDriver; class AutofillExternalDelegate; -class AutofillManagerDelegate; +class AutofillClient; struct FormData; // Per-tab Autocomplete history manager. Handles receiving form data @@ -25,7 +25,7 @@ struct FormData; class AutocompleteHistoryManager : public WebDataServiceConsumer { public: AutocompleteHistoryManager(AutofillDriver* driver, - AutofillManagerDelegate* delegate); + AutofillClient* autofill_client); virtual ~AutocompleteHistoryManager(); // WebDataServiceConsumer implementation. @@ -82,7 +82,7 @@ class AutocompleteHistoryManager : public WebDataServiceConsumer { AutofillExternalDelegate* external_delegate_; // Delegate to provide whether or not autocomplete functionality is enabled. - AutofillManagerDelegate* const manager_delegate_; + AutofillClient* const autofill_client_; // Whether IPC is sent. bool send_ipc_; diff --git a/components/autofill/core/browser/autocomplete_history_manager_unittest.cc b/components/autofill/core/browser/autocomplete_history_manager_unittest.cc index 6379f07..3ac46b6 100644 --- a/components/autofill/core/browser/autocomplete_history_manager_unittest.cc +++ b/components/autofill/core/browser/autocomplete_history_manager_unittest.cc @@ -15,8 +15,8 @@ #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_test_utils.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_driver.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/common/form_data.h" #include "components/webdata/common/web_data_service_test_util.h" @@ -43,15 +43,12 @@ class MockWebDataService : public AutofillWebDataService { virtual ~MockWebDataService() {} }; -class MockAutofillManagerDelegate - : public autofill::TestAutofillManagerDelegate { +class MockAutofillClient : public TestAutofillClient { public: - MockAutofillManagerDelegate( - scoped_refptr<MockWebDataService> web_data_service) + MockAutofillClient(scoped_refptr<MockWebDataService> web_data_service) : web_data_service_(web_data_service), - prefs_(test::PrefServiceForTesting()) { - } - virtual ~MockAutofillManagerDelegate() {} + prefs_(test::PrefServiceForTesting()) {} + virtual ~MockAutofillClient() {} virtual scoped_refptr<AutofillWebDataService> GetDatabase() OVERRIDE { return web_data_service_; } virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); } @@ -60,7 +57,7 @@ class MockAutofillManagerDelegate scoped_refptr<MockWebDataService> web_data_service_; scoped_ptr<PrefService> prefs_; - DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); }; } // namespace @@ -71,11 +68,10 @@ class AutocompleteHistoryManagerTest : public testing::Test { virtual void SetUp() OVERRIDE { web_data_service_ = new MockWebDataService(); - manager_delegate_.reset(new MockAutofillManagerDelegate(web_data_service_)); + autofill_client_.reset(new MockAutofillClient(web_data_service_)); autofill_driver_.reset(new TestAutofillDriver()); - autocomplete_manager_.reset( - new AutocompleteHistoryManager(autofill_driver_.get(), - manager_delegate_.get())); + autocomplete_manager_.reset(new AutocompleteHistoryManager( + autofill_driver_.get(), autofill_client_.get())); } virtual void TearDown() OVERRIDE { @@ -86,7 +82,7 @@ class AutocompleteHistoryManagerTest : public testing::Test { scoped_refptr<MockWebDataService> web_data_service_; scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; scoped_ptr<AutofillDriver> autofill_driver_; - scoped_ptr<MockAutofillManagerDelegate> manager_delegate_; + scoped_ptr<MockAutofillClient> autofill_client_; }; // Tests that credit card numbers are not sent to the WebDatabase to be saved. @@ -196,9 +192,8 @@ class MockAutofillExternalDelegate : public AutofillExternalDelegate { class TestAutocompleteHistoryManager : public AutocompleteHistoryManager { public: - TestAutocompleteHistoryManager(AutofillDriver* driver, - AutofillManagerDelegate* delegate) - : AutocompleteHistoryManager(driver, delegate) {} + TestAutocompleteHistoryManager(AutofillDriver* driver, AutofillClient* client) + : AutocompleteHistoryManager(driver, client) {} using AutocompleteHistoryManager::SendSuggestions; }; @@ -208,13 +203,13 @@ class TestAutocompleteHistoryManager : public AutocompleteHistoryManager { // Make sure our external delegate is called at the right time. TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { TestAutocompleteHistoryManager autocomplete_history_manager( - autofill_driver_.get(), manager_delegate_.get()); + autofill_driver_.get(), autofill_client_.get()); - scoped_ptr<AutofillManager> autofill_manager(new AutofillManager( - autofill_driver_.get(), - manager_delegate_.get(), - "en-US", - AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); + scoped_ptr<AutofillManager> autofill_manager( + new AutofillManager(autofill_driver_.get(), + autofill_client_.get(), + "en-US", + AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); MockAutofillExternalDelegate external_delegate(autofill_manager.get(), autofill_driver_.get()); @@ -228,13 +223,13 @@ TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { // Verify that no autocomplete suggestion is returned for textarea. TEST_F(AutocompleteHistoryManagerTest, NoAutocompleteSuggestionsForTextarea) { TestAutocompleteHistoryManager autocomplete_history_manager( - autofill_driver_.get(), manager_delegate_.get()); + autofill_driver_.get(), autofill_client_.get()); - scoped_ptr<AutofillManager> autofill_manager(new AutofillManager( - autofill_driver_.get(), - manager_delegate_.get(), - "en-US", - AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); + scoped_ptr<AutofillManager> autofill_manager( + new AutofillManager(autofill_driver_.get(), + autofill_client_.get(), + "en-US", + AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); MockAutofillExternalDelegate external_delegate(autofill_manager.get(), autofill_driver_.get()); diff --git a/components/autofill/core/browser/autofill_manager_delegate.h b/components/autofill/core/browser/autofill_client.h index f704e2ae..a9fed8d 100644 --- a/components/autofill/core/browser/autofill_manager_delegate.h +++ b/components/autofill/core/browser/autofill_client.h @@ -1,9 +1,9 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ -#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ #include <vector> @@ -33,38 +33,36 @@ class PersonalDataManager; struct FormData; struct PasswordForm; -// A delegate interface that needs to be supplied to AutofillManager -// by the embedder. +// A client interface that needs to be supplied to the Autofill component by the +// embedder. // -// Each delegate instance is associated with a given context within -// which an AutofillManager is used (e.g. a single tab), so when we -// say "for the delegate" below, we mean "in the execution context the -// delegate is associated with" (e.g. for the tab the AutofillManager is -// attached to). -class AutofillManagerDelegate { +// Each client instance is associated with a given context within which an +// AutofillManager is used (e.g. a single tab), so when we say "for the client" +// below, we mean "in the execution context the client is associated with" (e.g. +// for the tab the AutofillManager is attached to). +class AutofillClient { public: // Copy of blink::WebFormElement::AutocompleteResult. enum RequestAutocompleteResult { - AutocompleteResultSuccess, - AutocompleteResultErrorDisabled, - AutocompleteResultErrorCancel, - AutocompleteResultErrorInvalid, + AutocompleteResultSuccess, + AutocompleteResultErrorDisabled, + AutocompleteResultErrorCancel, + AutocompleteResultErrorInvalid, }; - typedef base::Callback< - void(RequestAutocompleteResult, - const base::string16&, - const FormStructure*)> ResultCallback; + typedef base::Callback<void(RequestAutocompleteResult, + const base::string16&, + const FormStructure*)> ResultCallback; - virtual ~AutofillManagerDelegate() {} + virtual ~AutofillClient() {} - // Gets the PersonalDataManager instance associated with the delegate. + // Gets the PersonalDataManager instance associated with the client. virtual PersonalDataManager* GetPersonalDataManager() = 0; - // Gets the AutofillWebDataService instance associated with the delegate. + // Gets the AutofillWebDataService instance associated with the client. virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; - // Gets the preferences associated with the delegate. + // Gets the preferences associated with the client. virtual PrefService* GetPrefs() = 0; // Hides the associated request autocomplete dialog (if it exists). @@ -113,13 +111,12 @@ class AutofillManagerDelegate { virtual void DetectAccountCreationForms( const std::vector<autofill::FormStructure*>& forms) = 0; - // Inform the delegate that the field has been filled. + // Inform the client that the field has been filled. virtual void DidFillOrPreviewField( const base::string16& autofilled_value, const base::string16& profile_full_name) = 0; - }; } // namespace autofill -#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc index 57ef7c7..57777c8 100644 --- a/components/autofill/core/browser/autofill_external_delegate.cc +++ b/components/autofill/core/browser/autofill_external_delegate.cc @@ -133,20 +133,19 @@ void AutofillExternalDelegate::OnSuggestionsReturned( if (values.empty()) { // No suggestions, any popup currently showing is obsolete. - manager_->delegate()->HideAutofillPopup(); + manager_->client()->HideAutofillPopup(); return; } // Send to display. if (query_field_.is_focusable) { - manager_->delegate()->ShowAutofillPopup( - element_bounds_, - query_field_.text_direction, - values, - labels, - icons, - ids, - GetWeakPtr()); + manager_->client()->ShowAutofillPopup(element_bounds_, + query_field_.text_direction, + values, + labels, + icons, + ids, + GetWeakPtr()); } } @@ -156,9 +155,8 @@ void AutofillExternalDelegate::SetCurrentDataListValues( data_list_values_ = data_list_values; data_list_labels_ = data_list_labels; - manager_->delegate()->UpdateAutofillPopupDataListValues( - data_list_values, - data_list_labels); + manager_->client()->UpdateAutofillPopupDataListValues(data_list_values, + data_list_labels); } void AutofillExternalDelegate::OnPopupShown() { @@ -235,7 +233,7 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, FillAutofillFormData(identifier, false); } - manager_->delegate()->HideAutofillPopup(); + manager_->client()->HideAutofillPopup(); } void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, @@ -247,7 +245,7 @@ void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, } void AutofillExternalDelegate::DidEndTextFieldEditing() { - manager_->delegate()->HideAutofillPopup(); + manager_->client()->HideAutofillPopup(); has_shown_popup_for_current_edit_ = false; } @@ -257,7 +255,7 @@ void AutofillExternalDelegate::ClearPreviewedForm() { } void AutofillExternalDelegate::Reset() { - manager_->delegate()->HideAutofillPopup(); + manager_->client()->HideAutofillPopup(); } void AutofillExternalDelegate::OnPingAck() { diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc index 8d00280..494bbbb 100644 --- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc +++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc @@ -10,9 +10,9 @@ #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/popup_item_ids.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_driver.h" #include "components/autofill/core/browser/test_autofill_external_delegate.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/password_form_fill_data.h" @@ -49,10 +49,9 @@ class MockAutofillDriver : public TestAutofillDriver { DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver); }; -class MockAutofillManagerDelegate - : public autofill::TestAutofillManagerDelegate { +class MockAutofillClient : public autofill::TestAutofillClient { public: - MockAutofillManagerDelegate() {} + MockAutofillClient() {} MOCK_METHOD7(ShowAutofillPopup, void(const gfx::RectF& element_bounds, @@ -70,17 +69,15 @@ class MockAutofillManagerDelegate MOCK_METHOD0(HideAutofillPopup, void()); private: - DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); }; class MockAutofillManager : public AutofillManager { public: - MockAutofillManager(AutofillDriver* driver, - MockAutofillManagerDelegate* delegate) + MockAutofillManager(AutofillDriver* driver, MockAutofillClient* client) // Force to use the constructor designated for unit test, but we don't // really need personal_data in this test so we pass a NULL pointer. - : AutofillManager(driver, delegate, NULL) { - } + : AutofillManager(driver, client, NULL) {} virtual ~MockAutofillManager() {} MOCK_METHOD5(FillOrPreviewForm, @@ -101,8 +98,7 @@ class AutofillExternalDelegateUnitTest : public testing::Test { virtual void SetUp() OVERRIDE { autofill_driver_.reset(new MockAutofillDriver()); autofill_manager_.reset( - new MockAutofillManager(autofill_driver_.get(), - &manager_delegate_)); + new MockAutofillManager(autofill_driver_.get(), &autofill_client_)); external_delegate_.reset( new AutofillExternalDelegate( autofill_manager_.get(), autofill_driver_.get())); @@ -127,7 +123,7 @@ class AutofillExternalDelegateUnitTest : public testing::Test { external_delegate_->OnQuery(query_id, form, field, element_bounds, true); } - MockAutofillManagerDelegate manager_delegate_; + MockAutofillClient autofill_client_; scoped_ptr<MockAutofillDriver> autofill_driver_; scoped_ptr<MockAutofillManager> autofill_manager_; scoped_ptr<AutofillExternalDelegate> external_delegate_; @@ -141,7 +137,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL( - manager_delegate_, + autofill_client_, ShowAutofillPopup(_, _, _, @@ -167,7 +163,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { EXPECT_CALL(*autofill_manager_, FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); // This should trigger a call to hide the popup since we've selected an // option. @@ -186,7 +182,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL( - manager_delegate_, + autofill_client_, ShowAutofillPopup(_, _, _, @@ -215,7 +211,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { // the datalist items are still shown. // The enum must be cast to an int to prevent compile errors on linux_rel. EXPECT_CALL( - manager_delegate_, + autofill_client_, ShowAutofillPopup( _, _, @@ -238,8 +234,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { IssueOnQuery(kQueryId); - EXPECT_CALL(manager_delegate_, - ShowAutofillPopup(_, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _, _, _, _)) + .Times(0); // Make sure just setting the data list values doesn't cause the popup to // appear. @@ -251,7 +247,7 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL( - manager_delegate_, + autofill_client_, ShowAutofillPopup(_, _, _, @@ -284,9 +280,9 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { data_list_items.push_back(base::string16()); // The enums must be cast to ints to prevent compile errors on linux_rel. - EXPECT_CALL(manager_delegate_, - UpdateAutofillPopupDataListValues(data_list_items, - data_list_items)); + EXPECT_CALL( + autofill_client_, + UpdateAutofillPopupDataListValues(data_list_items, data_list_items)); external_delegate_->SetCurrentDataListValues(data_list_items, data_list_items); @@ -300,7 +296,7 @@ TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL( - manager_delegate_, + autofill_client_, ShowAutofillPopup( _, _, @@ -334,9 +330,9 @@ TEST_F(AutofillExternalDelegateUnitTest, NoAutofillWarningsWithoutSuggestions) { external_delegate_->OnQuery(kQueryId, form, field, element_bounds, true); - EXPECT_CALL(manager_delegate_, - ShowAutofillPopup(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(manager_delegate_, HideAutofillPopup()).Times(1); + EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _, _, _, _)) + .Times(0); + EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(1); // This should not call ShowAutofillPopup. std::vector<base::string16> autofill_item; @@ -359,7 +355,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { external_delegate_->DidSelectSuggestion(base::string16(), -1); // Ensure it doesn't try to fill the form in with the negative id. - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0); external_delegate_->DidAcceptSuggestion(base::string16(), -1); } @@ -390,17 +386,17 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { // Test that the popup is hidden once we are done editing the autofill field. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHidePopupAfterEditing) { - EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); + EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _, _, _, _)); autofill::GenerateTestAutofillPopup(external_delegate_.get()); - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); external_delegate_->DidEndTextFieldEditing(); } // Test that the driver is directed to accept the data list after being notified // that the user accepted the data list suggestion. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); base::string16 dummy_string(ASCIIToUTF16("baz qux")); EXPECT_CALL(*autofill_driver_, RendererShouldAcceptDataListSuggestion(dummy_string)); @@ -411,7 +407,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { // Test that the driver is directed to clear the form after being notified that // the user accepted the suggestion to clear the form. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) { - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledForm()); external_delegate_->DidAcceptSuggestion(base::string16(), @@ -435,7 +431,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideWarning) { // Ensure the popup tries to hide itself, since it is not allowed to show // anything. - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); external_delegate_->OnSuggestionsReturned(kQueryId, autofill_items, @@ -445,7 +441,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideWarning) { } TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { - EXPECT_CALL(manager_delegate_, HideAutofillPopup()); + EXPECT_CALL(autofill_client_, HideAutofillPopup()); base::string16 dummy_string(ASCIIToUTF16("baz foo")); EXPECT_CALL(*autofill_driver_, RendererShouldFillFieldWithValue(dummy_string)); diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index 5e69a73..370a8f0 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -21,10 +21,10 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/sequenced_worker_pool.h" #include "components/autofill/core/browser/autocomplete_history_manager.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_data_model.h" #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_field.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" #include "components/autofill/core/browser/autofill_manager_test_delegate.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_profile.h" @@ -140,7 +140,7 @@ void DeterminePossibleFieldTypesForUpload( // If it's a password field, set the type directly. if (field->form_control_type == "password") { - matching_types.insert(autofill::PASSWORD); + matching_types.insert(PASSWORD); } else { base::string16 value; base::TrimWhitespace(field->value, base::TRIM_ALL, &value); @@ -165,15 +165,15 @@ void DeterminePossibleFieldTypesForUpload( AutofillManager::AutofillManager( AutofillDriver* driver, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillDownloadManagerState enable_download_manager) : driver_(driver), - manager_delegate_(delegate), + client_(client), app_locale_(app_locale), - personal_data_(delegate->GetPersonalDataManager()), + personal_data_(client->GetPersonalDataManager()), autocomplete_history_manager_( - new AutocompleteHistoryManager(driver, delegate)), + new AutocompleteHistoryManager(driver, client)), metric_logger_(new AutofillMetrics), has_logged_autofill_enabled_(false), has_logged_address_suggestions_count_(false), @@ -186,9 +186,7 @@ AutofillManager::AutofillManager( weak_ptr_factory_(this) { if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { download_manager_.reset( - new AutofillDownloadManager(driver, - manager_delegate_->GetPrefs(), - this)); + new AutofillDownloadManager(driver, client_->GetPrefs(), this)); } } @@ -280,7 +278,7 @@ void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { } void AutofillManager::ShowAutofillSettings() { - manager_delegate_->ShowAutofillSettings(); + client_->ShowAutofillSettings(); } #if defined(OS_MACOSX) && !defined(OS_IOS) @@ -572,7 +570,7 @@ void AutofillManager::FillOrPreviewForm( autofill_field->is_autofilled = true; if (!is_credit_card && !value.empty()) - manager_delegate_->DidFillOrPreviewField(value, profile_full_name); + client_->DidFillOrPreviewField(value, profile_full_name); } break; } @@ -629,7 +627,7 @@ void AutofillManager::FillOrPreviewForm( result.fields[i].is_autofilled = true; if (should_notify) - manager_delegate_->DidFillOrPreviewField(value, profile_full_name); + client_->DidFillOrPreviewField(value, profile_full_name); } } } @@ -681,7 +679,7 @@ void AutofillManager::OnHidePopup() { if (!IsAutofillEnabled()) return; - manager_delegate_->HideAutofillPopup(); + client_->HideAutofillPopup(); } void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { @@ -712,8 +710,7 @@ const std::vector<FormStructure*>& AutofillManager::GetFormStructures() { return form_structures_.get(); } -void AutofillManager::SetTestDelegate( - autofill::AutofillManagerTestDelegate* delegate) { +void AutofillManager::SetTestDelegate(AutofillManagerTestDelegate* delegate) { test_delegate_ = delegate; } @@ -736,7 +733,7 @@ void AutofillManager::OnLoadedServerPredictions( // Forward form structures to the password generation manager to detect // account creation forms. - manager_delegate_->DetectAccountCreationForms(form_structures_.get()); + client_->DetectAccountCreationForms(form_structures_.get()); // If the corresponding flag is set, annotate forms with the predicted types. driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); @@ -747,7 +744,7 @@ void AutofillManager::OnDidEndTextFieldEditing() { } bool AutofillManager::IsAutofillEnabled() const { - return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); + return client_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); } void AutofillManager::ImportFormData(const FormStructure& submitted_form) { @@ -758,11 +755,12 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { // If credit card information was submitted, we need to confirm whether to // save it. if (imported_credit_card) { - manager_delegate_->ConfirmSaveCreditCard( + client_->ConfirmSaveCreditCard( *metric_logger_, base::Bind( base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), - base::Unretained(personal_data_), *imported_credit_card)); + base::Unretained(personal_data_), + *imported_credit_card)); } } @@ -805,7 +803,7 @@ void AutofillManager::UploadFormData(const FormStructure& submitted_form) { // contains a password field it will be uploaded to the server. If // |submitted_form| doesn't contain a password field, there is no side // effect from adding PASSWORD to |non_empty_types|. - non_empty_types.insert(autofill::PASSWORD); + non_empty_types.insert(PASSWORD); download_manager_->StartUploadRequest(submitted_form, was_autofilled, non_empty_types); @@ -870,14 +868,14 @@ void AutofillManager::Reset() { } AutofillManager::AutofillManager(AutofillDriver* driver, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, PersonalDataManager* personal_data) : driver_(driver), - manager_delegate_(delegate), + client_(client), app_locale_("en-US"), personal_data_(personal_data), autocomplete_history_manager_( - new AutocompleteHistoryManager(driver, delegate)), + new AutocompleteHistoryManager(driver, client)), metric_logger_(new AutofillMetrics), has_logged_autofill_enabled_(false), has_logged_address_suggestions_count_(false), @@ -889,7 +887,7 @@ AutofillManager::AutofillManager(AutofillDriver* driver, test_delegate_(NULL), weak_ptr_factory_(this) { DCHECK(driver_); - DCHECK(manager_delegate_); + DCHECK(client_); } void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { diff --git a/components/autofill/core/browser/autofill_manager.h b/components/autofill/core/browser/autofill_manager.h index 5f84ba9..120b14d 100644 --- a/components/autofill/core/browser/autofill_manager.h +++ b/components/autofill/core/browser/autofill_manager.h @@ -20,9 +20,9 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "components/autofill/core/browser/autocomplete_history_manager.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_download.h" #include "components/autofill/core/browser/autofill_driver.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/common/form_data.h" @@ -49,7 +49,7 @@ class AutofillDataModel; class AutofillDownloadManager; class AutofillExternalDelegate; class AutofillField; -class AutofillManagerDelegate; +class AutofillClient; class AutofillManagerTestDelegate; class AutofillMetrics; class AutofillProfile; @@ -78,7 +78,7 @@ class AutofillManager : public AutofillDownloadManager::Observer { #endif // defined(OS_MACOSX) && !defined(OS_IOS) AutofillManager(AutofillDriver* driver, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, const std::string& app_locale, AutofillDownloadManagerState enable_download_manager); virtual ~AutofillManager(); @@ -125,14 +125,12 @@ class AutofillManager : public AutofillDownloadManager::Observer { // Happens when the autocomplete dialog runs its callback when being closed. void RequestAutocompleteDialogClosed(); - autofill::AutofillManagerDelegate* delegate() const { - return manager_delegate_; - } + AutofillClient* client() const { return client_; } const std::string& app_locale() const { return app_locale_; } // Only for testing. - void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); + void SetTestDelegate(AutofillManagerTestDelegate* delegate); void OnFormsSeen(const std::vector<FormData>& forms, const base::TimeTicks& timestamp); @@ -177,7 +175,7 @@ class AutofillManager : public AutofillDownloadManager::Observer { protected: // Test code should prefer to use this constructor. AutofillManager(AutofillDriver* driver, - autofill::AutofillManagerDelegate* delegate, + AutofillClient* client, PersonalDataManager* personal_data); // Uploads the form data to the Autofill server. @@ -293,7 +291,7 @@ class AutofillManager : public AutofillDownloadManager::Observer { // outlive this object. AutofillDriver* driver_; - autofill::AutofillManagerDelegate* const manager_delegate_; + AutofillClient* const client_; std::string app_locale_; @@ -345,12 +343,12 @@ class AutofillManager : public AutofillDownloadManager::Observer { AutofillExternalDelegate* external_delegate_; // Delegate used in test to get notifications on certain events. - autofill::AutofillManagerTestDelegate* test_delegate_; + AutofillManagerTestDelegate* test_delegate_; base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; friend class AutofillManagerTest; - friend class autofill::FormStructureBrowserTest; + friend class FormStructureBrowserTest; FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DeterminePossibleFieldTypesForUpload); FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc index d8cc496..a8d3573 100644 --- a/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_manager_unittest.cc @@ -27,9 +27,9 @@ #include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/popup_item_ids.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_driver.h" #include "components/autofill/core/browser/test_autofill_external_delegate.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/common/autofill_pref_names.h" #include "components/autofill/core/common/form_data.h" @@ -359,9 +359,8 @@ void ExpectFilledCreditCardYearMonthWithYearMonth(int page_id, class MockAutocompleteHistoryManager : public AutocompleteHistoryManager { public: - MockAutocompleteHistoryManager(AutofillDriver* driver, - AutofillManagerDelegate* delegate) - : AutocompleteHistoryManager(driver, delegate) {} + MockAutocompleteHistoryManager(AutofillDriver* driver, AutofillClient* client) + : AutocompleteHistoryManager(driver, client) {} MOCK_METHOD1(OnFormSubmitted, void(const FormData& form)); @@ -385,9 +384,9 @@ class MockAutofillDriver : public TestAutofillDriver { class TestAutofillManager : public AutofillManager { public: TestAutofillManager(AutofillDriver* driver, - autofill::AutofillManagerDelegate* delegate, + autofill::AutofillClient* client, TestPersonalDataManager* personal_data) - : AutofillManager(driver, delegate, personal_data), + : AutofillManager(driver, client, personal_data), personal_data_(personal_data), autofill_enabled_(true) {} virtual ~TestAutofillManager() {} @@ -587,12 +586,12 @@ class TestAutofillExternalDelegate : public AutofillExternalDelegate { class AutofillManagerTest : public testing::Test { public: virtual void SetUp() OVERRIDE { - autofill_delegate_.SetPrefs(test::PrefServiceForTesting()); - personal_data_.set_database(autofill_delegate_.GetDatabase()); - personal_data_.SetPrefService(autofill_delegate_.GetPrefs()); + autofill_client_.SetPrefs(test::PrefServiceForTesting()); + personal_data_.set_database(autofill_client_.GetDatabase()); + personal_data_.SetPrefService(autofill_client_.GetPrefs()); autofill_driver_.reset(new MockAutofillDriver()); autofill_manager_.reset(new TestAutofillManager( - autofill_driver_.get(), &autofill_delegate_, &personal_data_)); + autofill_driver_.get(), &autofill_client_, &personal_data_)); external_delegate_.reset(new TestAutofillExternalDelegate( autofill_manager_.get(), @@ -674,7 +673,7 @@ class AutofillManagerTest : public testing::Test { protected: base::MessageLoop message_loop_; - TestAutofillManagerDelegate autofill_delegate_; + TestAutofillClient autofill_client_; scoped_ptr<MockAutofillDriver> autofill_driver_; scoped_ptr<TestAutofillManager> autofill_manager_; scoped_ptr<TestAutofillExternalDelegate> external_delegate_; @@ -1553,10 +1552,10 @@ TEST_F(AutofillManagerTest, FillAddressForm) { TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { personal_data_.ClearAutofillProfiles(); #if defined(OS_MACOSX) && !defined(OS_IOS) - autofill_delegate_.GetPrefs()->SetBoolean( + autofill_client_.GetPrefs()->SetBoolean( ::autofill::prefs::kAutofillUseMacAddressBook, true); #else - autofill_delegate_.GetPrefs()->SetBoolean( + autofill_client_.GetPrefs()->SetBoolean( ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); #endif // defined(OS_MACOSX) && !defined(OS_IOS) @@ -2314,15 +2313,13 @@ TEST_F(AutofillManagerTest, FormSubmitted) { // Test that when Autocomplete is enabled and Autofill is disabled, // form submissions are still received by AutocompleteHistoryManager. TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) { - TestAutofillManagerDelegate delegate; - autofill_manager_.reset(new TestAutofillManager( - autofill_driver_.get(), - &delegate, - NULL)); + TestAutofillClient client; + autofill_manager_.reset( + new TestAutofillManager(autofill_driver_.get(), &client, NULL)); autofill_manager_->set_autofill_enabled(false); scoped_ptr<MockAutocompleteHistoryManager> autocomplete_history_manager; autocomplete_history_manager.reset( - new MockAutocompleteHistoryManager(autofill_driver_.get(), &delegate)); + new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); autofill_manager_->autocomplete_history_manager_ = autocomplete_history_manager.Pass(); @@ -2341,11 +2338,9 @@ TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) { // Test that when Autocomplete is enabled and Autofill is disabled, // Autocomplete suggestions are still received. TEST_F(AutofillManagerTest, AutocompleteSuggestionsWhenAutofillDisabled) { - TestAutofillManagerDelegate delegate; - autofill_manager_.reset(new TestAutofillManager( - autofill_driver_.get(), - &delegate, - NULL)); + TestAutofillClient client; + autofill_manager_.reset( + new TestAutofillManager(autofill_driver_.get(), &client, NULL)); autofill_manager_->set_autofill_enabled(false); autofill_manager_->SetExternalDelegate(external_delegate_.get()); @@ -2482,7 +2477,7 @@ TEST_F(AutofillManagerTest, FormSubmittedWithDefaultValues) { // Checks that resetting the auxiliary profile enabled preference does the right // thing on all platforms. TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { - PrefService* prefs = autofill_delegate_.GetPrefs(); + PrefService* prefs = autofill_client_.GetPrefs(); #if defined(OS_MACOSX) || defined(OS_ANDROID) // Auxiliary profiles is implemented on Mac and Android only. // OSX: This preference exists for legacy reasons. It is no longer used. @@ -2842,11 +2837,11 @@ TEST_F(AutofillManagerTest, RemoveProfileVariant) { namespace { -class MockAutofillManagerDelegate : public TestAutofillManagerDelegate { +class MockAutofillClient : public TestAutofillClient { public: - MockAutofillManagerDelegate() {} + MockAutofillClient() {} - virtual ~MockAutofillManagerDelegate() {} + virtual ~MockAutofillClient() {} virtual void ShowRequestAutocompleteDialog( const FormData& form, @@ -2865,7 +2860,7 @@ class MockAutofillManagerDelegate : public TestAutofillManagerDelegate { private: scoped_ptr<FormStructure> user_supplied_data_; - DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); }; } // namespace diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h index 6f8e459..fd57267 100644 --- a/components/autofill/core/browser/autofill_metrics.h +++ b/components/autofill/core/browser/autofill_metrics.h @@ -9,7 +9,7 @@ #include <string> #include "base/basictypes.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/field_types.h" namespace base { diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc index e0708b1..14f3d2c 100644 --- a/components/autofill/core/browser/autofill_metrics_unittest.cc +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc @@ -17,8 +17,8 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/personal_data_manager.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_driver.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_field_data.h" @@ -165,9 +165,9 @@ class TestFormStructure : public FormStructure { class TestAutofillManager : public AutofillManager { public: TestAutofillManager(AutofillDriver* driver, - AutofillManagerDelegate* manager_delegate, + AutofillClient* autofill_client, TestPersonalDataManager* personal_manager) - : AutofillManager(driver, manager_delegate, personal_manager), + : AutofillManager(driver, autofill_client, personal_manager), autofill_enabled_(true) { set_metric_logger(new testing::NiceMock<MockAutofillMetrics>); } @@ -238,7 +238,7 @@ class AutofillMetricsTest : public testing::Test { protected: base::MessageLoop message_loop_; - TestAutofillManagerDelegate manager_delegate_; + TestAutofillClient autofill_client_; scoped_ptr<TestAutofillDriver> autofill_driver_; scoped_ptr<TestAutofillManager> autofill_manager_; scoped_ptr<TestPersonalDataManager> personal_data_; @@ -252,17 +252,17 @@ AutofillMetricsTest::~AutofillMetricsTest() { } void AutofillMetricsTest::SetUp() { - manager_delegate_.SetPrefs(test::PrefServiceForTesting()); + autofill_client_.SetPrefs(test::PrefServiceForTesting()); // Ensure Mac OS X does not pop up a modal dialog for the Address Book. - test::DisableSystemServices(manager_delegate_.GetPrefs()); + test::DisableSystemServices(autofill_client_.GetPrefs()); personal_data_.reset(new TestPersonalDataManager()); - personal_data_->set_database(manager_delegate_.GetDatabase()); - personal_data_->SetPrefService(manager_delegate_.GetPrefs()); + personal_data_->set_database(autofill_client_.GetDatabase()); + personal_data_->SetPrefService(autofill_client_.GetPrefs()); autofill_driver_.reset(new TestAutofillDriver()); autofill_manager_.reset(new TestAutofillManager( - autofill_driver_.get(), &manager_delegate_, personal_data_.get())); + autofill_driver_.get(), &autofill_client_, personal_data_.get())); external_delegate_.reset(new AutofillExternalDelegate( autofill_manager_.get(), @@ -585,7 +585,7 @@ TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { EXPECT_CALL(*personal_data_->metric_logger(), LogIsAutofillEnabledAtStartup(true)).Times(1); personal_data_->Init( - manager_delegate_.GetDatabase(), manager_delegate_.GetPrefs(), false); + autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), false); } // Test that we correctly log when Autofill is disabled. @@ -594,7 +594,7 @@ TEST_F(AutofillMetricsTest, AutofillIsDisabledAtStartup) { EXPECT_CALL(*personal_data_->metric_logger(), LogIsAutofillEnabledAtStartup(false)).Times(1); personal_data_->Init( - manager_delegate_.GetDatabase(), manager_delegate_.GetPrefs(), false); + autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), false); } // Test that we log the number of Autofill suggestions when filling a form. diff --git a/components/autofill/core/browser/test_autofill_client.cc b/components/autofill/core/browser/test_autofill_client.cc new file mode 100644 index 0000000..3b73339 --- /dev/null +++ b/components/autofill/core/browser/test_autofill_client.cc @@ -0,0 +1,76 @@ +// Copyright 2014 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 "components/autofill/core/browser/test_autofill_client.h" + +#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" + +namespace autofill { + +TestAutofillClient::TestAutofillClient() { +} +TestAutofillClient::~TestAutofillClient() { +} + +PersonalDataManager* TestAutofillClient::GetPersonalDataManager() { + return NULL; +} + +scoped_refptr<AutofillWebDataService> TestAutofillClient::GetDatabase() { + return scoped_refptr<AutofillWebDataService>(NULL); +} + +PrefService* TestAutofillClient::GetPrefs() { + return prefs_.get(); +} + +void TestAutofillClient::HideRequestAutocompleteDialog() { +} + +void TestAutofillClient::ShowAutofillSettings() { +} + +void TestAutofillClient::ConfirmSaveCreditCard( + const AutofillMetrics& metric_logger, + const base::Closure& save_card_callback) { +} + +void TestAutofillClient::ShowRequestAutocompleteDialog( + const FormData& form, + const GURL& source_url, + const ResultCallback& callback) { +} + +void TestAutofillClient::ShowAutofillPopup( + const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, + const std::vector<base::string16>& values, + const std::vector<base::string16>& labels, + const std::vector<base::string16>& icons, + const std::vector<int>& identifiers, + base::WeakPtr<AutofillPopupDelegate> delegate) { +} + +void TestAutofillClient::UpdateAutofillPopupDataListValues( + const std::vector<base::string16>& values, + const std::vector<base::string16>& labels) { +} + +void TestAutofillClient::HideAutofillPopup() { +} + +bool TestAutofillClient::IsAutocompleteEnabled() { + return true; +} + +void TestAutofillClient::DetectAccountCreationForms( + const std::vector<autofill::FormStructure*>& forms) { +} + +void TestAutofillClient::DidFillOrPreviewField( + const base::string16& autofilled_value, + const base::string16& profile_full_name) { +} + +} // namespace autofill diff --git a/components/autofill/core/browser/test_autofill_manager_delegate.h b/components/autofill/core/browser/test_autofill_client.h index 654e2c6..9ec8416 100644 --- a/components/autofill/core/browser/test_autofill_manager_delegate.h +++ b/components/autofill/core/browser/test_autofill_client.h @@ -1,28 +1,27 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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 COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_MANAGER_DELEGATE_H_ -#define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_MANAGER_DELEGATE_H_ +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ #include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/memory/scoped_ptr.h" #include "base/prefs/pref_service.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" namespace autofill { // This class is for easier writing of tests. -class TestAutofillManagerDelegate : public AutofillManagerDelegate { +class TestAutofillClient : public AutofillClient { public: - TestAutofillManagerDelegate(); - virtual ~TestAutofillManagerDelegate(); + TestAutofillClient(); + virtual ~TestAutofillClient(); - // AutofillManagerDelegate implementation. + // AutofillClient implementation. virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE; - virtual scoped_refptr<AutofillWebDataService> - GetDatabase() OVERRIDE; + virtual scoped_refptr<AutofillWebDataService> GetDatabase() OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; virtual void HideRequestAutocompleteDialog() OVERRIDE; virtual void ShowAutofillSettings() OVERRIDE; @@ -60,9 +59,9 @@ class TestAutofillManagerDelegate : public AutofillManagerDelegate { // NULL by default. scoped_ptr<PrefService> prefs_; - DISALLOW_COPY_AND_ASSIGN(TestAutofillManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(TestAutofillClient); }; } // namespace autofill -#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_MANAGER_DELEGATE_H_ +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ diff --git a/components/autofill/core/browser/test_autofill_manager_delegate.cc b/components/autofill/core/browser/test_autofill_manager_delegate.cc deleted file mode 100644 index f4840f9..0000000 --- a/components/autofill/core/browser/test_autofill_manager_delegate.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2013 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 "components/autofill/core/browser/test_autofill_manager_delegate.h" -#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" - -namespace autofill { - -TestAutofillManagerDelegate::TestAutofillManagerDelegate() {} -TestAutofillManagerDelegate::~TestAutofillManagerDelegate() {} - -PersonalDataManager* TestAutofillManagerDelegate::GetPersonalDataManager() { - return NULL; -} - -scoped_refptr<AutofillWebDataService> -TestAutofillManagerDelegate::GetDatabase() { - return scoped_refptr<AutofillWebDataService>(NULL); -} - -PrefService* TestAutofillManagerDelegate::GetPrefs() { return prefs_.get(); } - -void TestAutofillManagerDelegate::HideRequestAutocompleteDialog() {} - -void TestAutofillManagerDelegate::ShowAutofillSettings() {} - -void TestAutofillManagerDelegate::ConfirmSaveCreditCard( - const AutofillMetrics& metric_logger, - const base::Closure& save_card_callback) {} - -void TestAutofillManagerDelegate::ShowRequestAutocompleteDialog( - const FormData& form, - const GURL& source_url, - const ResultCallback& callback) {} - -void TestAutofillManagerDelegate::ShowAutofillPopup( - const gfx::RectF& element_bounds, - base::i18n::TextDirection text_direction, - const std::vector<base::string16>& values, - const std::vector<base::string16>& labels, - const std::vector<base::string16>& icons, - const std::vector<int>& identifiers, - base::WeakPtr<AutofillPopupDelegate> delegate) {} - -void TestAutofillManagerDelegate::UpdateAutofillPopupDataListValues( - const std::vector<base::string16>& values, - const std::vector<base::string16>& labels) {} - -void TestAutofillManagerDelegate::HideAutofillPopup() {} - -bool TestAutofillManagerDelegate::IsAutocompleteEnabled() { - return true; -} - -void TestAutofillManagerDelegate::DetectAccountCreationForms( - const std::vector<autofill::FormStructure*>& forms) {} - -void TestAutofillManagerDelegate::DidFillOrPreviewField( - const base::string16& autofilled_value, - const base::string16& profile_full_name) {} - -} // namespace autofill diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc index 5991279..822cc80 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.cc +++ b/components/password_manager/content/browser/content_password_manager_driver.cc @@ -24,11 +24,11 @@ namespace password_manager { ContentPasswordManagerDriver::ContentPasswordManagerDriver( content::WebContents* web_contents, PasswordManagerClient* client, - autofill::AutofillManagerDelegate* autofill_manager_delegate) + autofill::AutofillClient* autofill_client) : WebContentsObserver(web_contents), password_manager_(client), password_generation_manager_(client), - password_autofill_manager_(client, autofill_manager_delegate) { + password_autofill_manager_(client, autofill_client) { DCHECK(web_contents); } diff --git a/components/password_manager/content/browser/content_password_manager_driver.h b/components/password_manager/content/browser/content_password_manager_driver.h index 4fb2e90..d7fcc0f 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.h +++ b/components/password_manager/content/browser/content_password_manager_driver.h @@ -27,10 +27,9 @@ namespace password_manager { class ContentPasswordManagerDriver : public PasswordManagerDriver, public content::WebContentsObserver { public: - ContentPasswordManagerDriver( - content::WebContents* web_contents, - PasswordManagerClient* client, - autofill::AutofillManagerDelegate* autofill_manager_delegate); + ContentPasswordManagerDriver(content::WebContents* web_contents, + PasswordManagerClient* client, + autofill::AutofillClient* autofill_client); virtual ~ContentPasswordManagerDriver(); // PasswordManagerDriver implementation. diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc index bd078dc..01bf791 100644 --- a/components/password_manager/core/browser/password_autofill_manager.cc +++ b/components/password_manager/core/browser/password_autofill_manager.cc @@ -17,9 +17,9 @@ namespace password_manager { PasswordAutofillManager::PasswordAutofillManager( PasswordManagerClient* password_manager_client, - autofill::AutofillManagerDelegate* autofill_manager_delegate) + autofill::AutofillClient* autofill_client) : password_manager_client_(password_manager_client), - autofill_manager_delegate_(autofill_manager_delegate), + autofill_client_(autofill_client), weak_ptr_factory_(this) { } @@ -77,21 +77,20 @@ void PasswordAutofillManager::OnShowPasswordSuggestions( form_field_ = field; if (suggestions.empty()) { - autofill_manager_delegate_->HideAutofillPopup(); + autofill_client_->HideAutofillPopup(); return; } std::vector<base::string16> empty(suggestions.size()); std::vector<int> password_ids(suggestions.size(), autofill::POPUP_ITEM_ID_PASSWORD_ENTRY); - autofill_manager_delegate_->ShowAutofillPopup( - bounds, - field.text_direction, - suggestions, - realms, - empty, - password_ids, - weak_ptr_factory_.GetWeakPtr()); + autofill_client_->ShowAutofillPopup(bounds, + field.text_direction, + suggestions, + realms, + empty, + password_ids, + weak_ptr_factory_.GetWeakPtr()); } void PasswordAutofillManager::Reset() { @@ -127,7 +126,7 @@ void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value, int identifier) { bool success = FillSuggestion(form_field_, value); DCHECK(success); - autofill_manager_delegate_->HideAutofillPopup(); + autofill_client_->HideAutofillPopup(); } void PasswordAutofillManager::RemoveSuggestion(const base::string16& value, diff --git a/components/password_manager/core/browser/password_autofill_manager.h b/components/password_manager/core/browser/password_autofill_manager.h index 88ab801..8ab9369 100644 --- a/components/password_manager/core/browser/password_autofill_manager.h +++ b/components/password_manager/core/browser/password_autofill_manager.h @@ -8,7 +8,7 @@ #include <map> #include "base/gtest_prod_util.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_popup_delegate.h" #include "components/autofill/core/common/password_form_fill_data.h" @@ -23,9 +23,8 @@ class PasswordManagerClient; // This class is responsible for filling password forms. class PasswordAutofillManager : public autofill::AutofillPopupDelegate { public: - PasswordAutofillManager( - PasswordManagerClient* password_manager_client, - autofill::AutofillManagerDelegate* autofill_manager_delegate); + PasswordAutofillManager(PasswordManagerClient* password_manager_client, + autofill::AutofillClient* autofill_client); virtual ~PasswordAutofillManager(); // AutofillPopupDelegate implementation. @@ -95,7 +94,7 @@ class PasswordAutofillManager : public autofill::AutofillPopupDelegate { // Provides embedder-level operations on passwords. Must outlive |this|. PasswordManagerClient* const password_manager_client_; // weak - autofill::AutofillManagerDelegate* const autofill_manager_delegate_; // weak + autofill::AutofillClient* const autofill_client_; // weak // The form field on which the autofill popup is shown. autofill::FormFieldData form_field_; diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc index c96facb..3440764 100644 --- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc +++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc @@ -6,8 +6,8 @@ #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/popup_item_ids.h" +#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_driver.h" -#include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "components/password_manager/core/browser/password_autofill_manager.h" #include "components/password_manager/core/browser/stub_password_manager_client.h" #include "components/password_manager/core/browser/stub_password_manager_driver.h" @@ -51,8 +51,7 @@ class TestPasswordManagerClient : public StubPasswordManagerClient { MockPasswordManagerDriver driver_; }; -class MockAutofillManagerDelegate - : public autofill::TestAutofillManagerDelegate { +class MockAutofillClient : public autofill::TestAutofillClient { public: MOCK_METHOD7(ShowAutofillPopup, void(const gfx::RectF& element_bounds, @@ -87,9 +86,9 @@ class PasswordAutofillManagerTest : public testing::Test { void InitializePasswordAutofillManager( PasswordManagerClient* client, - autofill::AutofillManagerDelegate* autofill_manager_delegate) { + autofill::AutofillClient* autofill_client) { password_autofill_manager_.reset( - new PasswordAutofillManager(client, autofill_manager_delegate)); + new PasswordAutofillManager(client, autofill_client)); password_autofill_manager_->OnAddPasswordFormMapping(username_field_, fill_data_); } @@ -164,9 +163,8 @@ TEST_F(PasswordAutofillManagerTest, PreviewSuggestion) { // suggestions. TEST_F(PasswordAutofillManagerTest, ExternalDelegatePasswordSuggestions) { scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); - scoped_ptr<MockAutofillManagerDelegate> delegate( - new MockAutofillManagerDelegate); - InitializePasswordAutofillManager(client.get(), delegate.get()); + scoped_ptr<MockAutofillClient> autofill_client(new MockAutofillClient); + InitializePasswordAutofillManager(client.get(), autofill_client.get()); gfx::RectF element_bounds; std::vector<base::string16> suggestions; @@ -175,17 +173,20 @@ TEST_F(PasswordAutofillManagerTest, ExternalDelegatePasswordSuggestions) { realms.push_back(base::ASCIIToUTF16("http://foo.com/")); // The enums must be cast to ints to prevent compile errors on linux_rel. - EXPECT_CALL( - *delegate, - ShowAutofillPopup(_, _, _, _, _, - testing::ElementsAre( - autofill::POPUP_ITEM_ID_PASSWORD_ENTRY), - _)); + EXPECT_CALL(*autofill_client, + ShowAutofillPopup( + _, + _, + _, + _, + _, + testing::ElementsAre(autofill::POPUP_ITEM_ID_PASSWORD_ENTRY), + _)); password_autofill_manager_->OnShowPasswordSuggestions( username_field_, element_bounds, suggestions, realms); // Accepting a suggestion should trigger a call to hide the popup. - EXPECT_CALL(*delegate, HideAutofillPopup()); + EXPECT_CALL(*autofill_client, HideAutofillPopup()); password_autofill_manager_->DidAcceptSuggestion( suggestions[0], autofill::POPUP_ITEM_ID_PASSWORD_ENTRY); } |