1// Copyright (c) 2013 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. 4 5#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_ 6#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_ 7 8#include <string> 9 10#include "base/callback.h" 11#include "base/strings/string16.h" 12#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" 13#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 14#include "components/history/core/browser/history_types.h" 15#include "ui/base/ui_base_types.h" 16#include "ui/web_dialogs/web_dialog_delegate.h" 17 18class Browser; 19class Profile; 20class WebUIMessageHandler; 21 22namespace content { 23class WebContents; 24} 25 26// A tab-modal dialog to allow a user signing in with a managed account 27// to create a new Chrome profile. 28class ProfileSigninConfirmationDialog : public ui::WebDialogDelegate { 29 public: 30 // Create and show the dialog, which owns itself. 31 static void ShowDialog( 32 content::WebContents* web_contents, 33 Profile* profile, 34 const std::string& username, 35 ui::ProfileSigninConfirmationDelegate* delegate); 36 37 // Closes the dialog, which will delete itself. 38 void Close() const; 39 40 private: 41 ProfileSigninConfirmationDialog( 42 content::WebContents* web_contents, 43 Profile* profile, 44 const std::string& username, 45 ui::ProfileSigninConfirmationDelegate* delegate); 46 virtual ~ProfileSigninConfirmationDialog(); 47 48 // Shows the dialog and releases ownership of this object. It will 49 // delete itself when the dialog is closed. If |prompt_for_new_profile| 50 // is true, the dialog will offer to create a new profile before signin. 51 void Show(bool prompt_for_new_profile); 52 53 // WebDialogDelegate implementation. 54 virtual ui::ModalType GetDialogModalType() const OVERRIDE; 55 virtual base::string16 GetDialogTitle() const OVERRIDE; 56 virtual GURL GetDialogContentURL() const OVERRIDE; 57 virtual void GetWebUIMessageHandlers( 58 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; 59 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; 60 virtual std::string GetDialogArgs() const OVERRIDE; 61 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; 62 virtual void OnCloseContents(content::WebContents* source, 63 bool* out_close_dialog) OVERRIDE; 64 virtual bool ShouldShowDialogTitle() const OVERRIDE; 65 66 // Weak pointer to the containing view. 67 content::WebContents* web_contents_; 68 69 // Weak pointer to the profile being signed-in. 70 Profile* profile_; 71 72 // The GAIA username being signed in. 73 std::string username_; 74 75 // Weak pointer to the signin delegate. 76 ui::ProfileSigninConfirmationDelegate* signin_delegate_; 77 78 // Weak pointer to the dialog delegate. 79 ConstrainedWebDialogDelegate* dialog_delegate_; 80 81 // Whether to show the "Create a new profile" button. 82 bool prompt_for_new_profile_; 83 84 // Cleanup bookkeeping. Labeled mutable to get around inherited const 85 // label on GetWebUIMessageHandlers. 86 mutable bool closed_by_handler_; 87 88 DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialog); 89}; 90 91#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_ 92