| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/html_viewer/html_frame.h" | 5 #include "components/html_viewer/html_frame.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 return; | 741 return; |
| 742 } | 742 } |
| 743 | 743 |
| 744 blink::WebLocalFrame* target_web_frame = | 744 blink::WebLocalFrame* target_web_frame = |
| 745 target->web_frame_->toWebLocalFrame(); | 745 target->web_frame_->toWebLocalFrame(); |
| 746 | 746 |
| 747 blink::WebSerializedScriptValue serialized_script_value; | 747 blink::WebSerializedScriptValue serialized_script_value; |
| 748 serialized_script_value = blink::WebSerializedScriptValue::fromString( | 748 serialized_script_value = blink::WebSerializedScriptValue::fromString( |
| 749 serialized_event->data.To<blink::WebString>()); | 749 serialized_event->data.To<blink::WebString>()); |
| 750 | 750 |
| 751 blink::WebMessagePortChannelArray channels; | |
| 752 | |
| 753 // Create an event with the message. The next-to-last parameter to | |
| 754 // initMessageEvent is the last event ID, which is not used with postMessage. | |
| 755 blink::WebDOMEvent event = | |
| 756 target_web_frame->document().createEvent("MessageEvent"); | |
| 757 blink::WebDOMMessageEvent msg_event = event.to<blink::WebDOMMessageEvent>(); | |
| 758 msg_event.initMessageEvent( | |
| 759 "message", | |
| 760 // |canBubble| and |cancellable| are always false | |
| 761 false, false, serialized_script_value, | |
| 762 serialized_event->source_origin.To<blink::WebString>(), | |
| 763 source->web_frame_, target_web_frame->document(), "", channels); | |
| 764 | |
| 765 // We must pass in the target_origin to do the security check on this side, | 751 // We must pass in the target_origin to do the security check on this side, |
| 766 // since it may have changed since the original postMessage call was made. | 752 // since it may have changed since the original postMessage call was made. |
| 767 blink::WebSecurityOrigin target_origin; | 753 blink::WebSecurityOrigin target_origin; |
| 768 if (!serialized_event->target_origin.is_null()) { | 754 if (!serialized_event->target_origin.is_null()) { |
| 769 target_origin = blink::WebSecurityOrigin::createFromString( | 755 target_origin = blink::WebSecurityOrigin::createFromString( |
| 770 serialized_event->target_origin.To<blink::WebString>()); | 756 serialized_event->target_origin.To<blink::WebString>()); |
| 771 } | 757 } |
| 758 |
| 759 // TODO(esprehn): Shouldn't this also fill in channels like RenderFrameImpl? |
| 760 blink::WebMessagePortChannelArray channels; |
| 761 blink::WebDOMMessageEvent msg_event(serialized_script_value, |
| 762 serialized_event->source_origin.To<blink::WebString>(), |
| 763 source->web_frame_, target_web_frame->document(), channels); |
| 764 |
| 772 target_web_frame->dispatchMessageEventWithOriginCheck(target_origin, | 765 target_web_frame->dispatchMessageEventWithOriginCheck(target_origin, |
| 773 msg_event); | 766 msg_event); |
| 774 } | 767 } |
| 775 | 768 |
| 776 void HTMLFrame::OnWillNavigate(const mojo::String& origin, | 769 void HTMLFrame::OnWillNavigate(const mojo::String& origin, |
| 777 const OnWillNavigateCallback& callback) { | 770 const OnWillNavigateCallback& callback) { |
| 778 DVLOG(2) << "HTMLFrame::OnWillNavigate this=" << this << " id=" << id_ | 771 DVLOG(2) << "HTMLFrame::OnWillNavigate this=" << this << " id=" << id_ |
| 779 << " local=" << IsLocal() << " will_swap=" | 772 << " local=" << IsLocal() << " will_swap=" |
| 780 << (IsLocal() && this != frame_tree_manager_->local_root_); | 773 << (IsLocal() && this != frame_tree_manager_->local_root_); |
| 781 callback.Run(); | 774 callback.Run(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 | 855 |
| 863 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { | 856 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { |
| 864 NOTIMPLEMENTED(); | 857 NOTIMPLEMENTED(); |
| 865 } | 858 } |
| 866 | 859 |
| 867 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { | 860 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { |
| 868 NOTIMPLEMENTED(); | 861 NOTIMPLEMENTED(); |
| 869 } | 862 } |
| 870 | 863 |
| 871 } // namespace mojo | 864 } // namespace mojo |
| OLD | NEW |