profile_signin_confirmation_dialog.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/callback.h"
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/common/cancelable_request.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/history/history_types.h"
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/ui_base_types.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/web_dialogs/web_dialog_delegate.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class Browser;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Profile;
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebUIMessageHandler;
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content {
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class WebContents;
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// A tab-modal dialog to allow a user signing in with a managed account
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// to create a new Chrome profile.
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ProfileSigninConfirmationDialog : public ui::WebDialogDelegate {
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Create and show the dialog, which owns itself.
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static void ShowDialog(
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      content::WebContents* web_contents,
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      Profile* profile,
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const std::string& username,
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      ui::ProfileSigninConfirmationDelegate* delegate);
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Closes the dialog, which will delete itself.
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void Close() const;
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ProfileSigninConfirmationDialog(
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      content::WebContents* web_contents,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      Profile* profile,
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::string& username,
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      ui::ProfileSigninConfirmationDelegate* delegate);
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~ProfileSigninConfirmationDialog();
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Shows the dialog and releases ownership of this object. It will
50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // delete itself when the dialog is closed. If |prompt_for_new_profile|
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // is true, the dialog will offer to create a new profile before signin.
52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void Show(bool prompt_for_new_profile);
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // WebDialogDelegate implementation.
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ui::ModalType GetDialogModalType() const OVERRIDE;
56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetDialogTitle() const OVERRIDE;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual GURL GetDialogContentURL() const OVERRIDE;
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetWebUIMessageHandlers(
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE;
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual std::string GetDialogArgs() const OVERRIDE;
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnCloseContents(content::WebContents* source,
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                               bool* out_close_dialog) OVERRIDE;
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ShouldShowDialogTitle() const OVERRIDE;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the containing view.
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  content::WebContents* web_contents_;
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the profile being signed-in.
71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  Profile* profile_;
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The GAIA username being signed in.
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string username_;
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the signin delegate.
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ui::ProfileSigninConfirmationDelegate* signin_delegate_;
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the dialog delegate.
80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ConstrainedWebDialogDelegate* dialog_delegate_;
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Whether to show the "Create a new profile" button.
83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool prompt_for_new_profile_;
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Cleanup bookkeeping.  Labeled mutable to get around inherited const
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // label on GetWebUIMessageHandlers.
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  mutable bool closed_by_handler_;
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialog);
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_
93