OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
19 #include "base/json/json_reader.h" | |
sgurun-gerrit only
2014/07/18 16:13:44
removed unintended include.
| |
19 #include "base/json/json_writer.h" | 20 #include "base/json/json_writer.h" |
20 #include "base/lazy_instance.h" | 21 #include "base/lazy_instance.h" |
21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
22 #include "base/message_loop/message_loop_proxy.h" | 23 #include "base/message_loop/message_loop_proxy.h" |
23 #include "base/metrics/field_trial.h" | 24 #include "base/metrics/field_trial.h" |
24 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
25 #include "base/path_service.h" | 26 #include "base/path_service.h" |
26 #include "base/process/kill.h" | 27 #include "base/process/kill.h" |
27 #include "base/process/process.h" | 28 #include "base/process/process.h" |
28 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
(...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2962 blink::WebMessagePortChannelArray channels(params.message_port_ids.size()); | 2963 blink::WebMessagePortChannelArray channels(params.message_port_ids.size()); |
2963 for (size_t i = 0; | 2964 for (size_t i = 0; |
2964 i < params.message_port_ids.size() && i < params.new_routing_ids.size(); | 2965 i < params.message_port_ids.size() && i < params.new_routing_ids.size(); |
2965 ++i) { | 2966 ++i) { |
2966 channels[i] = | 2967 channels[i] = |
2967 new WebMessagePortChannelImpl(params.new_routing_ids[i], | 2968 new WebMessagePortChannelImpl(params.new_routing_ids[i], |
2968 params.message_port_ids[i], | 2969 params.message_port_ids[i], |
2969 base::MessageLoopProxy::current().get()); | 2970 base::MessageLoopProxy::current().get()); |
2970 } | 2971 } |
2971 | 2972 |
2973 WebSerializedScriptValue serialized_script_value; | |
2974 if (params.is_data_raw_string) { | |
2975 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | |
jochen (gone - plz use gerrit)
2014/07/18 09:20:27
should be blink::mainThreadIsolate()
sgurun-gerrit only
2014/07/18 16:13:44
Done.
| |
2976 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | |
2977 v8::Context::Scope context_scope(context); | |
2978 V8ValueConverterImpl converter; | |
2979 converter.SetDateAllowed(true); | |
2980 converter.SetRegExpAllowed(true); | |
2981 scoped_ptr<base::Value> value(new base::StringValue(params.data)); | |
2982 v8::Handle<v8::Value> result_value = converter.ToV8Value(value.get(), | |
2983 context); | |
2984 serialized_script_value = WebSerializedScriptValue::serialize(result_value); | |
2985 } else { | |
2986 serialized_script_value = WebSerializedScriptValue::fromString(params.data); | |
2987 } | |
2988 | |
2972 // Create an event with the message. The final parameter to initMessageEvent | 2989 // Create an event with the message. The final parameter to initMessageEvent |
2973 // is the last event ID, which is not used with postMessage. | 2990 // is the last event ID, which is not used with postMessage. |
2974 WebDOMEvent event = frame->document().createEvent("MessageEvent"); | 2991 WebDOMEvent event = frame->document().createEvent("MessageEvent"); |
2975 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); | 2992 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); |
2976 msg_event.initMessageEvent("message", | 2993 msg_event.initMessageEvent("message", |
2977 // |canBubble| and |cancellable| are always false | 2994 // |canBubble| and |cancellable| are always false |
2978 false, false, | 2995 false, false, |
2979 WebSerializedScriptValue::fromString(params.data), | 2996 serialized_script_value, |
2980 params.source_origin, source_frame, "", channels); | 2997 params.source_origin, source_frame, "", channels); |
2981 | 2998 |
2982 // We must pass in the target_origin to do the security check on this side, | 2999 // We must pass in the target_origin to do the security check on this side, |
2983 // since it may have changed since the original postMessage call was made. | 3000 // since it may have changed since the original postMessage call was made. |
2984 WebSecurityOrigin target_origin; | 3001 WebSecurityOrigin target_origin; |
2985 if (!params.target_origin.empty()) { | 3002 if (!params.target_origin.empty()) { |
2986 target_origin = | 3003 target_origin = |
2987 WebSecurityOrigin::createFromString(WebString(params.target_origin)); | 3004 WebSecurityOrigin::createFromString(WebString(params.target_origin)); |
2988 } | 3005 } |
2989 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 3006 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4297 std::vector<gfx::Size> sizes; | 4314 std::vector<gfx::Size> sizes; |
4298 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4315 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4299 if (!url.isEmpty()) | 4316 if (!url.isEmpty()) |
4300 urls.push_back( | 4317 urls.push_back( |
4301 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4318 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4302 } | 4319 } |
4303 SendUpdateFaviconURL(urls); | 4320 SendUpdateFaviconURL(urls); |
4304 } | 4321 } |
4305 | 4322 |
4306 } // namespace content | 4323 } // namespace content |
OLD | NEW |