Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / web_modal / web_contents_modal_dialog_manager.h
index dc32674..326b4c1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 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.
 
@@ -8,7 +8,7 @@
 #include <deque>
 
 #include "base/memory/scoped_ptr.h"
-#include "components/web_modal/native_web_contents_modal_dialog_manager.h"
+#include "components/web_modal/single_web_contents_dialog_manager.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "content/public/browser/web_contents_user_data.h"
 #include "ui/gfx/native_widget_types.h"
@@ -19,7 +19,7 @@ class WebContentsModalDialogManagerDelegate;
 
 // Per-WebContents class to manage WebContents-modal dialogs.
 class WebContentsModalDialogManager
-    : public NativeWebContentsModalDialogManagerDelegate,
+    : public SingleWebContentsDialogManagerDelegate,
       public content::WebContentsObserver,
       public content::WebContentsUserData<WebContentsModalDialogManager> {
  public:
@@ -28,12 +28,19 @@ class WebContentsModalDialogManager
   WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; }
   void SetDelegate(WebContentsModalDialogManagerDelegate* d);
 
-  static NativeWebContentsModalDialogManager* CreateNativeManager(
-      NativeWebContentsModalDialogManagerDelegate* native_delegate);
+  static SingleWebContentsDialogManager* CreateNativeWebModalManager(
+      NativeWebContentsModalDialog dialog,
+      SingleWebContentsDialogManagerDelegate* native_delegate);
 
   // Shows the dialog as a web contents modal dialog. The dialog will notify via
   // WillClose() when it is being destroyed.
-  void ShowDialog(NativeWebContentsModalDialog dialog);
+  void ShowModalDialog(NativeWebContentsModalDialog dialog);
+
+  // Allow clients to supply their own native dialog manager. Suitable for
+  // bubble clients.
+  void ShowDialogWithManager(
+      NativeWebContentsModalDialog dialog,
+      scoped_ptr<SingleWebContentsDialogManager> manager);
 
   // Returns true if any dialogs are active and not closed.
   bool IsDialogActive() const;
@@ -46,7 +53,7 @@ class WebContentsModalDialogManager
   void SetCloseOnInterstitialPage(NativeWebContentsModalDialog dialog,
                                   bool close);
 
-  // Overriden from NativeWebContentsModalDialogManagerDelegate:
+  // Overriden from SingleWebContentsDialogManagerDelegate:
   virtual content::WebContents* GetWebContents() const OVERRIDE;
   // Called when a WebContentsModalDialogs we own is about to be closed.
   virtual void WillClose(NativeWebContentsModalDialog dialog) OVERRIDE;
@@ -59,9 +66,6 @@ class WebContentsModalDialogManager
 
     void CloseAllDialogs() { manager_->CloseAllDialogs(); }
     void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); }
-    void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) {
-      manager_->native_manager_.reset(delegate);
-    }
     void WebContentsWasShown() { manager_->WasShown(); }
     void WebContentsWasHidden() { manager_->WasHidden(); }
 
@@ -76,13 +80,16 @@ class WebContentsModalDialogManager
   friend class content::WebContentsUserData<WebContentsModalDialogManager>;
 
   struct DialogState {
-    explicit DialogState(NativeWebContentsModalDialog dialog);
+    DialogState(NativeWebContentsModalDialog dialog,
+                scoped_ptr<SingleWebContentsDialogManager> manager);
+    ~DialogState();
 
     NativeWebContentsModalDialog dialog;
+    scoped_ptr<SingleWebContentsDialogManager> manager;
     bool close_on_interstitial_webui;
   };
 
-  typedef std::deque<DialogState> WebContentsModalDialogList;
+  typedef std::deque<DialogState*> WebContentsModalDialogList;
 
   // Utility function to get the dialog state for a dialog.
   WebContentsModalDialogList::iterator FindDialogState(
@@ -103,15 +110,12 @@ class WebContentsModalDialogManager
   virtual void DidGetIgnoredUIEvent() OVERRIDE;
   virtual void WasShown() OVERRIDE;
   virtual void WasHidden() OVERRIDE;
-  virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
+  virtual void WebContentsDestroyed() OVERRIDE;
   virtual void DidAttachInterstitialPage() OVERRIDE;
 
   // Delegate for notifying our owner about stuff. Not owned by us.
   WebContentsModalDialogManagerDelegate* delegate_;
 
-  // Delegate for native UI-specific functions on the dialog.
-  scoped_ptr<NativeWebContentsModalDialogManager> native_manager_;
-
   // All active dialogs.
   WebContentsModalDialogList child_dialogs_;