OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "chrome/browser/ui/webui/web_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" | |
16 #include "ui/gfx/size.h" | |
17 | |
18 namespace chromeos { | |
19 | |
20 class BubbleFrameView; | |
21 | |
22 // Launches web dialog during OOBE/Login with specified URL and title. | |
23 class LoginHtmlDialog : public WebDialogDelegate, | |
24 public content::NotificationObserver { | |
25 public: | |
26 // Delegate class to get notifications from the dialog. | |
27 class Delegate { | |
28 public: | |
29 virtual ~Delegate() {} | |
30 | |
31 // Called when dialog has been closed. | |
32 virtual void OnDialogClosed(); | |
33 }; | |
34 | |
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, | |
41 gfx::NativeWindow parent_window, | |
42 const std::wstring& title, | |
43 const GURL& url, | |
44 Style style); | |
45 virtual ~LoginHtmlDialog(); | |
46 | |
47 // Shows created dialog. | |
48 void Show(); | |
49 | |
50 // Overrides default width/height for dialog. | |
51 void SetDialogSize(int width, int height); | |
52 | |
53 // Overrides dialog title. | |
54 void SetDialogTitle(const string16& title); | |
55 | |
56 void set_url(const GURL& url) { url_ = url; } | |
57 | |
58 bool is_open() const { return is_open_; } | |
59 | |
60 protected: | |
61 // WebDialogDelegate implementation. | |
62 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | |
63 virtual string16 GetDialogTitle() const OVERRIDE; | |
64 virtual GURL GetDialogContentURL() const OVERRIDE; | |
65 virtual void GetWebUIMessageHandlers( | |
66 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; | |
67 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | |
68 virtual std::string GetDialogArgs() const OVERRIDE; | |
69 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | |
70 virtual void OnCloseContents( | |
71 content::WebContents* source, bool* out_close_dialog) OVERRIDE; | |
72 virtual bool ShouldShowDialogTitle() const OVERRIDE; | |
73 virtual bool HandleContextMenu( | |
74 const content::ContextMenuParams& params) OVERRIDE; | |
75 | |
76 // content::NotificationObserver implementation. | |
77 virtual void Observe(int type, | |
78 const content::NotificationSource& source, | |
79 const content::NotificationDetails& details) OVERRIDE; | |
80 | |
81 private: | |
82 // Notifications receiver. | |
83 Delegate* delegate_; | |
84 | |
85 gfx::NativeWindow parent_window_; | |
86 string16 title_; | |
87 GURL url_; | |
88 Style style_; | |
89 content::NotificationRegistrar notification_registrar_; | |
90 BubbleFrameView* bubble_frame_view_; | |
91 bool is_open_; | |
92 | |
93 // Dialog display size. | |
94 int width_; | |
95 int height_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(LoginHtmlDialog); | |
98 }; | |
99 | |
100 } // namespace chromeos | |
101 | |
102 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_HTML_DIALOG_H_ | |
OLD | NEW |