Chromium Code Reviews| Index: chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| diff --git a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..26bed2e18411c86e9f3f5c1d9663ff95a42d3a5d |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| @@ -0,0 +1,108 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" |
| + |
| +#include "base/json/json_writer.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_dialogs.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/browser/ui/web_contents_modal_dialog.h" |
| +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| +#include "chrome/common/url_constants.h" |
| +#include "grit/browser_resources.h" |
| +#include "grit/chromium_strings.h" |
| +#include "grit/generated_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| + |
| +namespace { |
| +const int kMinimumDialogWidth = 640; |
| +const int kMinimumDialogHeight = 480; |
| +} // namespace |
| + |
| +void ProfileSigninConfirmationDialog::ShowDialog( |
| + const std::string& username, |
| + const base::Closure& cancel_signin, |
| + const base::Closure& signin_with_new_profile, |
| + const base::Closure& continue_signin) { |
| + new ProfileSigninConfirmationDialog(username, |
| + cancel_signin, |
| + signin_with_new_profile, |
| + continue_signin); |
| +} |
| + |
| +ProfileSigninConfirmationDialog::ProfileSigninConfirmationDialog( |
| + const std::string& username, |
| + const base::Closure& cancel_signin, |
| + const base::Closure& signin_with_new_profile, |
| + const base::Closure& continue_signin) |
| + : username_(username) { |
| + handler_.reset(new ProfileSigninConfirmationHandler(this, |
| + cancel_signin, |
| + signin_with_new_profile, |
| + continue_signin)); |
| + |
| + Profile* profile = ProfileManager::GetLastUsedProfile(); |
|
Andrew T Wilson (Slow)
2013/02/10 20:47:26
You should probably have the caller pass in a prof
dconnelly
2013/02/11 09:35:16
Done.
|
| + Browser* browser = FindBrowserWithProfile(profile, |
| + chrome::HOST_DESKTOP_TYPE_FIRST); |
| + DCHECK(browser); |
| + delegate_ = CreateConstrainedWebDialog( |
| + profile, this, NULL, browser->tab_strip_model()->GetActiveWebContents()); |
| +} |
| + |
| +ProfileSigninConfirmationDialog::~ProfileSigninConfirmationDialog() { |
| +} |
| + |
| +void ProfileSigninConfirmationDialog::Close() { |
| + delegate_->GetWindow()->CloseWebContentsModalDialog(); |
| +} |
| + |
| +ui::ModalType ProfileSigninConfirmationDialog::GetDialogModalType() const { |
| + return ui::MODAL_TYPE_WINDOW; |
| +} |
| + |
| +string16 ProfileSigninConfirmationDialog::GetDialogTitle() const { |
| + return l10n_util::GetStringUTF16( |
| + IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_DIALOG_TITLE); |
| +} |
| + |
| +GURL ProfileSigninConfirmationDialog::GetDialogContentURL() const { |
| + return GURL(chrome::kChromeUIProfileSigninConfirmationURL); |
| +} |
| + |
| +void ProfileSigninConfirmationDialog::GetWebUIMessageHandlers( |
| + std::vector<content::WebUIMessageHandler*>* handlers) const { |
| + handlers->push_back(handler_.release()); |
| +} |
| + |
| +void ProfileSigninConfirmationDialog::GetDialogSize(gfx::Size* size) const { |
| + size->SetSize(kMinimumDialogWidth, kMinimumDialogHeight); |
| +} |
| + |
| +std::string ProfileSigninConfirmationDialog::GetDialogArgs() const { |
| + std::string data; |
| + DictionaryValue dict; |
| + dict.SetString("username", username_); |
| + base::JSONWriter::Write(&dict, &data); |
| + return data; |
| +} |
| + |
| +void ProfileSigninConfirmationDialog::OnDialogClosed( |
| + const std::string& json_retval) { |
| + // TODO(dconnelly): if the user closed the tab we should cancel |
| +} |
| + |
| +void ProfileSigninConfirmationDialog::OnCloseContents( |
| + content::WebContents* source, |
| + bool* out_close_dialog) { |
| + if (out_close_dialog) |
| + *out_close_dialog = true; |
| +} |
| + |
| +bool ProfileSigninConfirmationDialog::ShouldShowDialogTitle() const { |
| + return true; |
| +} |