Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Unified Diff: components/infobars/core/confirm_infobar_delegate_factory.h

Issue 812823002: Remove dependency of infobars component on the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests by instanciating a TestConfirmInfoBarDelegateFactory Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/infobars/core/confirm_infobar_delegate_factory.h
diff --git a/components/infobars/core/confirm_infobar_delegate_factory.h b/components/infobars/core/confirm_infobar_delegate_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..6aa16fce2c557c31a20d80d2771024e27bdffbf9
--- /dev/null
+++ b/components/infobars/core/confirm_infobar_delegate_factory.h
@@ -0,0 +1,46 @@
+// 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.
+
+#ifndef COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_FACTORY_H_
+#define COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_FACTORY_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace infobars {
+class InfoBar;
+}
+
+class ConfirmInfoBarDelegate;
+
+// ConfirmInfoBarDelegateFactory is an abstract singleton allowing the embedder
+// to inject an implementation of |ConfirmInfoBarDelegate::CreateInfoBar()|.
+class ConfirmInfoBarDelegateFactory {
+ public:
+ // Sets the global instance returned by |GetInstance|. The embedder owns the
+ // |instance| and is responsible for calling SetInstance(nullptr) before
+ // destroying it. Must be called before any method in infobars component.
+ static void SetInstance(ConfirmInfoBarDelegateFactory* instance);
+
+ protected:
+ ConfirmInfoBarDelegateFactory();
+ virtual ~ConfirmInfoBarDelegateFactory();
+
+ // Returns the global ConfirmInfoBarDelegateFactory instance.
+ static ConfirmInfoBarDelegateFactory* GetInstance();
+
+ private:
+ // ConfirmInfoBarDelegate is the sole client of this factory. To keep the
+ // interface sealed, all methods are private and the class is marked as a
+ // friend.
+ friend class ConfirmInfoBarDelegate;
+
+ // Returns a confirm infobar that owns |delegate|
+ virtual scoped_ptr<infobars::InfoBar> CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate> delegate) = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegateFactory);
+};
+
+#endif // COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698