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 "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" | 5 #include "chrome/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 "chrome/browser/guest_view/guest_view_constants.h" | 9 #include "chrome/browser/guest_view/guest_view_constants.h" |
10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 const GURL& origin_url, | 42 const GURL& origin_url, |
43 const std::string& accept_lang, | 43 const std::string& accept_lang, |
44 content::JavaScriptMessageType javascript_message_type, | 44 content::JavaScriptMessageType javascript_message_type, |
45 const base::string16& message_text, | 45 const base::string16& message_text, |
46 const base::string16& default_prompt_text, | 46 const base::string16& default_prompt_text, |
47 const DialogClosedCallback& callback, | 47 const DialogClosedCallback& callback, |
48 bool* did_suppress_message) { | 48 bool* did_suppress_message) { |
49 base::DictionaryValue request_info; | 49 base::DictionaryValue request_info; |
50 request_info.Set( | 50 request_info.Set( |
51 webview::kDefaultPromptText, | 51 webview::kDefaultPromptText, |
52 base::Value::CreateStringValue(base::UTF16ToUTF8(default_prompt_text))); | 52 new base::StringValue(base::UTF16ToUTF8(default_prompt_text))); |
53 request_info.Set( | 53 request_info.Set(webview::kMessageText, |
54 webview::kMessageText, | 54 new base::StringValue(base::UTF16ToUTF8(message_text))); |
55 base::Value::CreateStringValue(base::UTF16ToUTF8(message_text))); | 55 request_info.Set(webview::kMessageType, |
56 request_info.Set( | 56 new base::StringValue( |
57 webview::kMessageType, | 57 JavaScriptMessageTypeToString(javascript_message_type))); |
58 base::Value::CreateStringValue( | 58 request_info.Set(guestview::kUrl, new base::StringValue(origin_url.spec())); |
59 JavaScriptMessageTypeToString(javascript_message_type))); | |
60 request_info.Set( | |
61 guestview::kUrl, | |
62 base::Value::CreateStringValue(origin_url.spec())); | |
63 webview_guest_->RequestPermission( | 59 webview_guest_->RequestPermission( |
64 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG, | 60 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG, |
65 request_info, | 61 request_info, |
66 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, | 62 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, |
67 base::Unretained(this), | 63 base::Unretained(this), |
68 callback), | 64 callback), |
69 false /* allowed_by_default */); | 65 false /* allowed_by_default */); |
70 } | 66 } |
71 | 67 |
72 void JavaScriptDialogHelper::RunBeforeUnloadDialog( | 68 void JavaScriptDialogHelper::RunBeforeUnloadDialog( |
(...skipping 21 matching lines...) Expand all Loading... |
94 content::WebContents* web_contents) { | 90 content::WebContents* web_contents) { |
95 } | 91 } |
96 | 92 |
97 void JavaScriptDialogHelper::OnPermissionResponse( | 93 void JavaScriptDialogHelper::OnPermissionResponse( |
98 const DialogClosedCallback& callback, | 94 const DialogClosedCallback& callback, |
99 bool allow, | 95 bool allow, |
100 const std::string& user_input) { | 96 const std::string& user_input) { |
101 callback.Run(allow && webview_guest_->attached(), | 97 callback.Run(allow && webview_guest_->attached(), |
102 base::UTF8ToUTF16(user_input)); | 98 base::UTF8ToUTF16(user_input)); |
103 } | 99 } |
OLD | NEW |