| Index: chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| index 229dd78b834cf6cfb3f524b42c692db777571b73..39643a74fa971ba6cb90532a6070cd93ebd0a682 100644
|
| --- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| +++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/browsing_data/browsing_data_helper.h"
|
| #include "chrome/browser/browsing_data/browsing_data_remover.h"
|
| #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
|
| +#include "chrome/browser/infobars/infobar_responder.h"
|
| #include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/notifications/notification_test_util.h"
|
| #include "chrome/browser/notifications/platform_notification_service_impl.h"
|
| @@ -32,9 +33,6 @@
|
| #include "components/content_settings/core/common/content_settings.h"
|
| #include "components/content_settings/core/common/content_settings_types.h"
|
| #include "components/gcm_driver/gcm_client.h"
|
| -#include "components/infobars/core/confirm_infobar_delegate.h"
|
| -#include "components/infobars/core/infobar.h"
|
| -#include "components/infobars/core/infobar_manager.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| @@ -46,50 +44,6 @@
|
| #endif
|
|
|
| namespace {
|
| -// Responds to a confirm infobar by accepting or cancelling it. Responds to at
|
| -// most one infobar.
|
| -class InfoBarResponder : public infobars::InfoBarManager::Observer {
|
| - public:
|
| - InfoBarResponder(Browser* browser, bool accept)
|
| - : infobar_service_(InfoBarService::FromWebContents(
|
| - browser->tab_strip_model()->GetActiveWebContents())),
|
| - accept_(accept),
|
| - has_observed_(false) {
|
| - infobar_service_->AddObserver(this);
|
| - }
|
| -
|
| - ~InfoBarResponder() override { infobar_service_->RemoveObserver(this); }
|
| -
|
| - // infobars::InfoBarManager::Observer
|
| - void OnInfoBarAdded(infobars::InfoBar* infobar) override {
|
| - if (has_observed_)
|
| - return;
|
| - has_observed_ = true;
|
| - ConfirmInfoBarDelegate* delegate =
|
| - infobar->delegate()->AsConfirmInfoBarDelegate();
|
| - DCHECK(delegate);
|
| -
|
| - // Respond to the infobar asynchronously, like a person.
|
| - base::MessageLoop::current()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(
|
| - &InfoBarResponder::Respond, base::Unretained(this), delegate));
|
| - }
|
| -
|
| - private:
|
| - void Respond(ConfirmInfoBarDelegate* delegate) {
|
| - if (accept_) {
|
| - delegate->Accept();
|
| - } else {
|
| - delegate->Cancel();
|
| - }
|
| - }
|
| -
|
| - InfoBarService* infobar_service_;
|
| - bool accept_;
|
| - bool has_observed_;
|
| -};
|
| -
|
| // Class to instantiate on the stack that is meant to be used with
|
| // FakeGCMProfileService. The ::Run() method follows the signature of
|
| // FakeGCMProfileService::UnregisterCallback.
|
| @@ -222,6 +176,11 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
|
|
|
| virtual Browser* GetBrowser() const { return browser(); }
|
|
|
| + InfoBarService* GetInfoBarService() {
|
| + return InfoBarService::FromWebContents(
|
| + GetBrowser()->tab_strip_model()->GetActiveWebContents());
|
| + }
|
| +
|
| private:
|
| scoped_ptr<net::SpawnedTestServer> https_server_;
|
| gcm::FakeGCMProfileService* gcm_service_;
|
| @@ -255,7 +214,7 @@ void PushMessagingBrowserTest::TryToRegisterSuccessfully(
|
| EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| EXPECT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder accepting_responder(GetBrowser(), true);
|
| + InfoBarResponder accepting_responder(GetInfoBarService(), true);
|
| EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result));
|
| EXPECT_EQ("permission status - granted", script_result);
|
|
|
| @@ -289,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
|
| ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| ASSERT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder accepting_responder(GetBrowser(), true);
|
| + InfoBarResponder accepting_responder(GetInfoBarService(), true);
|
| ASSERT_TRUE(RunScript("registerPush()", &script_result));
|
| EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1-0", script_result);
|
|
|
| @@ -305,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
|
| ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| ASSERT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder cancelling_responder(GetBrowser(), false);
|
| + InfoBarResponder cancelling_responder(GetInfoBarService(), false);
|
| ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
|
| ASSERT_EQ("permission status - denied", script_result);
|
|
|
| @@ -320,7 +279,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterFailureNoManifest) {
|
| ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| ASSERT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder accepting_responder(GetBrowser(), true);
|
| + InfoBarResponder accepting_responder(GetInfoBarService(), true);
|
| ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
|
| ASSERT_EQ("permission status - granted", script_result);
|
|
|
| @@ -610,7 +569,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysGranted) {
|
| ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| ASSERT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder accepting_responder(GetBrowser(), true);
|
| + InfoBarResponder accepting_responder(GetInfoBarService(), true);
|
| ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
|
| EXPECT_EQ("permission status - granted", script_result);
|
|
|
| @@ -627,7 +586,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysDenied) {
|
| ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| ASSERT_EQ("ok - service worker registered", script_result);
|
|
|
| - InfoBarResponder cancelling_responder(GetBrowser(), false);
|
| + InfoBarResponder cancelling_responder(GetInfoBarService(), false);
|
| ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
|
| EXPECT_EQ("permission status - denied", script_result);
|
|
|
|
|