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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_WEB_DIALOG_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_WEB_DIALOG_H_
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/size.h"
15 #include "ui/web_dialogs/web_dialog_delegate.h"
20 class BubbleFrameView;
22 // Launches web dialog during OOBE/Login with specified URL and title.
23 class LoginWebDialog : public ui::WebDialogDelegate,
24 public content::NotificationObserver {
26 // Delegate class to get notifications from the dialog.
29 // Called when dialog has been closed.
30 virtual void OnDialogClosed();
33 virtual ~Delegate() {}
37 STYLE_GENERIC, // Use generic CreateChromeWindow as a host.
38 STYLE_BUBBLE // Use chromeos::BubbleWindow as a host.
41 LoginWebDialog(Delegate* delegate,
42 gfx::NativeWindow parent_window,
43 const string16& title,
46 virtual ~LoginWebDialog();
50 // Overrides default width/height for dialog.
51 void SetDialogSize(int width, int height);
53 // Overrides dialog title.
54 void SetDialogTitle(const string16& title);
56 void set_url(const GURL& url) { url_ = url; }
58 bool is_open() const { return is_open_; }
61 // ui::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 void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE;
69 virtual std::string GetDialogArgs() const OVERRIDE;
70 // NOTE: This function deletes this object at the end.
71 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
72 virtual void OnCloseContents(
73 content::WebContents* source, bool* out_close_dialog) OVERRIDE;
74 virtual bool ShouldShowDialogTitle() const OVERRIDE;
75 virtual bool HandleContextMenu(
76 const content::ContextMenuParams& params) OVERRIDE;
78 // content::NotificationObserver implementation.
79 virtual void Observe(int type,
80 const content::NotificationSource& source,
81 const content::NotificationDetails& details) OVERRIDE;
84 // Notifications receiver.
87 gfx::NativeWindow parent_window_;
91 content::NotificationRegistrar notification_registrar_;
94 // Dialog display size.
98 DISALLOW_COPY_AND_ASSIGN(LoginWebDialog);
101 } // namespace chromeos
103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_WEB_DIALOG_H_