| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/signin/signin_email_confirmation_dialog.h" | 5 #include "chrome/browser/ui/webui/signin/signin_email_confirmation_dialog.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/grit/browser_resources.h" | 13 #include "chrome/grit/browser_resources.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "content/public/browser/user_metrics.h" | 15 #include "content/public/browser/user_metrics.h" |
| 16 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
| 17 #include "content/public/browser/web_ui_message_handler.h" | 17 #include "content/public/browser/web_ui_message_handler.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Dialog size. | 22 // Dialog size. |
| 23 const int kDialogWidth = 448; | 23 const int kDialogWidth = 448; |
| 24 const int kDialogHeight = 250; | 24 const int kDialogMinHeight = 200; |
| 25 const int kDialogMaxHeight = 700; |
| 25 | 26 |
| 26 // Dialog action key; | 27 // Dialog action key; |
| 27 const char kActionKey[] = "action"; | 28 const char kActionKey[] = "action"; |
| 28 | 29 |
| 29 // Dialog action values. | 30 // Dialog action values. |
| 30 const char kActionCancel[] = "cancel"; | 31 const char kActionCancel[] = "cancel"; |
| 31 const char kActionCreateNewUser[] = "createNewUser"; | 32 const char kActionCreateNewUser[] = "createNewUser"; |
| 32 const char kActionStartSync[] = "startSync"; | 33 const char kActionStartSync[] = "startSync"; |
| 33 | 34 |
| 34 class EmailConfirmationHandler : public content::WebUIMessageHandler { | 35 class EmailConfirmationHandler : public content::WebUIMessageHandler { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const std::string& email, | 68 const std::string& email, |
| 68 const Callback& callback) { | 69 const Callback& callback) { |
| 69 content::RecordAction( | 70 content::RecordAction( |
| 70 base::UserMetricsAction("Signin_Show_ImportDataPrompt")); | 71 base::UserMetricsAction("Signin_Show_ImportDataPrompt")); |
| 71 SigninEmailConfirmationDialog* dialog = new SigninEmailConfirmationDialog( | 72 SigninEmailConfirmationDialog* dialog = new SigninEmailConfirmationDialog( |
| 72 contents, profile, last_email, email, callback); | 73 contents, profile, last_email, email, callback); |
| 73 dialog->Show(); | 74 dialog->Show(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void SigninEmailConfirmationDialog::Show() { | 77 void SigninEmailConfirmationDialog::Show() { |
| 77 dialog_delegate_ = ShowConstrainedWebDialog(profile_, this, web_contents_); | 78 gfx::Size minSize(kDialogWidth, kDialogMinHeight); |
| 79 gfx::Size maxSize(kDialogWidth, kDialogMaxHeight); |
| 80 dialog_delegate_ = ShowConstrainedWebDialogWithAutoResize( |
| 81 profile_, this, web_contents_, minSize, maxSize); |
| 78 } | 82 } |
| 79 | 83 |
| 80 ui::ModalType SigninEmailConfirmationDialog::GetDialogModalType() const { | 84 ui::ModalType SigninEmailConfirmationDialog::GetDialogModalType() const { |
| 81 return ui::MODAL_TYPE_WINDOW; | 85 return ui::MODAL_TYPE_WINDOW; |
| 82 } | 86 } |
| 83 | 87 |
| 84 base::string16 SigninEmailConfirmationDialog::GetDialogTitle() const { | 88 base::string16 SigninEmailConfirmationDialog::GetDialogTitle() const { |
| 85 return base::string16(); | 89 return base::string16(); |
| 86 } | 90 } |
| 87 | 91 |
| 88 GURL SigninEmailConfirmationDialog::GetDialogContentURL() const { | 92 GURL SigninEmailConfirmationDialog::GetDialogContentURL() const { |
| 89 return GURL(chrome::kChromeUISigninEmailConfirmationURL); | 93 return GURL(chrome::kChromeUISigninEmailConfirmationURL); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void SigninEmailConfirmationDialog::GetWebUIMessageHandlers( | 96 void SigninEmailConfirmationDialog::GetWebUIMessageHandlers( |
| 93 std::vector<content::WebUIMessageHandler*>* handlers) const { | 97 std::vector<content::WebUIMessageHandler*>* handlers) const { |
| 94 handlers->push_back(new EmailConfirmationHandler()); | 98 handlers->push_back(new EmailConfirmationHandler()); |
| 95 } | 99 } |
| 96 | 100 |
| 97 void SigninEmailConfirmationDialog::GetDialogSize(gfx::Size* size) const { | 101 void SigninEmailConfirmationDialog::GetDialogSize(gfx::Size* size) const { |
| 98 size->SetSize(kDialogWidth, kDialogHeight); | 102 // Avoid setting a dialog size in here as this dialog auto-resizes (see |
| 103 // method |SigninEmailConfirmationDialog::Show|. |
| 99 } | 104 } |
| 100 | 105 |
| 101 std::string SigninEmailConfirmationDialog::GetDialogArgs() const { | 106 std::string SigninEmailConfirmationDialog::GetDialogArgs() const { |
| 102 std::string data; | 107 std::string data; |
| 103 base::DictionaryValue dialog_args; | 108 base::DictionaryValue dialog_args; |
| 104 dialog_args.SetString("lastEmail", last_email_); | 109 dialog_args.SetString("lastEmail", last_email_); |
| 105 dialog_args.SetString("newEmail", new_email_); | 110 dialog_args.SetString("newEmail", new_email_); |
| 106 base::JSONWriter::Write(dialog_args, &data); | 111 base::JSONWriter::Write(dialog_args, &data); |
| 107 return data; | 112 return data; |
| 108 } | 113 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 146 |
| 142 void SigninEmailConfirmationDialog::OnCloseContents( | 147 void SigninEmailConfirmationDialog::OnCloseContents( |
| 143 content::WebContents* source, | 148 content::WebContents* source, |
| 144 bool* out_close_dialog) { | 149 bool* out_close_dialog) { |
| 145 *out_close_dialog = true; | 150 *out_close_dialog = true; |
| 146 } | 151 } |
| 147 | 152 |
| 148 bool SigninEmailConfirmationDialog::ShouldShowDialogTitle() const { | 153 bool SigninEmailConfirmationDialog::ShouldShowDialogTitle() const { |
| 149 return false; | 154 return false; |
| 150 } | 155 } |
| OLD | NEW |