1 // Copyright 2014 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_UI_LOGIN_WEB_DIALOG_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_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/geometry/size.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/web_dialogs/web_dialog_delegate.h"
24 class BubbleFrameView
;
26 // Launches web dialog during OOBE/Login with specified URL and title.
27 class LoginWebDialog
: public ui::WebDialogDelegate
,
28 public content::NotificationObserver
{
30 // Delegate class to get notifications from the dialog.
33 // Called when dialog has been closed.
34 virtual void OnDialogClosed();
37 virtual ~Delegate() {}
41 STYLE_GENERIC
, // Use generic CreateChromeWindow as a host.
42 STYLE_BUBBLE
// Use chromeos::BubbleWindow as a host.
45 LoginWebDialog(content::BrowserContext
* browser_context
,
47 gfx::NativeWindow parent_window
,
48 const base::string16
& title
,
50 ~LoginWebDialog() override
;
54 // Overrides default width/height for dialog.
55 void SetDialogSize(int width
, int height
);
57 // Overrides dialog title.
58 void SetDialogTitle(const base::string16
& title
);
60 void set_url(const GURL
& url
) { url_
= url
; }
62 bool is_open() const { return is_open_
; }
64 static content::WebContents
* GetCurrentWebContents();
67 // ui::WebDialogDelegate implementation.
68 ui::ModalType
GetDialogModalType() const override
;
69 base::string16
GetDialogTitle() const override
;
70 GURL
GetDialogContentURL() const override
;
71 void GetWebUIMessageHandlers(
72 std::vector
<content::WebUIMessageHandler
*>* handlers
) const override
;
73 void GetDialogSize(gfx::Size
* size
) const override
;
74 void GetMinimumDialogSize(gfx::Size
* size
) const override
;
75 std::string
GetDialogArgs() const override
;
76 void OnDialogShown(content::WebUI
* webui
,
77 content::RenderViewHost
* render_view_host
) override
;
78 // NOTE: This function deletes this object at the end.
79 void OnDialogClosed(const std::string
& json_retval
) override
;
80 void OnCloseContents(content::WebContents
* source
,
81 bool* out_close_dialog
) override
;
82 bool ShouldShowDialogTitle() const override
;
83 bool HandleContextMenu(const content::ContextMenuParams
& params
) override
;
84 bool HandleOpenURLFromTab(content::WebContents
* source
,
85 const content::OpenURLParams
& params
,
86 content::WebContents
** out_new_contents
) override
;
87 bool HandleShouldCreateWebContents() override
;
89 // content::NotificationObserver implementation.
90 void Observe(int type
,
91 const content::NotificationSource
& source
,
92 const content::NotificationDetails
& details
) override
;
95 content::BrowserContext
* browser_context_
;
96 gfx::NativeWindow parent_window_
;
97 // Notifications receiver.
100 base::string16 title_
;
102 content::NotificationRegistrar notification_registrar_
;
105 // Dialog display size.
109 DISALLOW_COPY_AND_ASSIGN(LoginWebDialog
);
112 } // namespace chromeos
114 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_WEB_DIALOG_H_