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_ |