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