1854bb53438d1e966d468795b983de79f5f5605abGreg Clayton// Copyright 2014 The Chromium Authors. All rights reserved. 2854bb53438d1e966d468795b983de79f5f5605abGreg Clayton// Use of this source code is governed by a BSD-style license that can be 3854bb53438d1e966d468795b983de79f5f5605abGreg Clayton// found in the LICENSE file. 4854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 5854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_WEB_DIALOG_H_ 6854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#define CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_WEB_DIALOG_H_ 7854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 8854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include <string> 9854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 10854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "base/compiler_specific.h" 11854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "content/public/browser/notification_observer.h" 12854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "content/public/browser/notification_registrar.h" 13854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "ui/gfx/native_widget_types.h" 14854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "ui/gfx/size.h" 15854bb53438d1e966d468795b983de79f5f5605abGreg Clayton#include "ui/web_dialogs/web_dialog_delegate.h" 163cc7b7f4651b5b2e91f6179c8c96bfb380d95560Chris Lattner#include "url/gurl.h" 173cc7b7f4651b5b2e91f6179c8c96bfb380d95560Chris Lattner 183cc7b7f4651b5b2e91f6179c8c96bfb380d95560Chris Lattnernamespace content { 19854bb53438d1e966d468795b983de79f5f5605abGreg Claytonclass BrowserContext; 20854bb53438d1e966d468795b983de79f5f5605abGreg Clayton} 21854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 22854bb53438d1e966d468795b983de79f5f5605abGreg Claytonnamespace chromeos { 23854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 24854bb53438d1e966d468795b983de79f5f5605abGreg Claytonclass BubbleFrameView; 25854bb53438d1e966d468795b983de79f5f5605abGreg Clayton 26854bb53438d1e966d468795b983de79f5f5605abGreg Clayton// Launches web dialog during OOBE/Login with specified URL and title. 27854bb53438d1e966d468795b983de79f5f5605abGreg Claytonclass LoginWebDialog : public ui::WebDialogDelegate, 28854bb53438d1e966d468795b983de79f5f5605abGreg Clayton public content::NotificationObserver { 29854bb53438d1e966d468795b983de79f5f5605abGreg Clayton public: 30854bb53438d1e966d468795b983de79f5f5605abGreg Clayton // Delegate class to get notifications from the dialog. 31854bb53438d1e966d468795b983de79f5f5605abGreg Clayton class Delegate { 32854bb53438d1e966d468795b983de79f5f5605abGreg Clayton public: 33854bb53438d1e966d468795b983de79f5f5605abGreg Clayton // Called when dialog has been closed. 34 virtual void OnDialogClosed(); 35 36 protected: 37 virtual ~Delegate() {} 38 }; 39 40 enum Style { 41 STYLE_GENERIC, // Use generic CreateChromeWindow as a host. 42 STYLE_BUBBLE // Use chromeos::BubbleWindow as a host. 43 }; 44 45 LoginWebDialog(content::BrowserContext* browser_context, 46 Delegate* delegate, 47 gfx::NativeWindow parent_window, 48 const base::string16& title, 49 const GURL& url, 50 Style style); 51 virtual ~LoginWebDialog(); 52 53 void Show(); 54 55 // Overrides default width/height for dialog. 56 void SetDialogSize(int width, int height); 57 58 // Overrides dialog title. 59 void SetDialogTitle(const base::string16& title); 60 61 void set_url(const GURL& url) { url_ = url; } 62 63 bool is_open() const { return is_open_; } 64 65 static content::WebContents* GetCurrentWebContents(); 66 67 protected: 68 // ui::WebDialogDelegate implementation. 69 virtual ui::ModalType GetDialogModalType() const OVERRIDE; 70 virtual base::string16 GetDialogTitle() const OVERRIDE; 71 virtual GURL GetDialogContentURL() const OVERRIDE; 72 virtual void GetWebUIMessageHandlers( 73 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; 74 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; 75 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE; 76 virtual std::string GetDialogArgs() const OVERRIDE; 77 virtual void OnDialogShown( 78 content::WebUI* webui, 79 content::RenderViewHost* render_view_host) OVERRIDE; 80 // NOTE: This function deletes this object at the end. 81 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; 82 virtual void OnCloseContents( 83 content::WebContents* source, bool* out_close_dialog) OVERRIDE; 84 virtual bool ShouldShowDialogTitle() const OVERRIDE; 85 virtual bool HandleContextMenu( 86 const content::ContextMenuParams& params) OVERRIDE; 87 88 // content::NotificationObserver implementation. 89 virtual void Observe(int type, 90 const content::NotificationSource& source, 91 const content::NotificationDetails& details) OVERRIDE; 92 93 private: 94 content::BrowserContext* browser_context_; 95 gfx::NativeWindow parent_window_; 96 // Notifications receiver. 97 Delegate* delegate_; 98 99 base::string16 title_; 100 GURL url_; 101 Style style_; 102 content::NotificationRegistrar notification_registrar_; 103 bool is_open_; 104 105 // Dialog display size. 106 int width_; 107 int height_; 108 109 DISALLOW_COPY_AND_ASSIGN(LoginWebDialog); 110}; 111 112} // namespace chromeos 113 114#endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_WEB_DIALOG_H_ 115