Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / login_web_dialog.h
blob7249ba86f3b85628332ff7fb7dbc446f7e3c83da
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_
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/native_widget_types.h"
14 #include "ui/gfx/size.h"
15 #include "ui/web_dialogs/web_dialog_delegate.h"
16 #include "url/gurl.h"
18 namespace chromeos {
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 {
25 public:
26 // Delegate class to get notifications from the dialog.
27 class Delegate {
28 public:
29 // Called when dialog has been closed.
30 virtual void OnDialogClosed();
32 protected:
33 virtual ~Delegate() {}
36 enum Style {
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 base::string16& title,
44 const GURL& url,
45 Style style);
46 virtual ~LoginWebDialog();
48 void Show();
50 // Overrides default width/height for dialog.
51 void SetDialogSize(int width, int height);
53 // Overrides dialog title.
54 void SetDialogTitle(const base::string16& title);
56 void set_url(const GURL& url) { url_ = url; }
58 bool is_open() const { return is_open_; }
60 protected:
61 // ui::WebDialogDelegate implementation.
62 virtual ui::ModalType GetDialogModalType() const OVERRIDE;
63 virtual base::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;
83 private:
84 // Notifications receiver.
85 Delegate* delegate_;
87 gfx::NativeWindow parent_window_;
88 base::string16 title_;
89 GURL url_;
90 Style style_;
91 content::NotificationRegistrar notification_registrar_;
92 bool is_open_;
94 // Dialog display size.
95 int width_;
96 int height_;
98 DISALLOW_COPY_AND_ASSIGN(LoginWebDialog);
101 } // namespace chromeos
103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_WEB_DIALOG_H_