summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 23:42:25 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 23:42:25 +0000
commit87c64eaa8a7011f76da7e0ff0800d802a7f54f30 (patch)
treea89f5d29b447685814f79bfb4b2aa11fb3fc8e5c
parenta24c929b5310862f2565ddf42f884d0e892c1f87 (diff)
downloadchromium_src-87c64eaa8a7011f76da7e0ff0800d802a7f54f30.zip
chromium_src-87c64eaa8a7011f76da7e0ff0800d802a7f54f30.tar.gz
chromium_src-87c64eaa8a7011f76da7e0ff0800d802a7f54f30.tar.bz2
Misc. cleanup:
* Shorten code * Eliminate using directives * Rename "infobar" to "delegate" in a few places for clarity * Add a few DCHECKs BUG=none TEST=none R=dmazzoni@chromium.org, isherman@chromium.org, jam@chromium.org Review URL: https://codereview.chromium.org/18209021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211254 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/accessibility/accessibility_extension_apitest.cc3
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc38
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.cc6
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc5
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc26
5 files changed, 33 insertions, 45 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_apitest.cc b/chrome/browser/accessibility/accessibility_extension_apitest.cc
index c5d3151b..29e54c4 100644
--- a/chrome/browser/accessibility/accessibility_extension_apitest.cc
+++ b/chrome/browser/accessibility/accessibility_extension_apitest.cc
@@ -28,8 +28,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_GetAlertsForTab) {
const char kAlertMessage[] = "Simple Alert Infobar.";
SimpleAlertInfoBarDelegate::Create(infobar_service,
InfoBarDelegate::kNoIconID,
- ASCIIToUTF16(kAlertMessage),
- false);
+ ASCIIToUTF16(kAlertMessage), false);
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
ASSERT_TRUE(RunExtensionTest("accessibility/get_alerts_for_tab")) << message_;
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index 3bb5a64..55959e9 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -51,11 +51,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/keycodes/keyboard_codes.h"
-using content::RenderViewHost;
-using content::RenderViewHostTester;
-using content::WebContents;
-
-using testing::Invoke;
namespace autofill {
@@ -138,7 +133,7 @@ class WindowedPersonalDataManagerObserver
}
virtual ~WindowedPersonalDataManagerObserver() {
- if (infobar_service_ && infobar_service_->infobar_count() > 0)
+ if (infobar_service_ && (infobar_service_->infobar_count() > 0))
infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
}
@@ -168,14 +163,13 @@ class WindowedPersonalDataManagerObserver
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
- // Accept in the infobar.
+ EXPECT_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, type);
infobar_service_ = InfoBarService::FromWebContents(
browser_->tab_strip_model()->GetActiveWebContents());
- InfoBarDelegate* infobar = infobar_service_->infobar_at(0);
-
- ConfirmInfoBarDelegate* confirm_infobar =
- infobar->AsConfirmInfoBarDelegate();
- confirm_infobar->Accept();
+ ConfirmInfoBarDelegate* infobar_delegate =
+ infobar_service_->infobar_at(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(infobar_delegate);
+ infobar_delegate->Accept();
}
private:
@@ -387,7 +381,7 @@ class AutofillTest : public InProcessBrowserTest {
EXPECT_EQ(expected_value, value);
}
- RenderViewHost* render_view_host() {
+ content::RenderViewHost* render_view_host() {
return browser()->tab_strip_model()->GetActiveWebContents()->
GetRenderViewHost();
}
@@ -902,9 +896,10 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillAfterReload) {
// Reload the page.
LOG(WARNING) << "Reloading the page.";
- WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
- tab->GetController().Reload(false);
- content::WaitForLoadStop(tab);
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ web_contents->GetController().Reload(false);
+ content::WaitForLoadStop(web_contents);
// Invoke Autofill.
LOG(WARNING) << "Trying to fill the form.";
@@ -951,19 +946,18 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) {
// Get translation bar.
LanguageDetectionDetails details;
details.adopted_language = "ja";
- RenderViewHostTester::TestOnMessageReceived(
+ content::RenderViewHostTester::TestOnMessageReceived(
render_view_host(),
ChromeViewHostMsg_TranslateLanguageDetermined(0, details, true));
- TranslateInfoBarDelegate* infobar = InfoBarService::FromWebContents(
+ TranslateInfoBarDelegate* delegate = InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->infobar_at(0)->
AsTranslateInfoBarDelegate();
-
- ASSERT_TRUE(infobar != NULL);
+ ASSERT_TRUE(delegate);
EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE,
- infobar->infobar_type());
+ delegate->infobar_type());
// Simulate translation button press.
- infobar->Translate();
+ delegate->Translate();
// Simulate the translate script being retrieved.
// Pass fake google.translate lib as the translate script.
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
index a55a4d0..ff744d4 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
@@ -27,14 +27,12 @@ void AutofillCCInfoBarDelegate::Create(
infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
new AutofillCCInfoBarDelegate(
infobar_service, metric_logger, save_card_callback)));
- metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
}
// static
scoped_ptr<ConfirmInfoBarDelegate> AutofillCCInfoBarDelegate::CreateForTesting(
const AutofillMetrics* metric_logger,
const base::Closure& save_card_callback) {
- metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
return scoped_ptr<ConfirmInfoBarDelegate>(
new AutofillCCInfoBarDelegate(NULL, metric_logger, save_card_callback));
}
@@ -46,7 +44,9 @@ AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
: ConfirmInfoBarDelegate(infobar_service),
metric_logger_(metric_logger),
save_card_callback_(save_card_callback),
- had_user_interaction_(false) {}
+ had_user_interaction_(false) {
+ metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
+}
AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
if (!had_user_interaction_)
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index bd66049..cc4cfe8 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1240,9 +1240,8 @@ void InfoBarCountObserver::Observe(
}
void InfoBarCountObserver::CheckCount() {
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents_);
- if (infobar_service->infobar_count() != target_count_)
+ if (InfoBarService::FromWebContents(web_contents_)->infobar_count() !=
+ target_count_)
return;
if (automation_.get()) {
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index b37e935..1caeddf 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -2108,6 +2108,7 @@ void TestingAutomationProvider::PerformActionOnInfobar(
reply.SendError("Invalid or missing args");
return;
}
+ size_t infobar_index = static_cast<size_t>(infobar_index_int);
WebContents* web_contents =
browser->tab_strip_model()->GetWebContentsAt(tab_index);
@@ -2115,37 +2116,32 @@ void TestingAutomationProvider::PerformActionOnInfobar(
reply.SendError(base::StringPrintf("No such tab at index %d", tab_index));
return;
}
+
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
-
- InfoBarDelegate* infobar = NULL;
- size_t infobar_index = static_cast<size_t>(infobar_index_int);
if (infobar_index >= infobar_service->infobar_count()) {
reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS,
infobar_index));
return;
}
- infobar = infobar_service->infobar_at(infobar_index);
+ InfoBarDelegate* infobar = infobar_service->infobar_at(infobar_index);
- if ("dismiss" == action) {
+ if (action == "dismiss") {
infobar->InfoBarDismissed();
infobar_service->RemoveInfoBar(infobar);
reply.SendSuccess(NULL);
return;
}
- if ("accept" == action || "cancel" == action) {
- ConfirmInfoBarDelegate* confirm_infobar;
- if (!(confirm_infobar = infobar->AsConfirmInfoBarDelegate())) {
+ if ((action == "accept") || (action == "cancel")) {
+ ConfirmInfoBarDelegate* delegate = infobar->AsConfirmInfoBarDelegate();
+ if (!delegate) {
reply.SendError("Not a confirm infobar");
return;
}
- if ("accept" == action) {
- if (confirm_infobar->Accept())
- infobar_service->RemoveInfoBar(infobar);
- } else if ("cancel" == action) {
- if (confirm_infobar->Cancel())
- infobar_service->RemoveInfoBar(infobar);
- }
+ bool remove_infobar = (action == "accept") ?
+ delegate->Accept() : delegate->Cancel();
+ if (remove_infobar)
+ infobar_service->RemoveInfoBar(infobar);
reply.SendSuccess(NULL);
return;
}