Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "content/public/common/content_switches.h" 43 #include "content/public/common/content_switches.h"
44 #include "content/public/common/file_chooser_params.h" 44 #include "content/public/common/file_chooser_params.h"
45 #include "content/public/common/url_constants.h" 45 #include "content/public/common/url_constants.h"
46 #include "content/public/renderer/content_renderer_client.h" 46 #include "content/public/renderer/content_renderer_client.h"
47 #include "content/public/renderer/document_state.h" 47 #include "content/public/renderer/document_state.h"
48 #include "content/public/renderer/navigation_state.h" 48 #include "content/public/renderer/navigation_state.h"
49 #include "content/public/renderer/render_view_observer.h" 49 #include "content/public/renderer/render_view_observer.h"
50 #include "content/public/renderer/render_view_visitor.h" 50 #include "content/public/renderer/render_view_visitor.h"
51 #include "content/renderer/device_orientation_dispatcher.h" 51 #include "content/renderer/device_orientation_dispatcher.h"
52 #include "content/renderer/devtools_agent.h" 52 #include "content/renderer/devtools_agent.h"
53 #include "content/renderer/dom_proxy_installer.h"
53 #include "content/renderer/external_popup_menu.h" 54 #include "content/renderer/external_popup_menu.h"
54 #include "content/renderer/geolocation_dispatcher.h" 55 #include "content/renderer/geolocation_dispatcher.h"
55 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" 56 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
56 #include "content/renderer/idle_user_detector.h" 57 #include "content/renderer/idle_user_detector.h"
57 #include "content/renderer/intents_dispatcher.h" 58 #include "content/renderer/intents_dispatcher.h"
58 #include "content/renderer/java/java_bridge_dispatcher.h" 59 #include "content/renderer/java/java_bridge_dispatcher.h"
59 #include "content/renderer/load_progress_tracker.h" 60 #include "content/renderer/load_progress_tracker.h"
60 #include "content/renderer/media/audio_message_filter.h" 61 #include "content/renderer/media/audio_message_filter.h"
61 #include "content/renderer/media/audio_renderer_impl.h" 62 #include "content/renderer/media/audio_renderer_impl.h"
62 #include "content/renderer/media/media_stream_impl.h" 63 #include "content/renderer/media/media_stream_impl.h"
63 #include "content/renderer/media/render_media_log.h" 64 #include "content/renderer/media/render_media_log.h"
64 #include "content/renderer/mhtml_generator.h" 65 #include "content/renderer/mhtml_generator.h"
65 #include "content/renderer/notification_provider.h" 66 #include "content/renderer/notification_provider.h"
66 #include "content/renderer/p2p/socket_dispatcher.h" 67 #include "content/renderer/p2p/socket_dispatcher.h"
67 #include "content/renderer/plugin_channel_host.h" 68 #include "content/renderer/plugin_channel_host.h"
69 #include "content/renderer/proxy_view_host.h"
68 #include "content/renderer/render_process.h" 70 #include "content/renderer/render_process.h"
69 #include "content/renderer/render_thread_impl.h" 71 #include "content/renderer/render_thread_impl.h"
70 #include "content/renderer/render_widget_fullscreen_pepper.h" 72 #include "content/renderer/render_widget_fullscreen_pepper.h"
71 #include "content/renderer/renderer_accessibility.h" 73 #include "content/renderer/renderer_accessibility.h"
72 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 74 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
73 #include "content/renderer/renderer_webstoragenamespace_impl.h" 75 #include "content/renderer/renderer_webstoragenamespace_impl.h"
74 #include "content/renderer/speech_input_dispatcher.h" 76 #include "content/renderer/speech_input_dispatcher.h"
75 #include "content/renderer/text_input_client_observer.h" 77 #include "content/renderer/text_input_client_observer.h"
76 #include "content/renderer/v8_value_converter_impl.h" 78 #include "content/renderer/v8_value_converter_impl.h"
77 #include "content/renderer/web_ui_bindings.h" 79 #include "content/renderer/web_ui_bindings.h"
78 #include "content/renderer/webplugin_delegate_proxy.h" 80 #include "content/renderer/webplugin_delegate_proxy.h"
79 #include "content/renderer/websharedworker_proxy.h" 81 #include "content/renderer/websharedworker_proxy.h"
80 #include "media/base/filter_collection.h" 82 #include "media/base/filter_collection.h"
81 #include "media/base/media_switches.h" 83 #include "media/base/media_switches.h"
82 #include "media/base/message_loop_factory_impl.h" 84 #include "media/base/message_loop_factory_impl.h"
83 #include "net/base/escape.h" 85 #include "net/base/escape.h"
84 #include "net/base/net_errors.h" 86 #include "net/base/net_errors.h"
85 #include "net/http/http_util.h" 87 #include "net/http/http_util.h"
86 #include "ppapi/c/private/ppb_flash_net_connector.h" 88 #include "ppapi/c/private/ppb_flash_net_connector.h"
87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h"
88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h"
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" 100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h"
97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" 101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h" 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h"
100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" 105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h"
102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h" 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h"
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h"
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h"
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h"
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " 127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h "
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" 128 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h"
124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 129 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 130 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 131 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 132 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
128 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 133 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
129 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 134 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 using WebKit::WebApplicationCacheHostClient; 177 using WebKit::WebApplicationCacheHostClient;
173 using WebKit::WebCString; 178 using WebKit::WebCString;
174 using WebKit::WebColor; 179 using WebKit::WebColor;
175 using WebKit::WebColorName; 180 using WebKit::WebColorName;
176 using WebKit::WebConsoleMessage; 181 using WebKit::WebConsoleMessage;
177 using WebKit::WebContextMenuData; 182 using WebKit::WebContextMenuData;
178 using WebKit::WebCookieJar; 183 using WebKit::WebCookieJar;
179 using WebKit::WebData; 184 using WebKit::WebData;
180 using WebKit::WebDataSource; 185 using WebKit::WebDataSource;
181 using WebKit::WebDocument; 186 using WebKit::WebDocument;
187 using WebKit::WebDOMEvent;
188 using WebKit::WebDOMMessageEvent;
182 using WebKit::WebDragData; 189 using WebKit::WebDragData;
183 using WebKit::WebDragOperation; 190 using WebKit::WebDragOperation;
184 using WebKit::WebDragOperationsMask; 191 using WebKit::WebDragOperationsMask;
185 using WebKit::WebEditingAction; 192 using WebKit::WebEditingAction;
186 using WebKit::WebElement; 193 using WebKit::WebElement;
187 using WebKit::WebExternalPopupMenu; 194 using WebKit::WebExternalPopupMenu;
188 using WebKit::WebExternalPopupMenuClient; 195 using WebKit::WebExternalPopupMenuClient;
189 using WebKit::WebFileChooserCompletion; 196 using WebKit::WebFileChooserCompletion;
190 using WebKit::WebFileSystem; 197 using WebKit::WebFileSystem;
191 using WebKit::WebFileSystemCallbacks; 198 using WebKit::WebFileSystemCallbacks;
(...skipping 18 matching lines...) Expand all
210 using WebKit::WebPluginDocument; 217 using WebKit::WebPluginDocument;
211 using WebKit::WebPluginParams; 218 using WebKit::WebPluginParams;
212 using WebKit::WebPoint; 219 using WebKit::WebPoint;
213 using WebKit::WebPopupMenuInfo; 220 using WebKit::WebPopupMenuInfo;
214 using WebKit::WebRange; 221 using WebKit::WebRange;
215 using WebKit::WebRect; 222 using WebKit::WebRect;
216 using WebKit::WebScriptSource; 223 using WebKit::WebScriptSource;
217 using WebKit::WebSearchableFormData; 224 using WebKit::WebSearchableFormData;
218 using WebKit::WebSecurityOrigin; 225 using WebKit::WebSecurityOrigin;
219 using WebKit::WebSecurityPolicy; 226 using WebKit::WebSecurityPolicy;
227 using WebKit::WebSerializedScriptValue;
220 using WebKit::WebSettings; 228 using WebKit::WebSettings;
221 using WebKit::WebSharedWorker; 229 using WebKit::WebSharedWorker;
222 using WebKit::WebSize; 230 using WebKit::WebSize;
223 using WebKit::WebStorageNamespace; 231 using WebKit::WebStorageNamespace;
224 using WebKit::WebStorageQuotaCallbacks; 232 using WebKit::WebStorageQuotaCallbacks;
225 using WebKit::WebStorageQuotaError; 233 using WebKit::WebStorageQuotaError;
226 using WebKit::WebStorageQuotaType; 234 using WebKit::WebStorageQuotaType;
227 using WebKit::WebString; 235 using WebKit::WebString;
228 using WebKit::WebTextAffinity; 236 using WebKit::WebTextAffinity;
229 using WebKit::WebTextDirection; 237 using WebKit::WebTextDirection;
230 using WebKit::WebTouchEvent; 238 using WebKit::WebTouchEvent;
231 using WebKit::WebURL; 239 using WebKit::WebURL;
232 using WebKit::WebURLError; 240 using WebKit::WebURLError;
233 using WebKit::WebURLRequest; 241 using WebKit::WebURLRequest;
234 using WebKit::WebURLResponse; 242 using WebKit::WebURLResponse;
235 using WebKit::WebVector; 243 using WebKit::WebVector;
236 using WebKit::WebView; 244 using WebKit::WebView;
237 using WebKit::WebWidget; 245 using WebKit::WebWidget;
238 using WebKit::WebWindowFeatures; 246 using WebKit::WebWindowFeatures;
239 using WebKit::WebWorker; 247 using WebKit::WebWorker;
240 using WebKit::WebWorkerClient; 248 using WebKit::WebWorkerClient;
241 using appcache::WebApplicationCacheHostImpl; 249 using appcache::WebApplicationCacheHostImpl;
242 using base::Time; 250 using base::Time;
243 using base::TimeDelta; 251 using base::TimeDelta;
244 using content::DocumentState; 252 using content::DocumentState;
253 using content::DOMProxyInstaller;
254 using content::ProxyViewHost;
245 using content::NavigationState; 255 using content::NavigationState;
246 using content::RenderThread; 256 using content::RenderThread;
247 using content::RenderViewObserver; 257 using content::RenderViewObserver;
248 using content::RenderViewVisitor; 258 using content::RenderViewVisitor;
249 using content::V8ValueConverter; 259 using content::V8ValueConverter;
250 using webkit_glue::AltErrorPageResourceFetcher; 260 using webkit_glue::AltErrorPageResourceFetcher;
251 using webkit_glue::FormField; 261 using webkit_glue::FormField;
252 using webkit_glue::PasswordForm; 262 using webkit_glue::PasswordForm;
253 using webkit_glue::PasswordFormDomManager; 263 using webkit_glue::PasswordFormDomManager;
254 using webkit_glue::ResourceFetcher; 264 using webkit_glue::ResourceFetcher;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 #endif 697 #endif
688 #if defined(OS_MACOSX) 698 #if defined(OS_MACOSX)
689 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) 699 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
690 #endif 700 #endif
691 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 701 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
692 OnSetHistoryLengthAndPrune) 702 OnSetHistoryLengthAndPrune)
693 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 703 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
694 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) 704 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK)
695 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) 705 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost)
696 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) 706 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit)
707 IPC_MESSAGE_HANDLER(ViewMsg_PostMessage, OnPostMessage)
708 IPC_MESSAGE_HANDLER(ViewMsg_SetOpenerProxy, OnSetOpenerProxy)
697 709
698 // Have the super handle all other messages. 710 // Have the super handle all other messages.
699 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) 711 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
700 IPC_END_MESSAGE_MAP() 712 IPC_END_MESSAGE_MAP()
701 713
702 if (!msg_is_ok) { 714 if (!msg_is_ok) {
703 // The message had a handler, but its deserialization failed. 715 // The message had a handler, but its deserialization failed.
704 // Kill the renderer to avoid potential spoofing attacks. 716 // Kill the renderer to avoid potential spoofing attacks.
705 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; 717 CHECK(false) << "Unable to deserialize message in RenderViewImpl.";
706 } 718 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 793
782 if (!params.extra_headers.empty()) { 794 if (!params.extra_headers.empty()) {
783 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), 795 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(),
784 params.extra_headers.end(), "\n"); 796 params.extra_headers.end(), "\n");
785 i.GetNext(); ) { 797 i.GetNext(); ) {
786 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 798 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
787 WebString::fromUTF8(i.values())); 799 WebString::fromUTF8(i.values()));
788 } 800 }
789 } 801 }
790 802
803 DLOG(WARNING) << "Navigating to " << params.url << " with opener = " <<
804 params.opener_browsing_instance_frame_id;
805
806 if (params.opener_browsing_instance_frame_id != -1) {
807 ProxyViewHost* proxy_view_host = new ProxyViewHost(
808 this, params.opener_browsing_instance_frame_id);
809 main_frame->setOpener(proxy_view_host->mainFrame());
810 }
Charlie Reis 2011/12/01 23:13:02 Hmm, what happens if we go back to the NavigationE
supersat 2011/12/09 23:08:20 Yeah, and we shouldn't. Fixed. (But we should test
791 main_frame->loadRequest(request); 811 main_frame->loadRequest(request);
792 } 812 }
793 813
794 // In case LoadRequest failed before DidCreateDataSource was called. 814 // In case LoadRequest failed before DidCreateDataSource was called.
795 pending_navigation_params_.reset(); 815 pending_navigation_params_.reset();
796 } 816 }
797 817
798 bool RenderViewImpl::IsBackForwardToStaleEntry( 818 bool RenderViewImpl::IsBackForwardToStaleEntry(
799 const ViewMsg_Navigate_Params& params, 819 const ViewMsg_Navigate_Params& params,
800 bool is_reload) { 820 bool is_reload) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 952 }
933 953
934 void RenderViewImpl::OnPasteAndMatchStyle() { 954 void RenderViewImpl::OnPasteAndMatchStyle() {
935 if (!webview()) 955 if (!webview())
936 return; 956 return;
937 957
938 webview()->focusedFrame()->executeCommand( 958 webview()->focusedFrame()->executeCommand(
939 WebString::fromUTF8("PasteAndMatchStyle")); 959 WebString::fromUTF8("PasteAndMatchStyle"));
940 } 960 }
941 961
962 void RenderViewImpl::OnPostMessage(int64 frame_id,
963 const ViewMsg_PostMessage_Params& params) {
964 // TODO(supersat): support subframes
965 WebFrame *frame = webview()->mainFrame();
966
967 // We need to check whether we can send this message to the frame, since the
968 // asynchrony of postMessage means that the target frame's origin can change
969 // in the middle of a postMessage dispatch
970 WebSecurityOrigin messageSpecifiedOrigin =
971 WebSecurityOrigin::createFromString(WebString(params.origin));
972 if (!frame->document().securityOrigin().canReceivePostMessage(
973 &messageSpecifiedOrigin))
974 return;
975
976 WebDOMEvent event = frame->document().createEvent("MessageEvent");
977 WebDOMMessageEvent msgEvent = event.to<WebDOMMessageEvent>();
978
979 // TODO(supersat): fix the source frame parameter
980 msgEvent.initMessageEvent("message",
981 // canBubble and cancellable are always false
982 false, false,
983 WebSerializedScriptValue::fromString(params.data),
984 params.origin, 0 /* source frame */,
985 params.lastEventId);
986
987 DLOG(WARNING) << "Dispatching postMessage event";
988 frame->dispatchEvent(msgEvent);
989 }
990
942 void RenderViewImpl::OnReplace(const string16& text) { 991 void RenderViewImpl::OnReplace(const string16& text) {
943 if (!webview()) 992 if (!webview())
944 return; 993 return;
945 994
946 WebFrame* frame = webview()->focusedFrame(); 995 WebFrame* frame = webview()->focusedFrame();
947 if (!frame->hasSelection()) 996 if (!frame->hasSelection())
948 frame->selectWordAroundCaret(); 997 frame->selectWordAroundCaret();
949 frame->replaceSelection(text); 998 frame->replaceSelection(text);
950 } 999 }
951 1000
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 return; 1280 return;
1232 1281
1233 Send(new ViewHostMsg_UpdateState( 1282 Send(new ViewHostMsg_UpdateState(
1234 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); 1283 routing_id_, page_id_, webkit_glue::HistoryItemToString(item)));
1235 } 1284 }
1236 1285
1237 void RenderViewImpl::OpenURL(WebFrame* frame, 1286 void RenderViewImpl::OpenURL(WebFrame* frame,
1238 const GURL& url, 1287 const GURL& url,
1239 const GURL& referrer, 1288 const GURL& referrer,
1240 WebNavigationPolicy policy) { 1289 WebNavigationPolicy policy) {
1241 Send(new ViewHostMsg_OpenURL( 1290 long long opener_frame_id = -1;
1242 routing_id_, 1291 if (frame->opener()) {
1243 url, 1292 opener_frame_id = frame->opener()->identifier();
1244 referrer, 1293 }
1245 NavigationPolicyToDisposition(policy), 1294
1246 frame->identifier())); 1295 ViewHostMsg_OpenURL_Params params;
1296 params.url = url;
1297 params.referrer = referrer;
1298 params.disposition = NavigationPolicyToDisposition(policy);
1299 params.source_frame_id = frame->identifier();
1300 params.opener_frame_id = opener_frame_id;
1301
1302 Send(new ViewHostMsg_OpenURL(routing_id_, params));
1247 } 1303 }
1248 1304
1249 // WebViewDelegate ------------------------------------------------------------ 1305 // WebViewDelegate ------------------------------------------------------------
1250 1306
1251 void RenderViewImpl::LoadNavigationErrorPage( 1307 void RenderViewImpl::LoadNavigationErrorPage(
1252 WebFrame* frame, 1308 WebFrame* frame,
1253 const WebURLRequest& failed_request, 1309 const WebURLRequest& failed_request,
1254 const WebURLError& error, 1310 const WebURLError& error,
1255 const std::string& html, 1311 const std::string& html,
1256 bool replace) { 1312 bool replace) {
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, 2036 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer,
1981 suggested_name)); 2037 suggested_name));
1982 } else { 2038 } else {
1983 OpenURL(frame, request.url(), referrer, policy); 2039 OpenURL(frame, request.url(), referrer, policy);
1984 } 2040 }
1985 } 2041 }
1986 2042
1987 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( 2043 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation(
1988 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, 2044 WebFrame* frame, const WebURLRequest& request, WebNavigationType type,
1989 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { 2045 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) {
1990 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation.
Charlie Reis 2011/12/01 23:13:02 This can't be removed any more, can it?
supersat 2011/12/09 23:08:20 No. Done.
1991 if (is_swapped_out_) {
1992 DCHECK(request.url() == GURL("about:swappedout"));
1993 return default_policy;
1994 }
1995
1996 // Webkit is asking whether to navigate to a new URL. 2046 // Webkit is asking whether to navigate to a new URL.
1997 // This is fine normally, except if we're showing UI from one security 2047 // This is fine normally, except if we're showing UI from one security
1998 // context and they're trying to navigate to a different context. 2048 // context and they're trying to navigate to a different context.
1999 const GURL& url = request.url(); 2049 const GURL& url = request.url();
2000 2050
2001 // A content initiated navigation may have originated from a link-click, 2051 // A content initiated navigation may have originated from a link-click,
2002 // script, drag-n-drop operation, etc. 2052 // script, drag-n-drop operation, etc.
2003 bool is_content_initiated = 2053 bool is_content_initiated =
2004 DocumentState::FromDataSource(frame->provisionalDataSource())-> 2054 DocumentState::FromDataSource(frame->provisionalDataSource())->
2005 navigation_state()->is_content_initiated(); 2055 navigation_state()->is_content_initiated();
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 host_zoom_levels_[url] = zoom_level; 3744 host_zoom_levels_[url] = zoom_level;
3695 } 3745 }
3696 3746
3697 void RenderViewImpl::OnExitFullscreen() { 3747 void RenderViewImpl::OnExitFullscreen() {
3698 // TODO(darin): Remove this IPC once WebKit has been updated. 3748 // TODO(darin): Remove this IPC once WebKit has been updated.
3699 #ifndef WEBKIT_HAS_NEW_FULLSCREEN_API 3749 #ifndef WEBKIT_HAS_NEW_FULLSCREEN_API
3700 webview()->exitFullscreen(); 3750 webview()->exitFullscreen();
3701 #endif 3751 #endif
3702 } 3752 }
3703 3753
3754 void RenderViewImpl::OnSetOpenerProxy(const ViewMsg_SetOpenerProxy_Params& param s) {
3755 //webview()->mainFrame()->setOpener();
3756 }
3757
3704 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { 3758 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) {
3705 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); 3759 webview()->setPageEncoding(WebString::fromUTF8(encoding_name));
3706 } 3760 }
3707 3761
3708 void RenderViewImpl::OnResetPageEncodingToDefault() { 3762 void RenderViewImpl::OnResetPageEncodingToDefault() {
3709 WebString no_encoding; 3763 WebString no_encoding;
3710 webview()->setPageEncoding(no_encoding); 3764 webview()->setPageEncoding(no_encoding);
3711 } 3765 }
3712 3766
3713 WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { 3767 WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 4035
3982 // Send an UpdateState message before we get swapped out. 4036 // Send an UpdateState message before we get swapped out.
3983 SyncNavigationState(); 4037 SyncNavigationState();
3984 4038
3985 // Synchronously run the unload handler before sending the ACK. 4039 // Synchronously run the unload handler before sending the ACK.
3986 webview()->dispatchUnloadEvent(); 4040 webview()->dispatchUnloadEvent();
3987 4041
3988 // Swap out and stop sending any IPC messages that are not ACKs. 4042 // Swap out and stop sending any IPC messages that are not ACKs.
3989 SetSwappedOut(true); 4043 SetSwappedOut(true);
3990 4044
3991 // Replace the page with a blank dummy URL. The unload handler will not be 4045 // Replace the page with a blank dummy document.
3992 // run a second time, thanks to a check in FrameLoader::stopLoading. 4046 /*
3993 // TODO(creis): Need to add a better way to do this that avoids running the 4047 //webview()->mainFrame()->clearDocument();
3994 // beforeunload handler. For now, we just run it a second time silently. 4048 WebDocument dummyDocument = WebDocument::create(*frame,
3995 webview()->mainFrame()->loadHTMLString(std::string(), 4049 "text/html",
3996 GURL("about:swappedout"), 4050 GURL());
3997 GURL("about:swappedout"), 4051 dummyDocument.securityOrigin().grantUniversalAccess();
3998 false); 4052 frame->setDocument(dummyDocument);
4053 */
4054
4055 WebFrame* frame = webview()->mainFrame();
4056 frame->loadHTMLString(std::string(), GURL("about:swappedout"),
4057 GURL("about:swappedout"), false);
4058
4059 // Set up the postMessage event proxy
4060 new DOMProxyInstaller(this, params.browsing_instance_frame_id);
Charlie Reis 2011/12/01 23:13:02 I wonder if there's a clearer way to handle this.
supersat 2011/12/09 23:08:20 If we go with Adam's approach, we don't need the D
3999 4061
4000 // Just echo back the params in the ACK. 4062 // Just echo back the params in the ACK.
4001 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); 4063 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params));
4002 } 4064 }
4003 4065
4004 void RenderViewImpl::OnClosePage() { 4066 void RenderViewImpl::OnClosePage() {
4005 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); 4067 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage());
4006 // TODO(creis): We'd rather use webview()->Close() here, but that currently 4068 // TODO(creis): We'd rather use webview()->Close() here, but that currently
4007 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs 4069 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs
4008 // in the onunload handler from appearing. For now, we're bypassing that and 4070 // in the onunload handler from appearing. For now, we're bypassing that and
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
4752 return !!RenderThreadImpl::current()->compositor_thread(); 4814 return !!RenderThreadImpl::current()->compositor_thread();
4753 } 4815 }
4754 4816
4755 void RenderViewImpl::OnJavaBridgeInit( 4817 void RenderViewImpl::OnJavaBridgeInit(
4756 const IPC::ChannelHandle& channel_handle) { 4818 const IPC::ChannelHandle& channel_handle) {
4757 DCHECK(!java_bridge_dispatcher_.get()); 4819 DCHECK(!java_bridge_dispatcher_.get());
4758 #if defined(ENABLE_JAVA_BRIDGE) 4820 #if defined(ENABLE_JAVA_BRIDGE)
4759 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); 4821 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle));
4760 #endif 4822 #endif
4761 } 4823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698