profile_signin_confirmation_dialog.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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/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"
18
19class Browser;
20class Profile;
21class WebUIMessageHandler;
22
23namespace content {
24class WebContents;
25}
26
27// A tab-modal dialog to allow a user signing in with a managed account
28// to create a new Chrome profile.
29class ProfileSigninConfirmationDialog : public ui::WebDialogDelegate {
30 public:
31  // Create and show the dialog, which owns itself.
32  static void ShowDialog(
33      content::WebContents* web_contents,
34      Profile* profile,
35      const std::string& username,
36      ui::ProfileSigninConfirmationDelegate* delegate);
37
38  // Closes the dialog, which will delete itself.
39  void Close() const;
40
41 private:
42  ProfileSigninConfirmationDialog(
43      content::WebContents* web_contents,
44      Profile* profile,
45      const std::string& username,
46      ui::ProfileSigninConfirmationDelegate* delegate);
47  virtual ~ProfileSigninConfirmationDialog();
48
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);
53
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;
66
67  // Weak pointer to the containing view.
68  content::WebContents* web_contents_;
69
70  // Weak pointer to the profile being signed-in.
71  Profile* profile_;
72
73  // The GAIA username being signed in.
74  std::string username_;
75
76  // Weak pointer to the signin delegate.
77  ui::ProfileSigninConfirmationDelegate* signin_delegate_;
78
79  // Weak pointer to the dialog delegate.
80  ConstrainedWebDialogDelegate* dialog_delegate_;
81
82  // Whether to show the "Create a new profile" button.
83  bool prompt_for_new_profile_;
84
85  // Cleanup bookkeeping.  Labeled mutable to get around inherited const
86  // label on GetWebUIMessageHandlers.
87  mutable bool closed_by_handler_;
88
89  DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialog);
90};
91
92#endif  // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_
93