| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/javascript_dialog_helper.h" | 5 #include "extensions/browser/guest_view/web_view/javascript_dialog_helper.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/guest_view/common/guest_view_constants.h" | 9 #include "components/guest_view/common/guest_view_constants.h" |
| 10 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 10 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 void JavaScriptDialogHelper::RunJavaScriptDialog( | 43 void JavaScriptDialogHelper::RunJavaScriptDialog( |
| 44 content::WebContents* web_contents, | 44 content::WebContents* web_contents, |
| 45 const GURL& origin_url, | 45 const GURL& origin_url, |
| 46 content::JavaScriptDialogType dialog_type, | 46 content::JavaScriptDialogType dialog_type, |
| 47 const base::string16& message_text, | 47 const base::string16& message_text, |
| 48 const base::string16& default_prompt_text, | 48 const base::string16& default_prompt_text, |
| 49 const DialogClosedCallback& callback, | 49 const DialogClosedCallback& callback, |
| 50 bool* did_suppress_message) { | 50 bool* did_suppress_message) { |
| 51 base::DictionaryValue request_info; | 51 base::DictionaryValue request_info; |
| 52 request_info.Set(webview::kDefaultPromptText, | 52 request_info.SetString(webview::kDefaultPromptText, |
| 53 new base::Value(base::UTF16ToUTF8(default_prompt_text))); | 53 base::UTF16ToUTF8(default_prompt_text)); |
| 54 request_info.Set(webview::kMessageText, | 54 request_info.SetString(webview::kMessageText, |
| 55 new base::Value(base::UTF16ToUTF8(message_text))); | 55 base::UTF16ToUTF8(message_text)); |
| 56 request_info.Set(webview::kMessageType, | 56 request_info.SetString(webview::kMessageType, |
| 57 new base::Value(JavaScriptDialogTypeToString(dialog_type))); | 57 JavaScriptDialogTypeToString(dialog_type)); |
| 58 request_info.Set(guest_view::kUrl, new base::Value(origin_url.spec())); | 58 request_info.SetString(guest_view::kUrl, origin_url.spec()); |
| 59 WebViewPermissionHelper* web_view_permission_helper = | 59 WebViewPermissionHelper* web_view_permission_helper = |
| 60 WebViewPermissionHelper::FromWebContents(web_contents); | 60 WebViewPermissionHelper::FromWebContents(web_contents); |
| 61 web_view_permission_helper->RequestPermission( | 61 web_view_permission_helper->RequestPermission( |
| 62 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG, | 62 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG, |
| 63 request_info, | 63 request_info, |
| 64 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, | 64 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, |
| 65 base::Unretained(this), | 65 base::Unretained(this), |
| 66 callback), | 66 callback), |
| 67 false /* allowed_by_default */); | 67 false /* allowed_by_default */); |
| 68 } | 68 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 void JavaScriptDialogHelper::OnPermissionResponse( | 89 void JavaScriptDialogHelper::OnPermissionResponse( |
| 90 const DialogClosedCallback& callback, | 90 const DialogClosedCallback& callback, |
| 91 bool allow, | 91 bool allow, |
| 92 const std::string& user_input) { | 92 const std::string& user_input) { |
| 93 callback.Run(allow && web_view_guest_->attached(), | 93 callback.Run(allow && web_view_guest_->attached(), |
| 94 base::UTF8ToUTF16(user_input)); | 94 base::UTF8ToUTF16(user_input)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace extensions | 97 } // namespace extensions |
| OLD | NEW |