blob: c20d94a8b6d5383b1508ac2cdaa2f453835d7632 [file] [log] [blame]
initial.commit09911bf2008-07-26 23:55:291// Copyright 2008, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30#ifndef CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H__
31#define CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H__
32
33#include <vector>
34
35#include "chrome/browser/dom_ui/html_dialog_contents.h"
36#include "chrome/common/notification_service.h"
37
38// This class can only be used on the UI thread.
39class ModalHtmlDialogDelegate
40 : public HtmlDialogContentsDelegate,
41 public NotificationObserver {
42 public:
43 ModalHtmlDialogDelegate(const GURL& url,
44 int width, int height,
45 const std::string& json_arguments,
46 IPC::Message* sync_result,
47 WebContents* contents);
48 ~ModalHtmlDialogDelegate();
49
50 // Notification service callback.
51 virtual void Observe(NotificationType type,
52 const NotificationSource& source,
53 const NotificationDetails& details);
54
55 // ChromeViews::WindowDelegate implementation:
56 virtual bool IsModal() const;
57
58 // ModalHtmlDialogContents::ModalHTMLDialogContentsDelegate implementation:
59 virtual GURL GetDialogContentURL() const;
60 virtual void GetDialogSize(CSize* size) const;
61 virtual std::string GetDialogArgs() const;
62 virtual void OnDialogClosed(const std::string& json_retval);
63
64 private:
65 // The WebContents that opened the dialog.
66 WebContents* contents_;
67
68 // The parameters needed to display a modal HTML dialog.
69 HtmlDialogContents::HtmlDialogParams params_;
70
71 // Once we get our reply in OnModalDialogResponse we'll need to respond to the
72 // plugin using this |sync_result| pointer so we store it between calls.
73 IPC::Message* sync_response_;
74
75 DISALLOW_EVIL_CONSTRUCTORS(ModalHtmlDialogDelegate);
76};
77
78#endif // CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H__