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" |
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 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 blink::WebMessagePortChannelArray channels(params.message_port_ids.size()); | 2642 blink::WebMessagePortChannelArray channels(params.message_port_ids.size()); |
2642 for (size_t i = 0; | 2643 for (size_t i = 0; |
2643 i < params.message_port_ids.size() && i < params.new_routing_ids.size(); | 2644 i < params.message_port_ids.size() && i < params.new_routing_ids.size(); |
2644 ++i) { | 2645 ++i) { |
2645 channels[i] = | 2646 channels[i] = |
2646 new WebMessagePortChannelImpl(params.new_routing_ids[i], | 2647 new WebMessagePortChannelImpl(params.new_routing_ids[i], |
2647 params.message_port_ids[i], | 2648 params.message_port_ids[i], |
2648 base::MessageLoopProxy::current().get()); | 2649 base::MessageLoopProxy::current().get()); |
2649 } | 2650 } |
2650 | 2651 |
| 2652 WebSerializedScriptValue serialized_script_value; |
| 2653 if (params.is_data_raw_string) { |
| 2654 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 2655 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 2656 v8::Context::Scope context_scope(context); |
| 2657 V8ValueConverterImpl converter; |
| 2658 converter.SetDateAllowed(true); |
| 2659 converter.SetRegExpAllowed(true); |
| 2660 base::Value* value = new base::StringValue(params.data); |
| 2661 v8::Handle<v8::Value> result_value = converter.ToV8Value(value, context); |
| 2662 serialized_script_value = WebSerializedScriptValue::serialize(result_value); |
| 2663 } else { |
| 2664 serialized_script_value = WebSerializedScriptValue::fromString(params.data); |
| 2665 } |
| 2666 |
2651 // Create an event with the message. The final parameter to initMessageEvent | 2667 // Create an event with the message. The final parameter to initMessageEvent |
2652 // is the last event ID, which is not used with postMessage. | 2668 // is the last event ID, which is not used with postMessage. |
2653 WebDOMEvent event = frame->document().createEvent("MessageEvent"); | 2669 WebDOMEvent event = frame->document().createEvent("MessageEvent"); |
2654 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); | 2670 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); |
2655 msg_event.initMessageEvent("message", | 2671 msg_event.initMessageEvent("message", |
2656 // |canBubble| and |cancellable| are always false | 2672 // |canBubble| and |cancellable| are always false |
2657 false, false, | 2673 false, false, |
2658 WebSerializedScriptValue::fromString(params.data), | 2674 serialized_script_value, |
2659 params.source_origin, source_frame, "", channels); | 2675 params.source_origin, source_frame, "", channels); |
2660 | 2676 |
2661 // We must pass in the target_origin to do the security check on this side, | 2677 // We must pass in the target_origin to do the security check on this side, |
2662 // since it may have changed since the original postMessage call was made. | 2678 // since it may have changed since the original postMessage call was made. |
2663 WebSecurityOrigin target_origin; | 2679 WebSecurityOrigin target_origin; |
2664 if (!params.target_origin.empty()) { | 2680 if (!params.target_origin.empty()) { |
2665 target_origin = | 2681 target_origin = |
2666 WebSecurityOrigin::createFromString(WebString(params.target_origin)); | 2682 WebSecurityOrigin::createFromString(WebString(params.target_origin)); |
2667 } | 2683 } |
2668 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2684 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4012 std::vector<gfx::Size> sizes; | 4028 std::vector<gfx::Size> sizes; |
4013 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4029 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4014 if (!url.isEmpty()) | 4030 if (!url.isEmpty()) |
4015 urls.push_back( | 4031 urls.push_back( |
4016 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4032 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4017 } | 4033 } |
4018 SendUpdateFaviconURL(urls); | 4034 SendUpdateFaviconURL(urls); |
4019 } | 4035 } |
4020 | 4036 |
4021 } // namespace content | 4037 } // namespace content |
OLD | NEW |