| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/renderer/web_ui_extension.h" | 5 #include "content/renderer/web_ui_extension.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 12 #include "content/public/child/v8_value_converter.h" | 13 #include "content/public/child/v8_value_converter.h" |
| 13 #include "content/public/common/bindings_policy.h" | 14 #include "content/public/common/bindings_policy.h" |
| 14 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/renderer/chrome_object_extensions_utils.h" | 16 #include "content/public/renderer/chrome_object_extensions_utils.h" |
| 16 #include "content/public/renderer/render_thread.h" | 17 #include "content/public/renderer/render_thread.h" |
| 17 #include "content/public/renderer/render_view.h" | 18 #include "content/public/renderer/render_view.h" |
| 18 #include "content/renderer/web_ui_extension_data.h" | 19 #include "content/renderer/web_ui_extension_data.h" |
| 19 #include "gin/arguments.h" | 20 #include "gin/arguments.h" |
| 20 #include "gin/function_template.h" | 21 #include "gin/function_template.h" |
| 21 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 22 #include "third_party/WebKit/public/web/WebKit.h" | 23 #include "third_party/WebKit/public/web/WebKit.h" |
| 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 24 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 25 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 26 #include "v8/include/v8.h" | 28 #include "v8/include/v8.h" |
| 27 | 29 |
| 28 namespace content { | 30 namespace content { |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 bool ShouldRespondToRequest( | 34 bool ShouldRespondToRequest( |
| 33 blink::WebFrame** frame_ptr, | 35 blink::WebFrame** frame_ptr, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 RenderView* render_view; | 91 RenderView* render_view; |
| 90 if (!ShouldRespondToRequest(&frame, &render_view)) | 92 if (!ShouldRespondToRequest(&frame, &render_view)) |
| 91 return; | 93 return; |
| 92 | 94 |
| 93 std::string message; | 95 std::string message; |
| 94 if (!args->GetNext(&message)) { | 96 if (!args->GetNext(&message)) { |
| 95 args->ThrowError(); | 97 args->ThrowError(); |
| 96 return; | 98 return; |
| 97 } | 99 } |
| 98 | 100 |
| 101 if (base::EndsWith(message, "RequiringGesture", |
| 102 base::CompareCase::SENSITIVE) && |
| 103 !blink::WebUserGestureIndicator::isProcessingUserGesture()) { |
| 104 NOTREACHED(); |
| 105 return; |
| 106 } |
| 107 |
| 99 // If they've provided an optional message parameter, convert that into a | 108 // If they've provided an optional message parameter, convert that into a |
| 100 // Value to send to the browser process. | 109 // Value to send to the browser process. |
| 101 std::unique_ptr<base::ListValue> content; | 110 std::unique_ptr<base::ListValue> content; |
| 102 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { | 111 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { |
| 103 content.reset(new base::ListValue()); | 112 content.reset(new base::ListValue()); |
| 104 } else { | 113 } else { |
| 105 v8::Local<v8::Object> obj; | 114 v8::Local<v8::Object> obj; |
| 106 if (!args->GetNext(&obj)) { | 115 if (!args->GetNext(&obj)) { |
| 107 args->ThrowError(); | 116 args->ThrowError(); |
| 108 return; | 117 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 125 std::string WebUIExtension::GetVariableValue(const std::string& name) { | 134 std::string WebUIExtension::GetVariableValue(const std::string& name) { |
| 126 blink::WebFrame* frame; | 135 blink::WebFrame* frame; |
| 127 RenderView* render_view; | 136 RenderView* render_view; |
| 128 if (!ShouldRespondToRequest(&frame, &render_view)) | 137 if (!ShouldRespondToRequest(&frame, &render_view)) |
| 129 return std::string(); | 138 return std::string(); |
| 130 | 139 |
| 131 return WebUIExtensionData::Get(render_view)->GetValue(name); | 140 return WebUIExtensionData::Get(render_view)->GetValue(name); |
| 132 } | 141 } |
| 133 | 142 |
| 134 } // namespace content | 143 } // namespace content |
| OLD | NEW |