Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / ui / login_web_dialog.h
blob29ccb32854001e174c14c4d2b632ed8ab24a9f9c
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_
8 #include <string>
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"
16 #include "url/gurl.h"
18 namespace content {
19 class BrowserContext;
22 namespace chromeos {
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 {
29 public:
30 // Delegate class to get notifications from the dialog.
31 class Delegate {
32 public:
33 // Called when dialog has been closed.
34 virtual void OnDialogClosed();
36 protected:
37 virtual ~Delegate() {}
40 enum Style {
41 STYLE_GENERIC, // Use generic CreateChromeWindow as a host.
42 STYLE_BUBBLE // Use chromeos::BubbleWindow as a host.
45 LoginWebDialog(content::BrowserContext* browser_context,
46 Delegate* delegate,
47 gfx::NativeWindow parent_window,
48 const base::string16& title,
49 const GURL& url);
50 ~LoginWebDialog() override;
52 void Show();
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();
66 protected:
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;
94 private:
95 content::BrowserContext* browser_context_;
96 gfx::NativeWindow parent_window_;
97 // Notifications receiver.
98 Delegate* delegate_;
100 base::string16 title_;
101 GURL url_;
102 content::NotificationRegistrar notification_registrar_;
103 bool is_open_;
105 // Dialog display size.
106 int width_;
107 int height_;
109 DISALLOW_COPY_AND_ASSIGN(LoginWebDialog);
112 } // namespace chromeos
114 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_WEB_DIALOG_H_