| 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/javascript_dialogs/javascript_dialog_cocoa.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_cocoa.h" |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 title, dialog_type, message_text, | 162 title, dialog_type, message_text, |
| 163 default_prompt_text, dialog_callback)) | 163 default_prompt_text, dialog_callback)) |
| 164 ->weak_factory_.GetWeakPtr(); | 164 ->weak_factory_.GetWeakPtr(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void JavaScriptDialogCocoa::CloseDialogWithoutCallback() { | 167 void JavaScriptDialogCocoa::CloseDialogWithoutCallback() { |
| 168 impl_->dialog_callback_.Reset(); | 168 impl_->dialog_callback_.Reset(); |
| 169 impl_->window_->CloseWebContentsModalDialog(); | 169 impl_->window_->CloseWebContentsModalDialog(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 base::string16 JavaScriptDialogCocoa::GetUserInput() { |
| 173 if (!impl_->textField_) |
| 174 return base::string16(); |
| 175 |
| 176 return base::SysNSStringToUTF16([impl_->textField_ stringValue]); |
| 177 } |
| 178 |
| 172 JavaScriptDialogCocoa::JavaScriptDialogCocoa( | 179 JavaScriptDialogCocoa::JavaScriptDialogCocoa( |
| 173 content::WebContents* parent_web_contents, | 180 content::WebContents* parent_web_contents, |
| 174 content::WebContents* alerting_web_contents, | 181 content::WebContents* alerting_web_contents, |
| 175 const base::string16& title, | 182 const base::string16& title, |
| 176 content::JavaScriptDialogType dialog_type, | 183 content::JavaScriptDialogType dialog_type, |
| 177 const base::string16& message_text, | 184 const base::string16& message_text, |
| 178 const base::string16& default_prompt_text, | 185 const base::string16& default_prompt_text, |
| 179 const content::JavaScriptDialogManager::DialogClosedCallback& | 186 const content::JavaScriptDialogManager::DialogClosedCallback& |
| 180 dialog_callback) | 187 dialog_callback) |
| 181 : JavaScriptDialog(parent_web_contents), | 188 : JavaScriptDialog(parent_web_contents), |
| 182 impl_(base::MakeUnique<JavaScriptDialogCocoaImpl>(this, | 189 impl_(base::MakeUnique<JavaScriptDialogCocoaImpl>(this, |
| 183 parent_web_contents, | 190 parent_web_contents, |
| 184 alerting_web_contents, | 191 alerting_web_contents, |
| 185 title, | 192 title, |
| 186 dialog_type, | 193 dialog_type, |
| 187 message_text, | 194 message_text, |
| 188 default_prompt_text, | 195 default_prompt_text, |
| 189 dialog_callback)), | 196 dialog_callback)), |
| 190 weak_factory_(this) {} | 197 weak_factory_(this) {} |
| OLD | NEW |