summaryrefslogtreecommitdiffstats
path: root/components/infobars
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2014-12-22 09:30:59 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-22 17:31:51 +0000
commit316da458d4d1ea846f078efaf71ae1f23964f42e (patch)
tree97be3296df5195fdd697ab72738145d800b5f93c /components/infobars
parenta84772b7edfdc4f83e0b6b0831085657a8818334 (diff)
downloadchromium_src-316da458d4d1ea846f078efaf71ae1f23964f42e.zip
chromium_src-316da458d4d1ea846f078efaf71ae1f23964f42e.tar.gz
chromium_src-316da458d4d1ea846f078efaf71ae1f23964f42e.tar.bz2
Remove dependency of infobars component on the embedder
Add a virtual method InfoBarManager::CreateConfirmInfoBar that allow the embedder to use UI specific implementation of ConfirmInfoBar. Port all client code to use this virtual method instead of the static method ConfirmInfoBarDelegate::CreateInfoBar. Implements the InfoBarService::CreateConfirmInfoBar method for the different UI (views, android, cocoa) and for TestInfoBarManager. BUG=386171 TBR=jam@chromium.org TBR=jochen@chromium.org Review URL: https://codereview.chromium.org/812823002 Cr-Commit-Position: refs/heads/master@{#309437}
Diffstat (limited to 'components/infobars')
-rw-r--r--components/infobars/core/confirm_infobar_delegate.cc5
-rw-r--r--components/infobars/core/confirm_infobar_delegate.h6
-rw-r--r--components/infobars/core/infobar_manager.h6
-rw-r--r--components/infobars/test/BUILD.gn17
-rw-r--r--components/infobars/test/infobar_test.cc21
5 files changed, 10 insertions, 45 deletions
diff --git a/components/infobars/core/confirm_infobar_delegate.cc b/components/infobars/core/confirm_infobar_delegate.cc
index 0c2e59e..9c00449a5 100644
--- a/components/infobars/core/confirm_infobar_delegate.cc
+++ b/components/infobars/core/confirm_infobar_delegate.cc
@@ -4,6 +4,8 @@
#include "components/infobars/core/confirm_infobar_delegate.h"
+#include "base/logging.h"
+#include "components/infobars/core/infobar.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
@@ -57,9 +59,6 @@ bool ConfirmInfoBarDelegate::ShouldExpireInternal(
InfoBarDelegate::ShouldExpireInternal(details);
}
-// ConfirmInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
-// files.
-
bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
ConfirmInfoBarDelegate* confirm_delegate =
delegate->AsConfirmInfoBarDelegate();
diff --git a/components/infobars/core/confirm_infobar_delegate.h b/components/infobars/core/confirm_infobar_delegate.h
index 1e1930d..0f35f8c 100644
--- a/components/infobars/core/confirm_infobar_delegate.h
+++ b/components/infobars/core/confirm_infobar_delegate.h
@@ -8,9 +8,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "components/infobars/core/infobar_delegate.h"
+#include "components/infobars/core/infobar_manager.h"
namespace infobars {
class InfoBar;
+class InfoBarManager;
}
// An interface derived from InfoBarDelegate implemented by objects wishing to
@@ -66,10 +68,6 @@ class ConfirmInfoBarDelegate : public infobars::InfoBarDelegate {
protected:
ConfirmInfoBarDelegate();
- // Returns a confirm infobar that owns |delegate|.
- static scoped_ptr<infobars::InfoBar> CreateInfoBar(
- scoped_ptr<ConfirmInfoBarDelegate> delegate);
-
bool ShouldExpireInternal(const NavigationDetails& details) const override;
private:
diff --git a/components/infobars/core/infobar_manager.h b/components/infobars/core/infobar_manager.h
index 532566e..5685a03 100644
--- a/components/infobars/core/infobar_manager.h
+++ b/components/infobars/core/infobar_manager.h
@@ -11,6 +11,8 @@
#include "base/observer_list.h"
#include "components/infobars/core/infobar_delegate.h"
+class ConfirmInfoBarDelegate;
+
namespace content {
class WebContents;
}
@@ -94,6 +96,10 @@ class InfoBarManager {
// Returns the active entry ID.
virtual int GetActiveEntryID() = 0;
+ // Returns a confirm infobar that owns |delegate|.
+ virtual scoped_ptr<infobars::InfoBar> CreateConfirmInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate> delegate) = 0;
+
protected:
// Notifies the observer in |observer_list_|.
// TODO(droger): Absorb these methods back into their callers once virtual
diff --git a/components/infobars/test/BUILD.gn b/components/infobars/test/BUILD.gn
deleted file mode 100644
index 637738f..0000000
--- a/components/infobars/test/BUILD.gn
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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.
-
-source_set("test_support") {
- testonly = true
-
- sources = [
- "infobar_test.cc",
- ]
-
- deps = [
- "//base",
- "//components/infobars/core",
- "//skia",
- ]
-}
diff --git a/components/infobars/test/infobar_test.cc b/components/infobars/test/infobar_test.cc
deleted file mode 100644
index 1fef50f..0000000
--- a/components/infobars/test/infobar_test.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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 "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "components/infobars/core/confirm_infobar_delegate.h"
-#include "components/infobars/core/infobar.h"
-
-// Provides definitions of static variables and functions that are declared in
-// the component but defined in the embedder.
-// TODO(blundell): The component shouldn't be declaring statics that it's not
-// defining; instead, this information should be obtained via a client,
-// which can have a test implementation. crbug.com/386171
-
-// Some components' unittests exercise code that requires that
-// ConfirmInfoBarDelegate::CreateInfoBar() return a non-NULL infobar.
-scoped_ptr<infobars::InfoBar> ConfirmInfoBarDelegate::CreateInfoBar(
- scoped_ptr<ConfirmInfoBarDelegate> delegate) {
- return scoped_ptr<infobars::InfoBar>(new infobars::InfoBar(delegate.Pass()));
-}