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"
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/history/core/browser/history_types.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/ui_base_types.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/web_dialogs/web_dialog_delegate.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class Browser;
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Profile;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebUIMessageHandler;
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content {
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class WebContents;
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// A tab-modal dialog to allow a user signing in with a managed account
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// to create a new Chrome profile.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ProfileSigninConfirmationDialog : public ui::WebDialogDelegate {
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Create and show the dialog, which owns itself.
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static void ShowDialog(
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      content::WebContents* web_contents,
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      Profile* profile,
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const std::string& username,
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      ui::ProfileSigninConfirmationDelegate* delegate);
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Closes the dialog, which will delete itself.
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void Close() const;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ProfileSigninConfirmationDialog(
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      content::WebContents* web_contents,
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      Profile* profile,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::string& username,
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      ui::ProfileSigninConfirmationDelegate* delegate);
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~ProfileSigninConfirmationDialog();
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
48c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Shows the dialog and releases ownership of this object. It will
49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // delete itself when the dialog is closed. If |prompt_for_new_profile|
50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // is true, the dialog will offer to create a new profile before signin.
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void Show(bool prompt_for_new_profile);
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // WebDialogDelegate implementation.
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ui::ModalType GetDialogModalType() const OVERRIDE;
55a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetDialogTitle() const OVERRIDE;
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual GURL GetDialogContentURL() const OVERRIDE;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetWebUIMessageHandlers(
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual std::string GetDialogArgs() const OVERRIDE;
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnCloseContents(content::WebContents* source,
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                               bool* out_close_dialog) OVERRIDE;
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ShouldShowDialogTitle() const OVERRIDE;
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the containing view.
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  content::WebContents* web_contents_;
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the profile being signed-in.
70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  Profile* profile_;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The GAIA username being signed in.
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string username_;
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the signin delegate.
76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ui::ProfileSigninConfirmationDelegate* signin_delegate_;
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Weak pointer to the dialog delegate.
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ConstrainedWebDialogDelegate* dialog_delegate_;
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Whether to show the "Create a new profile" button.
82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool prompt_for_new_profile_;
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Cleanup bookkeeping.  Labeled mutable to get around inherited const
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // label on GetWebUIMessageHandlers.
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  mutable bool closed_by_handler_;
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialog);
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_SIGNIN_CONFIRMATION_DIALOG_H_
92