| 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #include "net/url_request/url_request_context.h" | 89 #include "net/url_request/url_request_context.h" |
| 90 #include "net/url_request/url_request_context_getter.h" | 90 #include "net/url_request/url_request_context_getter.h" |
| 91 #include "ui/base/layout.h" | 91 #include "ui/base/layout.h" |
| 92 #include "ui/gfx/display.h" | 92 #include "ui/gfx/display.h" |
| 93 #include "ui/gfx/screen.h" | 93 #include "ui/gfx/screen.h" |
| 94 #include "ui/gl/gl_switches.h" | 94 #include "ui/gl/gl_switches.h" |
| 95 #include "webkit/common/webpreferences.h" | 95 #include "webkit/common/webpreferences.h" |
| 96 | 96 |
| 97 #if defined(OS_ANDROID) | 97 #if defined(OS_ANDROID) |
| 98 #include "content/browser/android/date_time_chooser_android.h" | 98 #include "content/browser/android/date_time_chooser_android.h" |
| 99 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | |
| 100 #include "content/browser/web_contents/web_contents_android.h" | 99 #include "content/browser/web_contents/web_contents_android.h" |
| 101 #include "content/common/java_bridge_messages.h" | |
| 102 #include "content/public/browser/android/content_view_core.h" | 100 #include "content/public/browser/android/content_view_core.h" |
| 103 #endif | 101 #endif |
| 104 | 102 |
| 105 #if defined(OS_MACOSX) | 103 #if defined(OS_MACOSX) |
| 106 #include "base/mac/foundation_util.h" | 104 #include "base/mac/foundation_util.h" |
| 107 #include "ui/gl/io_surface_support_mac.h" | 105 #include "ui/gl/io_surface_support_mac.h" |
| 108 #endif | 106 #endif |
| 109 | 107 |
| 110 // Cross-Site Navigations | 108 // Cross-Site Navigations |
| 111 // | 109 // |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 RenderFrameHost* render_frame_host, | 463 RenderFrameHost* render_frame_host, |
| 466 const IPC::Message& message) { | 464 const IPC::Message& message) { |
| 467 DCHECK(render_view_host || render_frame_host); | 465 DCHECK(render_view_host || render_frame_host); |
| 468 if (GetWebUI() && | 466 if (GetWebUI() && |
| 469 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { | 467 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { |
| 470 return true; | 468 return true; |
| 471 } | 469 } |
| 472 | 470 |
| 473 ObserverListBase<WebContentsObserver>::Iterator it(observers_); | 471 ObserverListBase<WebContentsObserver>::Iterator it(observers_); |
| 474 WebContentsObserver* observer; | 472 WebContentsObserver* observer; |
| 475 while ((observer = it.GetNext()) != NULL) | 473 if (render_frame_host) { |
| 476 if (observer->OnMessageReceived(message)) | 474 while ((observer = it.GetNext()) != NULL) |
| 477 return true; | 475 if (observer->OnMessageReceived(render_frame_host, message)) |
| 476 return true; |
| 477 } else { |
| 478 while ((observer = it.GetNext()) != NULL) |
| 479 if (observer->OnMessageReceived(message)) |
| 480 return true; |
| 481 } |
| 478 | 482 |
| 479 // Message handlers should be aware of which | 483 // Message handlers should be aware of which |
| 480 // RenderViewHost/RenderFrameHost sent the message, which is temporarily | 484 // RenderViewHost/RenderFrameHost sent the message, which is temporarily |
| 481 // stored in render_(view|frame)_message_source_. | 485 // stored in render_(view|frame)_message_source_. |
| 482 if (render_frame_host) { | 486 if (render_frame_host) { |
| 483 if (RenderViewDevToolsAgentHost::DispatchIPCMessage( | 487 if (RenderViewDevToolsAgentHost::DispatchIPCMessage( |
| 484 render_frame_host->GetRenderViewHost(), message)) | 488 render_frame_host->GetRenderViewHost(), message)) |
| 485 return true; | 489 return true; |
| 486 render_frame_message_source_ = render_frame_host; | 490 render_frame_message_source_ = render_frame_host; |
| 487 } else { | 491 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 OnShowValidationMessage) | 541 OnShowValidationMessage) |
| 538 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 542 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 539 OnHideValidationMessage) | 543 OnHideValidationMessage) |
| 540 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 544 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 541 OnMoveValidationMessage) | 545 OnMoveValidationMessage) |
| 542 #if defined(OS_ANDROID) | 546 #if defined(OS_ANDROID) |
| 543 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 547 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 544 OnFindMatchRectsReply) | 548 OnFindMatchRectsReply) |
| 545 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 549 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
| 546 OnOpenDateTimeDialog) | 550 OnOpenDateTimeDialog) |
| 547 IPC_MESSAGE_HANDLER_DELAY_REPLY(JavaBridgeHostMsg_GetChannelHandle, | |
| 548 OnJavaBridgeGetChannelHandle) | |
| 549 #endif | 551 #endif |
| 550 IPC_MESSAGE_UNHANDLED(handled = false) | 552 IPC_MESSAGE_UNHANDLED(handled = false) |
| 551 IPC_END_MESSAGE_MAP_EX() | 553 IPC_END_MESSAGE_MAP_EX() |
| 552 render_view_message_source_ = NULL; | 554 render_view_message_source_ = NULL; |
| 553 render_frame_message_source_ = NULL; | 555 render_frame_message_source_ = NULL; |
| 554 | 556 |
| 555 if (!message_is_ok) { | 557 if (!message_is_ok) { |
| 556 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVD")); | 558 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVD")); |
| 557 GetRenderProcessHost()->ReceivedBadMessage(); | 559 GetRenderProcessHost()->ReceivedBadMessage(); |
| 558 } | 560 } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 view_->CreateView(initial_size, params.context); | 1101 view_->CreateView(initial_size, params.context); |
| 1100 | 1102 |
| 1101 // Listen for whether our opener gets destroyed. | 1103 // Listen for whether our opener gets destroyed. |
| 1102 if (opener_) | 1104 if (opener_) |
| 1103 AddDestructionObserver(opener_); | 1105 AddDestructionObserver(opener_); |
| 1104 | 1106 |
| 1105 registrar_.Add(this, | 1107 registrar_.Add(this, |
| 1106 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1108 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1107 NotificationService::AllBrowserContextsAndSources()); | 1109 NotificationService::AllBrowserContextsAndSources()); |
| 1108 #if defined(OS_ANDROID) | 1110 #if defined(OS_ANDROID) |
| 1109 java_bridge_dispatcher_host_manager_.reset( | |
| 1110 new JavaBridgeDispatcherHostManager(this)); | |
| 1111 date_time_chooser_.reset(new DateTimeChooserAndroid()); | 1111 date_time_chooser_.reset(new DateTimeChooserAndroid()); |
| 1112 #endif | 1112 #endif |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) { | 1115 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) { |
| 1116 RemoveDestructionObserver(web_contents); | 1116 RemoveDestructionObserver(web_contents); |
| 1117 | 1117 |
| 1118 // Clear the opener if it has been closed. | 1118 // Clear the opener if it has been closed. |
| 1119 if (web_contents == opener_) { | 1119 if (web_contents == opener_) { |
| 1120 opener_ = NULL; | 1120 opener_ = NULL; |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this), | 2647 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this), |
| 2648 GetRenderViewHost(), | 2648 GetRenderViewHost(), |
| 2649 value.dialog_type, | 2649 value.dialog_type, |
| 2650 value.dialog_value, | 2650 value.dialog_value, |
| 2651 value.minimum, | 2651 value.minimum, |
| 2652 value.maximum, | 2652 value.maximum, |
| 2653 value.step, | 2653 value.step, |
| 2654 value.suggestions); | 2654 value.suggestions); |
| 2655 } | 2655 } |
| 2656 | 2656 |
| 2657 void WebContentsImpl::OnJavaBridgeGetChannelHandle(IPC::Message* reply_msg) { | |
| 2658 java_bridge_dispatcher_host_manager_->OnGetChannelHandle( | |
| 2659 render_frame_message_source_, reply_msg); | |
| 2660 } | |
| 2661 | |
| 2662 #endif | 2657 #endif |
| 2663 | 2658 |
| 2664 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | 2659 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, |
| 2665 const base::FilePath& path, | 2660 const base::FilePath& path, |
| 2666 bool is_hung) { | 2661 bool is_hung) { |
| 2667 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | 2662 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
| 2668 | 2663 |
| 2669 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2664 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2670 PluginHungStatusChanged(plugin_child_id, path, is_hung)); | 2665 PluginHungStatusChanged(plugin_child_id, path, is_hung)); |
| 2671 } | 2666 } |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3893 | 3888 |
| 3894 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3889 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 3895 if (!delegate_) | 3890 if (!delegate_) |
| 3896 return; | 3891 return; |
| 3897 const gfx::Size new_size = GetPreferredSize(); | 3892 const gfx::Size new_size = GetPreferredSize(); |
| 3898 if (new_size != old_size) | 3893 if (new_size != old_size) |
| 3899 delegate_->UpdatePreferredSize(this, new_size); | 3894 delegate_->UpdatePreferredSize(this, new_size); |
| 3900 } | 3895 } |
| 3901 | 3896 |
| 3902 } // namespace content | 3897 } // namespace content |
| OLD | NEW |