diff options
author | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 18:00:59 +0000 |
---|---|---|
committer | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 18:00:59 +0000 |
commit | e1534da657357421c3a23796417db7d58eaddcc6 (patch) | |
tree | b7d0705dd4d1f45cf121f5a89ac6e97e810a34f8 /chrome/browser/autofill | |
parent | 8a385580890bf6f9bb1902b180f49e4cd95d8176 (diff) | |
download | chromium_src-e1534da657357421c3a23796417db7d58eaddcc6.zip chromium_src-e1534da657357421c3a23796417db7d58eaddcc6.tar.gz chromium_src-e1534da657357421c3a23796417db7d58eaddcc6.tar.bz2 |
Removing AutocheckoutInfoBarDelegate
BUG=174732
Review URL: https://chromiumcodereview.appspot.com/12271014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autocheckout_infobar_delegate.cc | 121 | ||||
-rw-r--r-- | chrome/browser/autofill/autocheckout_infobar_delegate.h | 95 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 1 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_metrics.cc | 7 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_metrics.h | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_metrics_unittest.cc | 101 |
6 files changed, 1 insertions, 326 deletions
diff --git a/chrome/browser/autofill/autocheckout_infobar_delegate.cc b/chrome/browser/autofill/autocheckout_infobar_delegate.cc deleted file mode 100644 index 8c1ddd7..0000000 --- a/chrome/browser/autofill/autocheckout_infobar_delegate.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 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 "chrome/browser/autofill/autocheckout_infobar_delegate.h" - -#include "base/logging.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/api/infobars/infobar_service.h" -#include "chrome/browser/autofill/autocheckout_manager.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/page_navigator.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_delegate.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" - -namespace autofill { - -// static -void AutocheckoutInfoBarDelegate::Create( - const AutofillMetrics& metric_logger, - const GURL& source_url, - const content::SSLStatus& ssl_status, - AutocheckoutManager* autocheckout_manager, - InfoBarService* infobar_service) { - infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( - new AutocheckoutInfoBarDelegate(metric_logger, source_url, ssl_status, - autocheckout_manager, infobar_service))); -} - -AutocheckoutInfoBarDelegate::AutocheckoutInfoBarDelegate( - const AutofillMetrics& metric_logger, - const GURL& source_url, - const content::SSLStatus& ssl_status, - AutocheckoutManager* autocheckout_manager, - InfoBarService* infobar_service) - : ConfirmInfoBarDelegate(infobar_service), - metric_logger_(metric_logger), - autocheckout_manager_(autocheckout_manager), - source_url_(source_url), - ssl_status_(ssl_status), - had_user_interaction_(false) { - metric_logger_.LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); -} - -AutocheckoutInfoBarDelegate::~AutocheckoutInfoBarDelegate() { - if (!had_user_interaction_) - LogUserAction(AutofillMetrics::INFOBAR_IGNORED); -} - -void AutocheckoutInfoBarDelegate::LogUserAction( - AutofillMetrics::InfoBarMetric user_action) { - DCHECK(!had_user_interaction_); - metric_logger_.LogAutocheckoutInfoBarMetric(user_action); - had_user_interaction_ = true; -} - -void AutocheckoutInfoBarDelegate::InfoBarDismissed() { - LogUserAction(AutofillMetrics::INFOBAR_DENIED); -} - -gfx::Image* AutocheckoutInfoBarDelegate::GetIcon() const { - return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( - IDR_INFOBAR_AUTOFILL); -} - -InfoBarDelegate::Type AutocheckoutInfoBarDelegate::GetInfoBarType() const { - return PAGE_ACTION_TYPE; -} - -bool AutocheckoutInfoBarDelegate::ShouldExpireInternal( - const content::LoadCommittedDetails& details) const { - // The user has submitted a form, causing the page to navigate elsewhere. We - // want the infobar to be expired at this point, because the user has - // potentially started the checkout flow manually. - return true; -} - - -string16 AutocheckoutInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringUTF16(IDS_AUTOFILL_FLOW_INFOBAR_TEXT); -} - -string16 AutocheckoutInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - return l10n_util::GetStringUTF16((button == BUTTON_OK) ? - IDS_AUTOFILL_FLOW_INFOBAR_ACCEPT : IDS_AUTOFILL_FLOW_INFOBAR_DENY); -} - -bool AutocheckoutInfoBarDelegate::Accept() { - LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED); - autocheckout_manager_->ShowAutocheckoutDialog(source_url_, ssl_status_); - return true; -} - -bool AutocheckoutInfoBarDelegate::Cancel() { - LogUserAction(AutofillMetrics::INFOBAR_DENIED); - return true; -} - -string16 AutocheckoutInfoBarDelegate::GetLinkText() const { - return l10n_util::GetStringUTF16(IDS_LEARN_MORE); -} - -bool AutocheckoutInfoBarDelegate::LinkClicked( - WindowOpenDisposition disposition) { - // TODO(ramankk): Fix the help URL when we have one. - owner()->GetWebContents()->GetDelegate()->OpenURLFromTab( - owner()->GetWebContents(), - content::OpenURLParams(GURL(chrome::kAutofillHelpURL), - content::Referrer(), - NEW_FOREGROUND_TAB, - content::PAGE_TRANSITION_LINK, - false)); - return false; -} - -} // namespace autofill diff --git a/chrome/browser/autofill/autocheckout_infobar_delegate.h b/chrome/browser/autofill/autocheckout_infobar_delegate.h deleted file mode 100644 index 34c21e8..0000000 --- a/chrome/browser/autofill/autocheckout_infobar_delegate.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 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. - -#ifndef CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/gtest_prod_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/string16.h" -#include "chrome/browser/api/infobars/confirm_infobar_delegate.h" -#include "chrome/browser/autofill/autofill_metrics.h" -#include "content/public/common/ssl_status.h" -#include "googleurl/src/gurl.h" - -namespace content { -struct LoadCommittedDetails; -} - -namespace autofill { - -class AutocheckoutManager; - -// An InfoBar delegate that enables the user to allow or deny storing credit -// card information gathered from a form submission. -class AutocheckoutInfoBarDelegate : public ConfirmInfoBarDelegate { - public: - // Creates an autofillflow infobar delegate and adds it to |infobar_service|. - static void Create(const AutofillMetrics& metric_logger, - const GURL& source_url, - const content::SSLStatus& ssl_status, - AutocheckoutManager* autocheckout_manager, - InfoBarService* infobar_service); - -#if defined(UNIT_TEST) - static scoped_ptr<ConfirmInfoBarDelegate> Create( - const AutofillMetrics& metric_logger, - const GURL& source_url, - const content::SSLStatus& ssl_status, - AutocheckoutManager* autocheckout_manager) { - return scoped_ptr<ConfirmInfoBarDelegate>(new AutocheckoutInfoBarDelegate( - metric_logger, source_url, ssl_status, autocheckout_manager, NULL)); - } -#endif - - private: - AutocheckoutInfoBarDelegate(const AutofillMetrics& metric_logger, - const GURL& source_url, - const content::SSLStatus& ssl_status, - AutocheckoutManager* autocheckout_manager, - InfoBarService* infobar_service); - - virtual ~AutocheckoutInfoBarDelegate(); - - // Logs UMA metric for user action type. - void LogUserAction(AutofillMetrics::InfoBarMetric user_action); - - // ConfirmInfoBarDelegate: - virtual void InfoBarDismissed() OVERRIDE; - virtual gfx::Image* GetIcon() const OVERRIDE; - virtual Type GetInfoBarType() const OVERRIDE; - virtual bool ShouldExpireInternal( - const content::LoadCommittedDetails& details) const OVERRIDE; - virtual string16 GetMessageText() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual bool Cancel() OVERRIDE; - virtual string16 GetLinkText() const OVERRIDE; - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - - // For logging UMA metrics. - // Weak reference. Owned by the AutofillManager that initiated this infobar. - const AutofillMetrics& metric_logger_; - - // To callback AutocheckoutManager's ShowAutocheckoutDialog. - AutocheckoutManager* autocheckout_manager_; - - // URL of the page which triggered infobar. - GURL source_url_; - - // SSL status of the page which triggered infobar. - content::SSLStatus ssl_status_; - - // Did the user ever explicitly accept or dismiss this infobar? - bool had_user_interaction_; - - FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutocheckoutInfoBar); - - DISALLOW_COPY_AND_ASSIGN(AutocheckoutInfoBarDelegate); -}; - -} // namespace autofill - -#endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index df3571b..d49f16e 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -24,7 +24,6 @@ #include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/sync/profile_sync_service_base.h" #include "chrome/browser/autofill/autocheckout/whitelist_manager.h" -#include "chrome/browser/autofill/autocheckout_infobar_delegate.h" #include "chrome/browser/autofill/autocheckout_manager.h" #include "chrome/browser/autofill/autocomplete_history_manager.h" #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" diff --git a/chrome/browser/autofill/autofill_metrics.cc b/chrome/browser/autofill/autofill_metrics.cc index c8bbbd9..69e60fb 100644 --- a/chrome/browser/autofill/autofill_metrics.cc +++ b/chrome/browser/autofill/autofill_metrics.cc @@ -274,13 +274,6 @@ void AutofillMetrics::LogCreditCardInfoBarMetric(InfoBarMetric metric) const { NUM_INFO_BAR_METRICS); } -void AutofillMetrics::LogAutocheckoutInfoBarMetric(InfoBarMetric metric) const { - DCHECK(metric < NUM_INFO_BAR_METRICS); - - UMA_HISTOGRAM_ENUMERATION("Autofill.AutocheckoutInfoBar", metric, - NUM_INFO_BAR_METRICS); -} - void AutofillMetrics::LogRequestAutocompleteUiDuration( const base::TimeDelta& duration, autofill::DialogType dialog_type, diff --git a/chrome/browser/autofill/autofill_metrics.h b/chrome/browser/autofill/autofill_metrics.h index 32629f8..8a8a6fd 100644 --- a/chrome/browser/autofill/autofill_metrics.h +++ b/chrome/browser/autofill/autofill_metrics.h @@ -163,8 +163,6 @@ class AutofillMetrics { virtual void LogUserHappinessMetric(UserHappinessMetric metric) const; - virtual void LogAutocheckoutInfoBarMetric(InfoBarMetric metric) const; - // This should be called when the requestAutocomplete dialog, invoked by the // |requester|, is closed. |duration| should be the time elapsed between the // dialog being shown and it being closed. |dismissal_action| should indicate diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index 086c720..be238cb 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -8,7 +8,6 @@ #include "base/string16.h" #include "base/time.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/autofill/autocheckout_infobar_delegate.h" #include "chrome/browser/autofill/autocheckout_page_meta_data.h" #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" #include "chrome/browser/autofill/autofill_common_test.h" @@ -42,7 +41,6 @@ class MockAutofillMetrics : public AutofillMetrics { public: MockAutofillMetrics() {} MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); - MOCK_CONST_METHOD1(LogAutocheckoutInfoBarMetric, void(InfoBarMetric metric)); MOCK_CONST_METHOD1(LogDeveloperEngagementMetric, void(DeveloperEngagementMetric metric)); MOCK_CONST_METHOD3(LogHeuristicTypePrediction, @@ -262,25 +260,6 @@ class TestAutofillManager : public AutofillManager { DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); }; -class TestAutocheckoutManager : public autofill::AutocheckoutManager { - public: - explicit TestAutocheckoutManager(AutofillManager* autofill_manager) - : AutocheckoutManager(autofill_manager) { - } - - virtual void ShowAutocheckoutDialog( - const GURL& frame_url, - const content::SSLStatus& ssl_status) OVERRIDE { - // no-op. Just used as callback from autocheckout_infobar_delegate. - } - - virtual ~TestAutocheckoutManager() { - } - - private: - DISALLOW_COPY_AND_ASSIGN(TestAutocheckoutManager); -}; - } // namespace class AutofillMetricsTest : public ChromeRenderViewHostTestHarness { @@ -296,15 +275,11 @@ class AutofillMetricsTest : public ChromeRenderViewHostTestHarness { MockAutofillMetrics* metric_logger, CreditCard** created_card); - scoped_ptr<ConfirmInfoBarDelegate> CreateAutocheckoutDelegate( - MockAutofillMetrics* metric_logger); - content::TestBrowserThread ui_thread_; content::TestBrowserThread file_thread_; content::TestBrowserThread io_thread_; scoped_refptr<TestAutofillManager> autofill_manager_; - TestAutocheckoutManager autocheckout_manager_; TestPersonalDataManager personal_data_; private: @@ -317,8 +292,7 @@ AutofillMetricsTest::AutofillMetricsTest() : ChromeRenderViewHostTestHarness(), ui_thread_(BrowserThread::UI, &message_loop_), file_thread_(BrowserThread::FILE), - io_thread_(BrowserThread::IO), - autocheckout_manager_(NULL) { + io_thread_(BrowserThread::IO) { } AutofillMetricsTest::~AutofillMetricsTest() { @@ -382,20 +356,6 @@ scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( metric_logger); } -scoped_ptr<ConfirmInfoBarDelegate> -AutofillMetricsTest::CreateAutocheckoutDelegate( - MockAutofillMetrics* metric_logger) { - EXPECT_CALL(*metric_logger, - LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); - GURL url("www.google.com"); - content::SSLStatus ssl_status; - return autofill::AutocheckoutInfoBarDelegate::Create( - *metric_logger, - url, - ssl_status, - &autocheckout_manager_); -} - // Test that we log quality metrics appropriately. TEST_F(AutofillMetricsTest, QualityMetrics) { // Set up our form data. @@ -1235,65 +1195,6 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) { } } -// Test that autofill flow infobar metrics are logged correctly. -TEST_F(AutofillMetricsTest, AutocheckoutInfoBar) { - MockAutofillMetrics metric_logger; - ::testing::InSequence dummy; - - // Accept the infobar. - { - scoped_ptr<ConfirmInfoBarDelegate> infobar( - CreateAutocheckoutDelegate(&metric_logger)); - ASSERT_TRUE(infobar); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_ACCEPTED)).Times(1); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_IGNORED)).Times(0); - EXPECT_TRUE(infobar->Accept()); - } - - // Cancel the infobar. - { - scoped_ptr<ConfirmInfoBarDelegate> infobar( - CreateAutocheckoutDelegate(&metric_logger)); - ASSERT_TRUE(infobar); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_DENIED)).Times(1); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_IGNORED)).Times(0); - EXPECT_TRUE(infobar->Cancel()); - } - - // Dismiss the infobar. - { - scoped_ptr<ConfirmInfoBarDelegate> infobar( - CreateAutocheckoutDelegate(&metric_logger)); - ASSERT_TRUE(infobar); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_DENIED)).Times(1); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_IGNORED)).Times(0); - infobar->InfoBarDismissed(); - } - - // Ignore the infobar. - { - scoped_ptr<ConfirmInfoBarDelegate> infobar( - CreateAutocheckoutDelegate(&metric_logger)); - ASSERT_TRUE(infobar); - EXPECT_CALL(metric_logger, - LogAutocheckoutInfoBarMetric( - AutofillMetrics::INFOBAR_IGNORED)).Times(1); - } -} - - // Test that server query response experiment id metrics are logged correctly. TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) { MockAutofillMetrics metric_logger; |