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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 webview::kMessageText, | 54 webview::kMessageText, |
55 base::Value::CreateStringValue(base::UTF16ToUTF8(message_text))); | 55 base::Value::CreateStringValue(base::UTF16ToUTF8(message_text))); |
56 request_info.Set( | 56 request_info.Set( |
57 webview::kMessageType, | 57 webview::kMessageType, |
58 base::Value::CreateStringValue( | 58 base::Value::CreateStringValue( |
59 JavaScriptMessageTypeToString(javascript_message_type))); | 59 JavaScriptMessageTypeToString(javascript_message_type))); |
60 request_info.Set( | 60 request_info.Set( |
61 guestview::kUrl, | 61 guestview::kUrl, |
62 base::Value::CreateStringValue(origin_url.spec())); | 62 base::Value::CreateStringValue(origin_url.spec())); |
63 webview_guest_->RequestPermission( | 63 webview_guest_->RequestPermission( |
64 static_cast<BrowserPluginPermissionType>( | 64 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG, |
65 WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG), | |
66 request_info, | 65 request_info, |
67 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, | 66 base::Bind(&JavaScriptDialogHelper::OnPermissionResponse, |
68 base::Unretained(this), | 67 base::Unretained(this), |
69 callback), | 68 callback), |
70 false /* allowed_by_default */); | 69 false /* allowed_by_default */); |
71 } | 70 } |
72 | 71 |
73 void JavaScriptDialogHelper::RunBeforeUnloadDialog( | 72 void JavaScriptDialogHelper::RunBeforeUnloadDialog( |
74 content::WebContents* web_contents, | 73 content::WebContents* web_contents, |
75 const base::string16& message_text, | 74 const base::string16& message_text, |
(...skipping 19 matching lines...) Expand all Loading... |
95 content::WebContents* web_contents) { | 94 content::WebContents* web_contents) { |
96 } | 95 } |
97 | 96 |
98 void JavaScriptDialogHelper::OnPermissionResponse( | 97 void JavaScriptDialogHelper::OnPermissionResponse( |
99 const DialogClosedCallback& callback, | 98 const DialogClosedCallback& callback, |
100 bool allow, | 99 bool allow, |
101 const std::string& user_input) { | 100 const std::string& user_input) { |
102 callback.Run(allow && webview_guest_->attached(), | 101 callback.Run(allow && webview_guest_->attached(), |
103 base::UTF8ToUTF16(user_input)); | 102 base::UTF8ToUTF16(user_input)); |
104 } | 103 } |
OLD | NEW |