license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | c633a49 | 2008-11-17 21:32:42 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H_ |
6 | #define CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
8 | #include <vector> | ||||
9 | |||||
[email protected] | 387b71b | 2009-02-26 01:51:21 | [diff] [blame] | 10 | #include "base/gfx/size.h" |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 11 | #include "chrome/browser/dom_ui/html_dialog_ui.h" |
12 | #include "chrome/common/ipc_message.h" | ||||
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 13 | #include "chrome/common/notification_observer.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | |
15 | // This class can only be used on the UI thread. | ||||
16 | class ModalHtmlDialogDelegate | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 17 | : public HtmlDialogUIDelegate, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 18 | public NotificationObserver { |
19 | public: | ||||
20 | ModalHtmlDialogDelegate(const GURL& url, | ||||
21 | int width, int height, | ||||
22 | const std::string& json_arguments, | ||||
23 | IPC::Message* sync_result, | ||||
24 | WebContents* contents); | ||||
25 | ~ModalHtmlDialogDelegate(); | ||||
26 | |||||
27 | // Notification service callback. | ||||
28 | virtual void Observe(NotificationType type, | ||||
29 | const NotificationSource& source, | ||||
30 | const NotificationDetails& details); | ||||
31 | |||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 32 | // HTMLDialogUIDelegate implementation: |
[email protected] | b0c6e5d | 2009-02-24 01:18:57 | [diff] [blame] | 33 | virtual bool IsDialogModal() const; |
34 | virtual std::wstring GetDialogTitle() const { return L"Google Gears"; } | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | virtual GURL GetDialogContentURL() const; |
[email protected] | 387b71b | 2009-02-26 01:51:21 | [diff] [blame] | 36 | virtual void GetDialogSize(gfx::Size* size) const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 37 | virtual std::string GetDialogArgs() const; |
38 | virtual void OnDialogClosed(const std::string& json_retval); | ||||
39 | |||||
40 | private: | ||||
[email protected] | c633a49 | 2008-11-17 21:32:42 | [diff] [blame] | 41 | // Invoked from the destructor or when we receive notification the web |
42 | // contents has been disconnnected. Removes the observer from the WebContents | ||||
43 | // and NULLs out contents_. | ||||
44 | void RemoveObserver(); | ||||
45 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 46 | // The WebContents that opened the dialog. |
47 | WebContents* contents_; | ||||
48 | |||||
49 | // The parameters needed to display a modal HTML dialog. | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 50 | HtmlDialogUI::HtmlDialogParams params_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | |
52 | // Once we get our reply in OnModalDialogResponse we'll need to respond to the | ||||
53 | // plugin using this |sync_result| pointer so we store it between calls. | ||||
54 | IPC::Message* sync_response_; | ||||
55 | |||||
[email protected] | c633a49 | 2008-11-17 21:32:42 | [diff] [blame] | 56 | DISALLOW_COPY_AND_ASSIGN(ModalHtmlDialogDelegate); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 57 | }; |
58 | |||||
[email protected] | c633a49 | 2008-11-17 21:32:42 | [diff] [blame] | 59 | #endif // CHROME_BROWSER_MODAL_HTML_DIALOG_DELEGATE_H_ |