OLD | NEW |
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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/json/json_value_serializer.h" | 16 #include "base/json/json_value_serializer.h" |
17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
22 #include "base/string_piece.h" | 22 #include "base/string_piece.h" |
23 #include "base/string_split.h" | 23 #include "base/string_split.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
26 #include "base/time.h" | 26 #include "base/time.h" |
27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
28 #include "content/common/appcache/appcache_dispatcher.h" | 28 #include "content/common/appcache/appcache_dispatcher.h" |
| 29 #include "content/common/child_thread.h" |
29 #include "content/common/clipboard_messages.h" | 30 #include "content/common/clipboard_messages.h" |
30 #include "content/common/database_messages.h" | 31 #include "content/common/database_messages.h" |
31 #include "content/common/drag_messages.h" | 32 #include "content/common/drag_messages.h" |
32 #include "content/common/file_system/file_system_dispatcher.h" | 33 #include "content/common/file_system/file_system_dispatcher.h" |
33 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" | 34 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" |
34 #include "content/common/intents_messages.h" | 35 #include "content/common/intents_messages.h" |
35 #include "content/common/java_bridge_messages.h" | 36 #include "content/common/java_bridge_messages.h" |
36 #include "content/common/pepper_messages.h" | 37 #include "content/common/pepper_messages.h" |
37 #include "content/common/pepper_plugin_registry.h" | 38 #include "content/common/pepper_plugin_registry.h" |
38 #include "content/common/quota_dispatcher.h" | 39 #include "content/common/quota_dispatcher.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 #include "media/base/media_switches.h" | 83 #include "media/base/media_switches.h" |
83 #include "media/base/message_loop_factory_impl.h" | 84 #include "media/base/message_loop_factory_impl.h" |
84 #include "media/filters/gpu_video_decoder.h" | 85 #include "media/filters/gpu_video_decoder.h" |
85 #include "net/base/escape.h" | 86 #include "net/base/escape.h" |
86 #include "net/base/net_errors.h" | 87 #include "net/base/net_errors.h" |
87 #include "net/http/http_util.h" | 88 #include "net/http/http_util.h" |
88 #include "ppapi/c/private/ppb_flash_net_connector.h" | 89 #include "ppapi/c/private/ppb_flash_net_connector.h" |
89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" |
90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
91 #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" |
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" |
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" | 98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" | 99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" |
97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" | 100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" | 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" | 105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" |
103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.
h" | 106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.
h" |
104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" | 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" |
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" | 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" | 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" |
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 119 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" | 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" |
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
121 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
122 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" | 126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" |
123 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" | 127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" | 129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 using WebKit::WebApplicationCacheHostClient; | 177 using WebKit::WebApplicationCacheHostClient; |
174 using WebKit::WebCString; | 178 using WebKit::WebCString; |
175 using WebKit::WebColor; | 179 using WebKit::WebColor; |
176 using WebKit::WebColorName; | 180 using WebKit::WebColorName; |
177 using WebKit::WebConsoleMessage; | 181 using WebKit::WebConsoleMessage; |
178 using WebKit::WebContextMenuData; | 182 using WebKit::WebContextMenuData; |
179 using WebKit::WebCookieJar; | 183 using WebKit::WebCookieJar; |
180 using WebKit::WebData; | 184 using WebKit::WebData; |
181 using WebKit::WebDataSource; | 185 using WebKit::WebDataSource; |
182 using WebKit::WebDocument; | 186 using WebKit::WebDocument; |
| 187 using WebKit::WebDOMEvent; |
| 188 using WebKit::WebDOMMessageEvent; |
183 using WebKit::WebDragData; | 189 using WebKit::WebDragData; |
184 using WebKit::WebDragOperation; | 190 using WebKit::WebDragOperation; |
185 using WebKit::WebDragOperationsMask; | 191 using WebKit::WebDragOperationsMask; |
186 using WebKit::WebEditingAction; | 192 using WebKit::WebEditingAction; |
187 using WebKit::WebElement; | 193 using WebKit::WebElement; |
188 using WebKit::WebExternalPopupMenu; | 194 using WebKit::WebExternalPopupMenu; |
189 using WebKit::WebExternalPopupMenuClient; | 195 using WebKit::WebExternalPopupMenuClient; |
190 using WebKit::WebFileChooserCompletion; | 196 using WebKit::WebFileChooserCompletion; |
191 using WebKit::WebFileSystem; | 197 using WebKit::WebFileSystem; |
192 using WebKit::WebFileSystemCallbacks; | 198 using WebKit::WebFileSystemCallbacks; |
(...skipping 19 matching lines...) Expand all Loading... |
212 using WebKit::WebPluginParams; | 218 using WebKit::WebPluginParams; |
213 using WebKit::WebPoint; | 219 using WebKit::WebPoint; |
214 using WebKit::WebPopupMenuInfo; | 220 using WebKit::WebPopupMenuInfo; |
215 using WebKit::WebRange; | 221 using WebKit::WebRange; |
216 using WebKit::WebRect; | 222 using WebKit::WebRect; |
217 using WebKit::WebReferrerPolicy; | 223 using WebKit::WebReferrerPolicy; |
218 using WebKit::WebScriptSource; | 224 using WebKit::WebScriptSource; |
219 using WebKit::WebSearchableFormData; | 225 using WebKit::WebSearchableFormData; |
220 using WebKit::WebSecurityOrigin; | 226 using WebKit::WebSecurityOrigin; |
221 using WebKit::WebSecurityPolicy; | 227 using WebKit::WebSecurityPolicy; |
| 228 using WebKit::WebSerializedScriptValue; |
222 using WebKit::WebSettings; | 229 using WebKit::WebSettings; |
223 using WebKit::WebSharedWorker; | 230 using WebKit::WebSharedWorker; |
224 using WebKit::WebSize; | 231 using WebKit::WebSize; |
225 using WebKit::WebStorageNamespace; | 232 using WebKit::WebStorageNamespace; |
226 using WebKit::WebStorageQuotaCallbacks; | 233 using WebKit::WebStorageQuotaCallbacks; |
227 using WebKit::WebStorageQuotaError; | 234 using WebKit::WebStorageQuotaError; |
228 using WebKit::WebStorageQuotaType; | 235 using WebKit::WebStorageQuotaType; |
229 using WebKit::WebString; | 236 using WebKit::WebString; |
230 using WebKit::WebTextAffinity; | 237 using WebKit::WebTextAffinity; |
231 using WebKit::WebTextDirection; | 238 using WebKit::WebTextDirection; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 333 |
327 RenderViewImpl::RenderViewImpl( | 334 RenderViewImpl::RenderViewImpl( |
328 gfx::NativeViewId parent_hwnd, | 335 gfx::NativeViewId parent_hwnd, |
329 int32 opener_id, | 336 int32 opener_id, |
330 const content::RendererPreferences& renderer_prefs, | 337 const content::RendererPreferences& renderer_prefs, |
331 const WebPreferences& webkit_prefs, | 338 const WebPreferences& webkit_prefs, |
332 SharedRenderViewCounter* counter, | 339 SharedRenderViewCounter* counter, |
333 int32 routing_id, | 340 int32 routing_id, |
334 int64 session_storage_namespace_id, | 341 int64 session_storage_namespace_id, |
335 const string16& frame_name, | 342 const string16& frame_name, |
| 343 bool is_renderer_created, |
336 int32 next_page_id) | 344 int32 next_page_id) |
337 : RenderWidget(WebKit::WebPopupTypeNone), | 345 : RenderWidget(WebKit::WebPopupTypeNone), |
338 webkit_preferences_(webkit_prefs), | 346 webkit_preferences_(webkit_prefs), |
339 send_content_state_immediately_(false), | 347 send_content_state_immediately_(false), |
340 enabled_bindings_(0), | 348 enabled_bindings_(0), |
341 send_preferred_size_changes_(false), | 349 send_preferred_size_changes_(false), |
342 is_loading_(false), | 350 is_loading_(false), |
343 navigation_gesture_(NavigationGestureUnknown), | 351 navigation_gesture_(NavigationGestureUnknown), |
344 opened_by_user_gesture_(true), | 352 opened_by_user_gesture_(true), |
345 opener_suppressed_(false), | 353 opener_suppressed_(false), |
(...skipping 10 matching lines...) Expand all Loading... |
356 cached_has_main_frame_vertical_scrollbar_(false), | 364 cached_has_main_frame_vertical_scrollbar_(false), |
357 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 365 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
358 geolocation_dispatcher_(NULL), | 366 geolocation_dispatcher_(NULL), |
359 speech_input_dispatcher_(NULL), | 367 speech_input_dispatcher_(NULL), |
360 device_orientation_dispatcher_(NULL), | 368 device_orientation_dispatcher_(NULL), |
361 p2p_socket_dispatcher_(NULL), | 369 p2p_socket_dispatcher_(NULL), |
362 devtools_agent_(NULL), | 370 devtools_agent_(NULL), |
363 renderer_accessibility_(NULL), | 371 renderer_accessibility_(NULL), |
364 session_storage_namespace_id_(session_storage_namespace_id), | 372 session_storage_namespace_id_(session_storage_namespace_id), |
365 handling_select_range_(false), | 373 handling_select_range_(false), |
| 374 active_content_frame_id_(-1), |
366 #if defined(OS_WIN) | 375 #if defined(OS_WIN) |
367 focused_plugin_id_(-1), | 376 focused_plugin_id_(-1), |
368 #endif | 377 #endif |
369 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { | 378 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
370 routing_id_ = routing_id; | 379 routing_id_ = routing_id; |
371 if (opener_id != MSG_ROUTING_NONE) | 380 if (opener_id != MSG_ROUTING_NONE && is_renderer_created) |
372 opener_id_ = opener_id; | 381 opener_id_ = opener_id; |
373 | 382 |
374 // Ensure we start with a valid next_page_id_ from the browser. | 383 // Ensure we start with a valid next_page_id_ from the browser. |
375 DCHECK_GE(next_page_id_, 0); | 384 DCHECK_GE(next_page_id_, 0); |
376 | 385 |
377 #if defined(ENABLE_NOTIFICATIONS) | 386 #if defined(ENABLE_NOTIFICATIONS) |
378 notification_provider_ = new NotificationProvider(this); | 387 notification_provider_ = new NotificationProvider(this); |
379 #else | 388 #else |
380 notification_provider_ = NULL; | 389 notification_provider_ = NULL; |
381 #endif | 390 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
393 | 402 |
394 intents_dispatcher_ = new IntentsDispatcher(this); | 403 intents_dispatcher_ = new IntentsDispatcher(this); |
395 | 404 |
396 RenderThread::Get()->AddRoute(routing_id_, this); | 405 RenderThread::Get()->AddRoute(routing_id_, this); |
397 // Take a reference on behalf of the RenderThread. This will be balanced | 406 // Take a reference on behalf of the RenderThread. This will be balanced |
398 // when we receive ViewMsg_ClosePage. | 407 // when we receive ViewMsg_ClosePage. |
399 AddRef(); | 408 AddRef(); |
400 | 409 |
401 // If this is a popup, we must wait for the CreatingNew_ACK message before | 410 // If this is a popup, we must wait for the CreatingNew_ACK message before |
402 // completing initialization. Otherwise, we can finish it now. | 411 // completing initialization. Otherwise, we can finish it now. |
403 if (opener_id == MSG_ROUTING_NONE) { | 412 if (opener_id_ == MSG_ROUTING_NONE) { |
404 did_show_ = true; | 413 did_show_ = true; |
405 CompleteInit(parent_hwnd); | 414 CompleteInit(parent_hwnd); |
406 } | 415 } |
407 | 416 |
408 g_view_map.Get().insert(std::make_pair(webview(), this)); | 417 g_view_map.Get().insert(std::make_pair(webview(), this)); |
409 webkit_preferences_.Apply(webview()); | 418 webkit_preferences_.Apply(webview()); |
410 webview()->initializeMainFrame(this); | 419 webview()->initializeMainFrame(this); |
411 if (!frame_name.empty()) | 420 if (!frame_name.empty()) |
412 webview()->mainFrame()->setName(frame_name); | 421 webview()->mainFrame()->setName(frame_name); |
413 webview()->settings()->setMinimumTimerInterval( | 422 webview()->settings()->setMinimumTimerInterval( |
(...skipping 19 matching lines...) Expand all Loading... |
433 | 442 |
434 new IdleUserDetector(this); | 443 new IdleUserDetector(this); |
435 | 444 |
436 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 445 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
437 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 446 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
438 media_stream_impl_ = new MediaStreamImpl( | 447 media_stream_impl_ = new MediaStreamImpl( |
439 RenderThreadImpl::current()->video_capture_impl_manager()); | 448 RenderThreadImpl::current()->video_capture_impl_manager()); |
440 } | 449 } |
441 | 450 |
442 content::GetContentClient()->renderer()->RenderViewCreated(this); | 451 content::GetContentClient()->renderer()->RenderViewCreated(this); |
| 452 |
| 453 // If we have an opener_id but we weren't created by a renderer, then |
| 454 // it's the browser asking us to set our opener to another RenderView. |
| 455 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { |
| 456 RenderViewImpl* opener_rv = |
| 457 static_cast<RenderViewImpl*>( |
| 458 ChildThread::current()->ResolveRoute(opener_id)); |
| 459 webview()->mainFrame()->setOpener(opener_rv->webview()->mainFrame()); |
| 460 } |
443 } | 461 } |
444 | 462 |
445 RenderViewImpl::~RenderViewImpl() { | 463 RenderViewImpl::~RenderViewImpl() { |
446 history_page_ids_.clear(); | 464 history_page_ids_.clear(); |
447 | 465 |
448 if (decrement_shared_popup_at_destruction_) | 466 if (decrement_shared_popup_at_destruction_) |
449 shared_popup_counter_->data--; | 467 shared_popup_counter_->data--; |
450 | 468 |
451 // If file chooser is still waiting for answer, dispatch empty answer. | 469 // If file chooser is still waiting for answer, dispatch empty answer. |
452 while (!file_chooser_completions_.empty()) { | 470 while (!file_chooser_completions_.empty()) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 /*static*/ | 521 /*static*/ |
504 RenderViewImpl* RenderViewImpl::Create( | 522 RenderViewImpl* RenderViewImpl::Create( |
505 gfx::NativeViewId parent_hwnd, | 523 gfx::NativeViewId parent_hwnd, |
506 int32 opener_id, | 524 int32 opener_id, |
507 const content::RendererPreferences& renderer_prefs, | 525 const content::RendererPreferences& renderer_prefs, |
508 const WebPreferences& webkit_prefs, | 526 const WebPreferences& webkit_prefs, |
509 SharedRenderViewCounter* counter, | 527 SharedRenderViewCounter* counter, |
510 int32 routing_id, | 528 int32 routing_id, |
511 int64 session_storage_namespace_id, | 529 int64 session_storage_namespace_id, |
512 const string16& frame_name, | 530 const string16& frame_name, |
| 531 bool is_renderer_created, |
513 int32 next_page_id) { | 532 int32 next_page_id) { |
514 DCHECK(routing_id != MSG_ROUTING_NONE); | 533 DCHECK(routing_id != MSG_ROUTING_NONE); |
515 return new RenderViewImpl( | 534 return new RenderViewImpl( |
516 parent_hwnd, | 535 parent_hwnd, |
517 opener_id, | 536 opener_id, |
518 renderer_prefs, | 537 renderer_prefs, |
519 webkit_prefs, | 538 webkit_prefs, |
520 counter, | 539 counter, |
521 routing_id, | 540 routing_id, |
522 session_storage_namespace_id, | 541 session_storage_namespace_id, |
523 frame_name, | 542 frame_name, |
| 543 is_renderer_created, |
524 next_page_id); // adds reference | 544 next_page_id); // adds reference |
525 } | 545 } |
526 | 546 |
527 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 547 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
528 observers_.AddObserver(observer); | 548 observers_.AddObserver(observer); |
529 } | 549 } |
530 | 550 |
531 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 551 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
532 observer->RenderViewGone(); | 552 observer->RenderViewGone(); |
533 observers_.RemoveObserver(observer); | 553 observers_.RemoveObserver(observer); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 #endif | 711 #endif |
692 #if defined(OS_MACOSX) | 712 #if defined(OS_MACOSX) |
693 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 713 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
694 #endif | 714 #endif |
695 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 715 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
696 OnSetHistoryLengthAndPrune) | 716 OnSetHistoryLengthAndPrune) |
697 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 717 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
698 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | 718 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
699 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) | 719 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
700 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 720 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
| 721 IPC_MESSAGE_HANDLER(ViewMsg_PostMessage, OnPostMessage) |
701 | 722 |
702 // Have the super handle all other messages. | 723 // Have the super handle all other messages. |
703 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 724 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
704 IPC_END_MESSAGE_MAP() | 725 IPC_END_MESSAGE_MAP() |
705 | 726 |
706 if (!msg_is_ok) { | 727 if (!msg_is_ok) { |
707 // The message had a handler, but its deserialization failed. | 728 // The message had a handler, but its deserialization failed. |
708 // Kill the renderer to avoid potential spoofing attacks. | 729 // Kill the renderer to avoid potential spoofing attacks. |
709 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 730 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
710 } | 731 } |
711 | 732 |
712 return handled; | 733 return handled; |
713 } | 734 } |
714 | 735 |
715 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { | 736 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
716 if (!webview()) | 737 if (!webview()) |
717 return; | 738 return; |
718 | 739 |
719 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 740 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
720 | 741 |
721 bool is_reload = IsReload(params); | 742 bool is_reload = IsReload(params); |
722 | 743 |
723 // If this is a stale back/forward (due to a recent navigation the browser | 744 // If this is a stale back/forward (due to a recent navigation the browser |
724 // didn't know about), ignore it. | 745 // didn't know about), ignore it. |
725 if (IsBackForwardToStaleEntry(params, is_reload)) | 746 if (IsBackForwardToStaleEntry(params, is_reload)) |
726 return; | 747 return; |
727 | 748 |
728 // Swap this renderer back in if necessary. | 749 // Swap this renderer back in if necessary. |
729 if (is_swapped_out_) | 750 if (is_swapped_out_) { |
730 SetSwappedOut(false); | 751 SetSwappedOut(false); |
| 752 active_content_frame_id_ = -1; |
| 753 } |
731 | 754 |
732 history_list_offset_ = params.current_history_list_offset; | 755 history_list_offset_ = params.current_history_list_offset; |
733 history_list_length_ = params.current_history_list_length; | 756 history_list_length_ = params.current_history_list_length; |
734 if (history_list_length_ >= 0) | 757 if (history_list_length_ >= 0) |
735 history_page_ids_.resize(history_list_length_, -1); | 758 history_page_ids_.resize(history_list_length_, -1); |
736 if (params.pending_history_list_offset >= 0 && | 759 if (params.pending_history_list_offset >= 0 && |
737 params.pending_history_list_offset < history_list_length_) | 760 params.pending_history_list_offset < history_list_length_) |
738 history_page_ids_[params.pending_history_list_offset] = params.page_id; | 761 history_page_ids_[params.pending_history_list_offset] = params.page_id; |
739 | 762 |
740 content::GetContentClient()->SetActiveURL(params.url); | 763 content::GetContentClient()->SetActiveURL(params.url); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 } | 959 } |
937 | 960 |
938 void RenderViewImpl::OnPasteAndMatchStyle() { | 961 void RenderViewImpl::OnPasteAndMatchStyle() { |
939 if (!webview()) | 962 if (!webview()) |
940 return; | 963 return; |
941 | 964 |
942 webview()->focusedFrame()->executeCommand( | 965 webview()->focusedFrame()->executeCommand( |
943 WebString::fromUTF8("PasteAndMatchStyle")); | 966 WebString::fromUTF8("PasteAndMatchStyle")); |
944 } | 967 } |
945 | 968 |
| 969 void RenderViewImpl::OnPostMessage(int64 frame_id, |
| 970 const ViewMsg_PostMessage_Params& params) { |
| 971 // TODO(supersat): support subframes |
| 972 WebFrame *frame = webview()->mainFrame(); |
| 973 |
| 974 // We need to check whether we can send this message to the frame, since the |
| 975 // asynchrony of postMessage means that the target frame's origin can change |
| 976 // in the middle of a postMessage dispatch. An empty target origin means that |
| 977 // "*" was passed in, and any target origin is acceptable. |
| 978 if (!params.target_origin.empty()) { |
| 979 WebSecurityOrigin messageSpecifiedOrigin = |
| 980 WebSecurityOrigin::createFromString(WebString(params.target_origin)); |
| 981 if (!messageSpecifiedOrigin.isSameSchemeHostPort( |
| 982 frame->document().securityOrigin())) |
| 983 return; |
| 984 } |
| 985 |
| 986 WebDOMEvent event = frame->document().createEvent("MessageEvent"); |
| 987 WebDOMMessageEvent msgEvent = event.to<WebDOMMessageEvent>(); |
| 988 |
| 989 // TODO(supersat): fix the source frame parameter |
| 990 msgEvent.initMessageEvent("message", |
| 991 // |canBubble| and |cancellable| are always false |
| 992 false, false, |
| 993 WebSerializedScriptValue::fromString(params.data), |
| 994 params.source_origin, 0 /* source frame */, |
| 995 "" /* last event id, not used with postmsg */); |
| 996 |
| 997 DLOG(WARNING) << "Dispatching postMessage event"; |
| 998 frame->dispatchEvent(msgEvent); |
| 999 } |
| 1000 |
946 void RenderViewImpl::OnReplace(const string16& text) { | 1001 void RenderViewImpl::OnReplace(const string16& text) { |
947 if (!webview()) | 1002 if (!webview()) |
948 return; | 1003 return; |
949 | 1004 |
950 WebFrame* frame = webview()->focusedFrame(); | 1005 WebFrame* frame = webview()->focusedFrame(); |
951 if (!frame->hasSelection()) | 1006 if (!frame->hasSelection()) |
952 frame->selectWordAroundCaret(); | 1007 frame->selectWordAroundCaret(); |
953 frame->replaceSelection(text); | 1008 frame->replaceSelection(text); |
954 } | 1009 } |
955 | 1010 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 | 1395 |
1341 RenderViewImpl* view = RenderViewImpl::Create( | 1396 RenderViewImpl* view = RenderViewImpl::Create( |
1342 0, | 1397 0, |
1343 routing_id_, | 1398 routing_id_, |
1344 renderer_preferences_, | 1399 renderer_preferences_, |
1345 webkit_preferences_, | 1400 webkit_preferences_, |
1346 shared_popup_counter_, | 1401 shared_popup_counter_, |
1347 routing_id, | 1402 routing_id, |
1348 cloned_session_storage_namespace_id, | 1403 cloned_session_storage_namespace_id, |
1349 frame_name, | 1404 frame_name, |
| 1405 true, |
1350 1); | 1406 1); |
1351 view->opened_by_user_gesture_ = params.user_gesture; | 1407 view->opened_by_user_gesture_ = params.user_gesture; |
1352 | 1408 |
1353 // Record whether the creator frame is trying to suppress the opener field. | 1409 // Record whether the creator frame is trying to suppress the opener field. |
1354 view->opener_suppressed_ = opener_suppressed; | 1410 view->opener_suppressed_ = opener_suppressed; |
1355 | 1411 |
1356 // Record the security origin of the creator. | 1412 // Record the security origin of the creator. |
1357 GURL creator_url(creator->document().securityOrigin().toString().utf8()); | 1413 GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
1358 if (!creator_url.is_valid() || !creator_url.IsStandard()) | 1414 if (!creator_url.is_valid() || !creator_url.IsStandard()) |
1359 creator_url = GURL(); | 1415 creator_url = GURL(); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 } else { | 2070 } else { |
2015 OpenURL(frame, request.url(), | 2071 OpenURL(frame, request.url(), |
2016 Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); | 2072 Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); |
2017 } | 2073 } |
2018 } | 2074 } |
2019 | 2075 |
2020 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 2076 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
2021 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 2077 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
2022 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 2078 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
2023 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. | 2079 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
| 2080 // TODO(supersat): This currently causes a crash when reloading an app that |
| 2081 // opens an out-of-app window |
2024 if (is_swapped_out_) { | 2082 if (is_swapped_out_) { |
2025 DCHECK(request.url() == GURL("about:swappedout")); | 2083 DCHECK(request.url() == GURL("about:swappedout")); |
2026 return default_policy; | 2084 return default_policy; |
2027 } | 2085 } |
2028 | 2086 |
2029 // Webkit is asking whether to navigate to a new URL. | 2087 // Webkit is asking whether to navigate to a new URL. |
2030 // This is fine normally, except if we're showing UI from one security | 2088 // This is fine normally, except if we're showing UI from one security |
2031 // context and they're trying to navigate to a different context. | 2089 // context and they're trying to navigate to a different context. |
2032 const GURL& url = request.url(); | 2090 const GURL& url = request.url(); |
2033 | 2091 |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3107 void RenderViewImpl::registerIntentService( | 3165 void RenderViewImpl::registerIntentService( |
3108 WebKit::WebFrame* frame, const WebKit::WebIntentServiceInfo& service) { | 3166 WebKit::WebFrame* frame, const WebKit::WebIntentServiceInfo& service) { |
3109 Send(new IntentsHostMsg_RegisterIntentService(routing_id_, | 3167 Send(new IntentsHostMsg_RegisterIntentService(routing_id_, |
3110 service.action(), | 3168 service.action(), |
3111 service.type(), | 3169 service.type(), |
3112 service.url().spec().utf16(), | 3170 service.url().spec().utf16(), |
3113 service.title(), | 3171 service.title(), |
3114 service.disposition())); | 3172 service.disposition())); |
3115 } | 3173 } |
3116 | 3174 |
| 3175 bool RenderViewImpl::willCheckAndDispatchMessageEvent( |
| 3176 WebKit::WebFrame* source, |
| 3177 WebKit::WebSecurityOrigin target_origin, |
| 3178 WebKit::WebDOMMessageEvent event) { |
| 3179 if (!is_swapped_out_) |
| 3180 return false; |
| 3181 DCHECK_NE(active_content_frame_id_, -1); |
| 3182 |
| 3183 ViewMsg_PostMessage_Params params; |
| 3184 params.data = event.data().toString(); |
| 3185 params.source_origin = event.origin(); |
| 3186 if (!target_origin.isNull()) |
| 3187 params.target_origin = target_origin.toString(); |
| 3188 |
| 3189 Send(new ViewHostMsg_SendPostMessage( |
| 3190 active_content_frame_id_, params)); |
| 3191 return true; |
| 3192 } |
| 3193 |
3117 void RenderViewImpl::dispatchIntent(WebKit::WebFrame* frame, | 3194 void RenderViewImpl::dispatchIntent(WebKit::WebFrame* frame, |
3118 const WebKit::WebIntent& intent) { | 3195 const WebKit::WebIntent& intent) { |
3119 webkit_glue::WebIntentData intent_data(intent); | 3196 webkit_glue::WebIntentData intent_data(intent); |
3120 Send(new IntentsHostMsg_WebIntentDispatch( | 3197 Send(new IntentsHostMsg_WebIntentDispatch( |
3121 routing_id_, intent_data, intent.identifier())); | 3198 routing_id_, intent_data, intent.identifier())); |
3122 } | 3199 } |
3123 | 3200 |
3124 // WebKit::WebPageSerializerClient implementation ------------------------------ | 3201 // WebKit::WebPageSerializerClient implementation ------------------------------ |
3125 | 3202 |
3126 void RenderViewImpl::didSerializeDataForFrame( | 3203 void RenderViewImpl::didSerializeDataForFrame( |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4033 | 4110 |
4034 // Replace the page with a blank dummy URL. The unload handler will not be | 4111 // Replace the page with a blank dummy URL. The unload handler will not be |
4035 // run a second time, thanks to a check in FrameLoader::stopLoading. | 4112 // run a second time, thanks to a check in FrameLoader::stopLoading. |
4036 // TODO(creis): Need to add a better way to do this that avoids running the | 4113 // TODO(creis): Need to add a better way to do this that avoids running the |
4037 // beforeunload handler. For now, we just run it a second time silently. | 4114 // beforeunload handler. For now, we just run it a second time silently. |
4038 webview()->mainFrame()->loadHTMLString(std::string(), | 4115 webview()->mainFrame()->loadHTMLString(std::string(), |
4039 GURL("about:swappedout"), | 4116 GURL("about:swappedout"), |
4040 GURL("about:swappedout"), | 4117 GURL("about:swappedout"), |
4041 false); | 4118 false); |
4042 | 4119 |
| 4120 active_content_frame_id_ = params.content_frame_id; |
| 4121 |
4043 // Just echo back the params in the ACK. | 4122 // Just echo back the params in the ACK. |
4044 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); | 4123 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
4045 } | 4124 } |
4046 | 4125 |
4047 void RenderViewImpl::OnClosePage() { | 4126 void RenderViewImpl::OnClosePage() { |
4048 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); | 4127 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
4049 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 4128 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
4050 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 4129 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
4051 // in the onunload handler from appearing. For now, we're bypassing that and | 4130 // in the onunload handler from appearing. For now, we're bypassing that and |
4052 // calling the FrameLoader's CloseURL method directly. This should be | 4131 // calling the FrameLoader's CloseURL method directly. This should be |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4794 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4873 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4795 return !!RenderThreadImpl::current()->compositor_thread(); | 4874 return !!RenderThreadImpl::current()->compositor_thread(); |
4796 } | 4875 } |
4797 | 4876 |
4798 void RenderViewImpl::OnJavaBridgeInit() { | 4877 void RenderViewImpl::OnJavaBridgeInit() { |
4799 DCHECK(!java_bridge_dispatcher_.get()); | 4878 DCHECK(!java_bridge_dispatcher_.get()); |
4800 #if defined(ENABLE_JAVA_BRIDGE) | 4879 #if defined(ENABLE_JAVA_BRIDGE) |
4801 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 4880 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
4802 #endif | 4881 #endif |
4803 } | 4882 } |
OLD | NEW |