OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 12 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
16 #include "ui/gfx/size.h" | |
17 | 14 |
18 namespace chromeos { | 15 namespace chromeos { |
19 | 16 |
20 class BubbleFrameView; | 17 class BubbleFrameView; |
21 | 18 |
22 // Launches html dialog during OOBE/Login with specified URL and title. | 19 // Launches html dialog during OOBE/Login with specified URL and title. |
23 class LoginHtmlDialog : public HtmlDialogUIDelegate, | 20 class LoginHtmlDialog : public HtmlDialogUIDelegate { |
24 public content::NotificationObserver { | |
25 public: | 21 public: |
26 // Delegate class to get notifications from the dialog. | 22 // Delegate class to get notifications from the dialog. |
27 class Delegate { | 23 class Delegate { |
28 public: | 24 public: |
29 virtual ~Delegate() {} | 25 virtual ~Delegate() {} |
30 | 26 |
31 // Called when dialog has been closed. | 27 // Called when dialog has been closed. |
32 virtual void OnDialogClosed(); | 28 virtual void OnDialogClosed(); |
33 }; | 29 }; |
34 | 30 |
35 enum Style { | |
36 STYLE_GENERIC, // Use generic CreateChromeWindow as a host. | |
37 STYLE_BUBBLE // Use chromeos::BubbleWindow as a host. | |
38 }; | |
39 | |
40 LoginHtmlDialog(Delegate* delegate, | 31 LoginHtmlDialog(Delegate* delegate, |
41 gfx::NativeWindow parent_window, | 32 gfx::NativeWindow parent_window, |
42 const std::wstring& title, | 33 const std::wstring& title, |
43 const GURL& url, | 34 const GURL& url); |
44 Style style); | |
45 virtual ~LoginHtmlDialog(); | 35 virtual ~LoginHtmlDialog(); |
46 | 36 |
47 // Shows created dialog. | 37 // Shows created dialog. |
48 void Show(); | 38 void Show(); |
49 | 39 |
50 // Overrides default width/height for dialog. | 40 // Overrides default width/height for dialog. |
51 void SetDialogSize(int width, int height); | 41 void SetDialogSize(int width, int height); |
52 | 42 |
53 void set_url(const GURL& url) { url_ = url; } | 43 void set_url(const GURL& url) { url_ = url; } |
54 | 44 |
55 bool is_open() const { return is_open_; } | 45 bool is_open() const { return is_open_; } |
56 | 46 |
57 protected: | 47 protected: |
58 // HtmlDialogUIDelegate implementation. | 48 // HtmlDialogUIDelegate implementation. |
59 virtual bool IsDialogModal() const OVERRIDE; | 49 virtual bool IsDialogModal() const OVERRIDE; |
60 virtual string16 GetDialogTitle() const OVERRIDE; | 50 virtual string16 GetDialogTitle() const OVERRIDE; |
61 virtual GURL GetDialogContentURL() const OVERRIDE; | 51 virtual GURL GetDialogContentURL() const OVERRIDE; |
62 virtual void GetWebUIMessageHandlers( | 52 virtual void GetWebUIMessageHandlers( |
63 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 53 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; |
64 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 54 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
65 virtual std::string GetDialogArgs() const OVERRIDE; | 55 virtual std::string GetDialogArgs() const OVERRIDE; |
66 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 56 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
67 virtual void OnCloseContents( | 57 virtual void OnCloseContents( |
68 TabContents* source, bool* out_close_dialog) OVERRIDE; | 58 TabContents* source, bool* out_close_dialog) OVERRIDE; |
69 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 59 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
70 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 60 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
71 | 61 |
72 // content::NotificationObserver implementation. | |
73 virtual void Observe(int type, | |
74 const content::NotificationSource& source, | |
75 const content::NotificationDetails& details) OVERRIDE; | |
76 | |
77 private: | 62 private: |
78 // Notifications receiver. | 63 // Notifications receiver. |
79 Delegate* delegate_; | 64 Delegate* delegate_; |
80 | 65 |
81 gfx::NativeWindow parent_window_; | 66 gfx::NativeWindow parent_window_; |
82 string16 title_; | 67 string16 title_; |
83 GURL url_; | 68 GURL url_; |
84 Style style_; | |
85 content::NotificationRegistrar notification_registrar_; | |
86 BubbleFrameView* bubble_frame_view_; | |
87 bool is_open_; | 69 bool is_open_; |
88 | 70 |
89 // Dialog display size. | 71 // Dialog display size. |
90 int width_; | 72 int width_; |
91 int height_; | 73 int height_; |
92 | 74 |
93 DISALLOW_COPY_AND_ASSIGN(LoginHtmlDialog); | 75 DISALLOW_COPY_AND_ASSIGN(LoginHtmlDialog); |
94 }; | 76 }; |
95 | 77 |
96 } // namespace chromeos | 78 } // namespace chromeos |
97 | 79 |
98 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | 80 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ |
OLD | NEW |