diff options
22 files changed, 95 insertions, 51 deletions
diff --git a/android_webview/native/aw_autofill_client.cc b/android_webview/native/aw_autofill_client.cc index 4696293..b14b24e 100644 --- a/android_webview/native/aw_autofill_client.cc +++ b/android_webview/native/aw_autofill_client.cc @@ -167,6 +167,11 @@ void AwAutofillClient::OnFirstUserGestureObserved() { NOTIMPLEMENTED(); } +void AwAutofillClient::LinkClicked(const GURL& url, + WindowOpenDisposition disposition) { + NOTIMPLEMENTED(); +} + void AwAutofillClient::SuggestionSelected(JNIEnv* env, jobject object, jint position) { diff --git a/android_webview/native/aw_autofill_client.h b/android_webview/native/aw_autofill_client.h index b2b0de6..11085f4 100644 --- a/android_webview/native/aw_autofill_client.h +++ b/android_webview/native/aw_autofill_client.h @@ -91,6 +91,8 @@ class AwAutofillClient : public autofill::AutofillClient, const base::string16& autofilled_value, const base::string16& profile_full_name) override; virtual void OnFirstUserGestureObserved() override; + virtual void LinkClicked(const GURL& url, + WindowOpenDisposition disposition) override; void SuggestionSelected(JNIEnv* env, jobject obj, jint position); diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index e498059..a708c53 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -974,9 +974,7 @@ Signing in anyway will merge Chromium information like bookmarks, history, and o Details from your contacts can help you fill out forms more quickly in Chromium. </message> </if> - <message name="IDS_AUTOFILL_CC_INFOBAR_TEXT" desc="Text to show in the Autofill credit card request infobar."> - Do you want Chromium to save this credit card information for completing web forms? - </message> + <message name="IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX" desc="Checkbox that controls whether info the user types into the autofill dialog is saved by chrome."> Save details in Chromium </message> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 5720845..83ae3cd 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -11135,14 +11135,6 @@ Chrome ran out of memory. </message> </if> - <!-- Autofill infobar --> - <message name="IDS_AUTOFILL_CC_INFOBAR_ACCEPT" desc="Text to show for the Autofill credit card request infobar accept button."> - Save info - </message> - <message name="IDS_AUTOFILL_CC_INFOBAR_DENY" desc="Text to show for the Autofill credit card request infobar deny button."> - Don't save - </message> - <!-- Auto-login infobar --> <if expr="is_ios"> <message name="IDS_AUTOLOGIN_INFOBAR_MESSAGE" desc="The string shown in the infobar explaining that they can press one button to auto-login instead of entering their user name and password. [length: 60em]"> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index d67bd2d..e6cf908 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -899,9 +899,6 @@ Signing in anyway will merge Chrome information like bookmarks, history, and oth </message> </if> - <message name="IDS_AUTOFILL_CC_INFOBAR_TEXT" desc="Text to show in the Autofill credit card request infobar."> - Do you want Chrome to save this credit card information for completing web forms? - </message> <message name="IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX" desc="Checkbox that controls whether info the user types into the autofill dialog is saved by chrome."> Save details in Chrome </message> diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 890b614..ae2a5d2 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -421,7 +421,6 @@ </if> <structure type="chrome_scaled_image" name="IDR_INFOBAR_3D_BLOCKED" file="common/infobar_3d_blocked.png" /> <structure type="chrome_scaled_image" name="IDR_INFOBAR_ALT_NAV_URL" file="common/infobar_alt_nav_url.png" /> - <structure type="chrome_scaled_image" name="IDR_INFOBAR_AUTOFILL_CC" file="common/infobar_autofill_cc.png" /> <structure type="chrome_scaled_image" name="IDR_INFOBAR_AUTOLOGIN" file="common/infobar_autologin.png" /> <structure type="chrome_scaled_image" name="IDR_INFOBAR_COOKIE" file="common/infobar_cookie.png" /> <if expr="not is_android"> diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc index 3aa5b17..adc41d3 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" +#include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" #include "base/memory/scoped_ptr.h" #include "base/test/histogram_tester.h" @@ -43,6 +43,7 @@ class TestPersonalDataManager : public PersonalDataManager { class AutofillCCInfobarDelegateTest : public ChromeRenderViewHostTestHarness { public: + AutofillCCInfobarDelegateTest(); ~AutofillCCInfobarDelegateTest() override; void SetUp() override; @@ -52,8 +53,14 @@ class AutofillCCInfobarDelegateTest : public ChromeRenderViewHostTestHarness { scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate(); scoped_ptr<TestPersonalDataManager> personal_data_; + + private: + DISALLOW_COPY_AND_ASSIGN(AutofillCCInfobarDelegateTest); }; +AutofillCCInfobarDelegateTest::AutofillCCInfobarDelegateTest() { +} + AutofillCCInfobarDelegateTest::~AutofillCCInfobarDelegateTest() {} void AutofillCCInfobarDelegateTest::SetUp() { @@ -82,8 +89,9 @@ scoped_ptr<ConfirmInfoBarDelegate> AutofillCCInfobarDelegateTest::CreateDelegate() { base::HistogramTester histogram_tester; CreditCard credit_card; - scoped_ptr<ConfirmInfoBarDelegate> delegate( - AutofillCCInfoBarDelegate::Create(base::Bind( + scoped_ptr<ConfirmInfoBarDelegate> delegate(AutofillCCInfoBarDelegate::Create( + ChromeAutofillClient::FromWebContents(web_contents()), + base::Bind( base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard), base::Unretained(personal_data_.get()), credit_card))); histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc index 4f728ef..da0ebca 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/prefs/pref_service.h" -#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h" @@ -24,6 +23,7 @@ #include "chrome/common/url_constants.h" #include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/common/autofill_messages.h" +#include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" #include "components/autofill/core/common/autofill_pref_names.h" #include "components/password_manager/content/browser/content_password_manager_driver.h" #include "content/public/browser/render_frame_host.h" @@ -121,9 +121,9 @@ void ChromeAutofillClient::OnUnmaskVerificationResult(bool success) { void ChromeAutofillClient::ConfirmSaveCreditCard( const base::Closure& save_card_callback) { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(web_contents()); - AutofillCCInfoBarDelegate::Create(infobar_service, save_card_callback); + AutofillCCInfoBarDelegate::Create( + InfoBarService::FromWebContents(web_contents()), this, + save_card_callback); } bool ChromeAutofillClient::HasCreditCardScanFeature() { @@ -252,4 +252,10 @@ void ChromeAutofillClient::OnFirstUserGestureObserved() { new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); } +void ChromeAutofillClient::LinkClicked(const GURL& url, + WindowOpenDisposition disposition) { + web_contents()->OpenURL(content::OpenURLParams( + url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); +} + } // namespace autofill diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.h b/chrome/browser/ui/autofill/chrome_autofill_client.h index f22bf18..4017e02 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.h +++ b/chrome/browser/ui/autofill/chrome_autofill_client.h @@ -74,6 +74,7 @@ class ChromeAutofillClient void DidFillOrPreviewField(const base::string16& autofilled_value, const base::string16& profile_full_name) override; void OnFirstUserGestureObserved() override; + void LinkClicked(const GURL& url, WindowOpenDisposition disposition) override; // content::WebContentsObserver implementation. void RenderFrameDeleted(content::RenderFrameHost* rfh) override; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d343694..d0b0417 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -164,8 +164,6 @@ 'browser/bitmap_fetcher/bitmap_fetcher_service_factory.h', 'browser/autofill/android/personal_data_manager_android.cc', 'browser/autofill/android/personal_data_manager_android.h', - 'browser/autofill/autofill_cc_infobar_delegate.cc', - 'browser/autofill/autofill_cc_infobar_delegate.h', 'browser/autofill/personal_data_manager_factory.cc', 'browser/autofill/personal_data_manager_factory.h', 'browser/autofill/validation_rules_storage_factory.cc', diff --git a/components/autofill.gypi b/components/autofill.gypi index d6e4e33..682ddfe 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -97,6 +97,7 @@ 'autofill_regexes', 'components_resources.gyp:components_resources', 'components_strings.gyp:components_strings', + 'infobars_core', 'keyed_service_core', 'os_crypt', 'pref_registry', @@ -112,6 +113,8 @@ 'autofill/core/browser/autocomplete_history_manager.cc', 'autofill/core/browser/autocomplete_history_manager.h', 'autofill/core/browser/autofill-inl.h', + 'autofill/core/browser/autofill_cc_infobar_delegate.cc', + 'autofill/core/browser/autofill_cc_infobar_delegate.h', 'autofill/core/browser/autofill_country.cc', 'autofill/core/browser/autofill_country.h', 'autofill/core/browser/autofill_data_model.cc', diff --git a/components/autofill/core/browser/BUILD.gn b/components/autofill/core/browser/BUILD.gn index 615fa15..3a82eaf 100644 --- a/components/autofill/core/browser/BUILD.gn +++ b/components/autofill/core/browser/BUILD.gn @@ -46,6 +46,8 @@ static_library("browser") { "autocomplete_history_manager.cc", "autocomplete_history_manager.h", "autofill-inl.h", + "autofill_cc_infobar_delegate.cc", + "autofill_cc_infobar_delegate.h", "autofill_country.cc", "autofill_country.h", "autofill_data_model.cc", @@ -145,6 +147,7 @@ static_library("browser") { "//base:i18n", "//base:prefs", "//components/autofill/core/common", + "//components/infobars/core", "//components/keyed_service/core", "//components/os_crypt", "//components/pref_registry", diff --git a/components/autofill/core/browser/DEPS b/components/autofill/core/browser/DEPS index 5a50e09..2f26f85 100644 --- a/components/autofill/core/browser/DEPS +++ b/components/autofill/core/browser/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/infobars/core", "+components/keyed_service/core", "+components/webdata/common", "+components/webdata_services", @@ -13,4 +14,6 @@ include_rules = [ "+third_party/webrtc/libjingle", "+third_party/libaddressinput", # For address i18n. "+third_party/libphonenumber", # For phone number i18n. + "+ui/base", + "+ui/gfx", ] diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/components/autofill/core/browser/autofill_cc_infobar_delegate.cc index 430a79c..1f2bd35 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc +++ b/components/autofill/core/browser/autofill_cc_infobar_delegate.cc @@ -2,37 +2,37 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" +#include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" #include "base/logging.h" -#include "chrome/browser/infobars/infobar_service.h" -#include "chrome/grit/generated_resources.h" -#include "chrome/grit/google_chrome_strings.h" +#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/common/autofill_constants.h" #include "components/infobars/core/infobar.h" -#include "content/public/browser/page_navigator.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_delegate.h" +#include "components/infobars/core/infobar_manager.h" +#include "grit/components_scaled_resources.h" #include "grit/components_strings.h" -#include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "url/gurl.h" namespace autofill { // static void AutofillCCInfoBarDelegate::Create( - InfoBarService* infobar_service, + infobars::InfoBarManager* infobar_manager, + AutofillClient* autofill_client, const base::Closure& save_card_callback) { - infobar_service->AddInfoBar( - infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( - new AutofillCCInfoBarDelegate(save_card_callback)))); + infobar_manager->AddInfoBar( + infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( + new AutofillCCInfoBarDelegate(autofill_client, save_card_callback)))); } AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( + AutofillClient* autofill_client, const base::Closure& save_card_callback) : ConfirmInfoBarDelegate(), + autofill_client_(autofill_client), save_card_callback_(save_card_callback), had_user_interaction_(false) { AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); @@ -99,11 +99,10 @@ base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { } bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( - content::OpenURLParams( - GURL(autofill::kHelpURL), content::Referrer(), - (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, - ui::PAGE_TRANSITION_LINK, false)); + autofill_client_->LinkClicked( + GURL(autofill::kHelpURL), + (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition); + return false; } diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/components/autofill/core/browser/autofill_cc_infobar_delegate.h index 717cd90..b492fb7 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h +++ b/components/autofill/core/browser/autofill_cc_infobar_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_ #include "base/basictypes.h" #include "base/callback.h" @@ -14,31 +14,36 @@ #include "components/infobars/core/confirm_infobar_delegate.h" #include "ui/base/window_open_disposition.h" -class CreditCard; -class PersonalDataManager; -class InfoBarService; +namespace infobars { +class InfoBarManager; +} namespace autofill { +class AutofillClient; + // An InfoBar delegate that enables the user to allow or deny storing credit // card information gathered from a form submission. class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { public: // Creates an autofill credit card infobar and delegate and adds the infobar - // to |infobar_service|. - static void Create(InfoBarService* infobar_service, + // to |infobar_manager|. The |autofill_client| must outlive the infobar. + static void Create(infobars::InfoBarManager* infobar_manager, + AutofillClient* autofill_client, const base::Closure& save_card_callback); #if defined(UNIT_TEST) static scoped_ptr<ConfirmInfoBarDelegate> Create( + AutofillClient* autofill_client, const base::Closure& save_card_callback) { return scoped_ptr<ConfirmInfoBarDelegate>( - new AutofillCCInfoBarDelegate(save_card_callback)); + new AutofillCCInfoBarDelegate(autofill_client, save_card_callback)); } #endif private: - explicit AutofillCCInfoBarDelegate(const base::Closure& save_card_callback); + AutofillCCInfoBarDelegate(AutofillClient* autofill_client, + const base::Closure& save_card_callback); ~AutofillCCInfoBarDelegate() override; void LogUserAction(AutofillMetrics::InfoBarMetric user_action); @@ -55,6 +60,9 @@ class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { base::string16 GetLinkText() const override; bool LinkClicked(WindowOpenDisposition disposition) override; + // Performs navigation to handle any link click. Guaranteed to outlive us. + AutofillClient* const autofill_client_; + // The callback to save credit card if the user accepts the infobar. base::Closure save_card_callback_; @@ -68,4 +76,4 @@ class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { } // namespace autofill -#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_ diff --git a/components/autofill/core/browser/autofill_client.h b/components/autofill/core/browser/autofill_client.h index 47dca7d..6096d01 100644 --- a/components/autofill/core/browser/autofill_client.h +++ b/components/autofill/core/browser/autofill_client.h @@ -11,6 +11,7 @@ #include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" +#include "ui/base/window_open_disposition.h" namespace content { class RenderFrameHost; @@ -136,6 +137,10 @@ class AutofillClient { // Informs the client that a user gesture has been observed. virtual void OnFirstUserGestureObserved() = 0; + + // Opens |url| with the supplied |disposition|. + virtual void LinkClicked(const GURL& url, + WindowOpenDisposition disposition) = 0; }; } // namespace autofill diff --git a/components/autofill/core/browser/test_autofill_client.cc b/components/autofill/core/browser/test_autofill_client.cc index f224bc3..34523dd 100644 --- a/components/autofill/core/browser/test_autofill_client.cc +++ b/components/autofill/core/browser/test_autofill_client.cc @@ -89,4 +89,8 @@ void TestAutofillClient::DidFillOrPreviewField( void TestAutofillClient::OnFirstUserGestureObserved() { } +void TestAutofillClient::LinkClicked(const GURL& url, + WindowOpenDisposition disposition) { +} + } // namespace autofill diff --git a/components/autofill/core/browser/test_autofill_client.h b/components/autofill/core/browser/test_autofill_client.h index bb49a25..25c5308 100644 --- a/components/autofill/core/browser/test_autofill_client.h +++ b/components/autofill/core/browser/test_autofill_client.h @@ -50,6 +50,7 @@ class TestAutofillClient : public AutofillClient { void DidFillOrPreviewField(const base::string16& autofilled_value, const base::string16& profile_full_name) override; void OnFirstUserGestureObserved() override; + void LinkClicked(const GURL& url, WindowOpenDisposition disposition) override; void SetPrefs(scoped_ptr<PrefService> prefs) { prefs_ = prefs.Pass(); } diff --git a/components/autofill_strings.grdp b/components/autofill_strings.grdp index df8df9a..3236c54 100644 --- a/components/autofill_strings.grdp +++ b/components/autofill_strings.grdp @@ -135,4 +135,15 @@ Use password for: </message> + <!-- Autofill infobar --> + <message name="IDS_AUTOFILL_CC_INFOBAR_ACCEPT" desc="Text to show for the Autofill credit card request infobar accept button."> + Save info + </message> + <message name="IDS_AUTOFILL_CC_INFOBAR_DENY" desc="Text to show for the Autofill credit card request infobar deny button."> + Don't save + </message> + <message name="IDS_AUTOFILL_CC_INFOBAR_TEXT" desc="Text to show in the Autofill credit card request infobar."> + Do you want Chrome to save this credit card information for completing web forms? + </message> + </grit-part> diff --git a/components/resources/autofill_scaled_resources.grdp b/components/resources/autofill_scaled_resources.grdp index 153dffa..68a0088 100644 --- a/components/resources/autofill_scaled_resources.grdp +++ b/components/resources/autofill_scaled_resources.grdp @@ -8,4 +8,5 @@ <!-- This is not used on desktop, only Android, so use a placeholder file. --> <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_SCAN_NEW" file="common/autofill/cc-generic.png" /> <structure type="chrome_scaled_image" name="IDR_AUTOFILL_MAC_CONTACTS_ICON" file="common/autofill/mac_contacts_icon.png" /> + <structure type="chrome_scaled_image" name="IDR_INFOBAR_AUTOFILL_CC" file="common/autofill/infobar_autofill_cc.png" /> </grit-part> diff --git a/components/resources/default_100_percent/common/autofill/infobar_autofill_cc.png b/components/resources/default_100_percent/common/autofill/infobar_autofill_cc.png Binary files differnew file mode 100644 index 0000000..e0f8fc8 --- /dev/null +++ b/components/resources/default_100_percent/common/autofill/infobar_autofill_cc.png diff --git a/components/resources/default_200_percent/common/autofill/infobar_autofill_cc.png b/components/resources/default_200_percent/common/autofill/infobar_autofill_cc.png Binary files differnew file mode 100644 index 0000000..49cffc6 --- /dev/null +++ b/components/resources/default_200_percent/common/autofill/infobar_autofill_cc.png |