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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 253013002: Pass RenderFrameHost to WebContentObservers' message handlers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in RenderHostTracker Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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
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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 RenderFrameHost* render_frame_host, 472 RenderFrameHost* render_frame_host,
475 const IPC::Message& message) { 473 const IPC::Message& message) {
476 DCHECK(render_view_host || render_frame_host); 474 DCHECK(render_view_host || render_frame_host);
477 if (GetWebUI() && 475 if (GetWebUI() &&
478 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { 476 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) {
479 return true; 477 return true;
480 } 478 }
481 479
482 ObserverListBase<WebContentsObserver>::Iterator it(observers_); 480 ObserverListBase<WebContentsObserver>::Iterator it(observers_);
483 WebContentsObserver* observer; 481 WebContentsObserver* observer;
484 while ((observer = it.GetNext()) != NULL) 482 if (render_frame_host) {
485 if (observer->OnMessageReceived(message)) 483 while ((observer = it.GetNext()) != NULL)
486 return true; 484 if (observer->OnMessageReceived(message, render_frame_host))
485 return true;
486 } else {
487 while ((observer = it.GetNext()) != NULL)
488 if (observer->OnMessageReceived(message))
489 return true;
490 }
487 491
488 // Message handlers should be aware of which 492 // Message handlers should be aware of which
489 // RenderViewHost/RenderFrameHost sent the message, which is temporarily 493 // RenderViewHost/RenderFrameHost sent the message, which is temporarily
490 // stored in render_(view|frame)_message_source_. 494 // stored in render_(view|frame)_message_source_.
491 if (render_frame_host) { 495 if (render_frame_host) {
492 if (RenderViewDevToolsAgentHost::DispatchIPCMessage( 496 if (RenderViewDevToolsAgentHost::DispatchIPCMessage(
493 render_frame_host->GetRenderViewHost(), message)) 497 render_frame_host->GetRenderViewHost(), message))
494 return true; 498 return true;
495 render_frame_message_source_ = render_frame_host; 499 render_frame_message_source_ = render_frame_host;
496 } else { 500 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 OnShowValidationMessage) 550 OnShowValidationMessage)
547 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, 551 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage,
548 OnHideValidationMessage) 552 OnHideValidationMessage)
549 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, 553 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage,
550 OnMoveValidationMessage) 554 OnMoveValidationMessage)
551 #if defined(OS_ANDROID) 555 #if defined(OS_ANDROID)
552 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, 556 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply,
553 OnFindMatchRectsReply) 557 OnFindMatchRectsReply)
554 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, 558 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog,
555 OnOpenDateTimeDialog) 559 OnOpenDateTimeDialog)
556 IPC_MESSAGE_HANDLER_DELAY_REPLY(JavaBridgeHostMsg_GetChannelHandle,
557 OnJavaBridgeGetChannelHandle)
558 #endif 560 #endif
559 IPC_MESSAGE_UNHANDLED(handled = false) 561 IPC_MESSAGE_UNHANDLED(handled = false)
560 IPC_END_MESSAGE_MAP_EX() 562 IPC_END_MESSAGE_MAP_EX()
561 render_view_message_source_ = NULL; 563 render_view_message_source_ = NULL;
562 render_frame_message_source_ = NULL; 564 render_frame_message_source_ = NULL;
563 565
564 if (!message_is_ok) { 566 if (!message_is_ok) {
565 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVD")); 567 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVD"));
566 GetRenderProcessHost()->ReceivedBadMessage(); 568 GetRenderProcessHost()->ReceivedBadMessage();
567 } 569 }
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 view_->CreateView(initial_size, params.context); 1110 view_->CreateView(initial_size, params.context);
1109 1111
1110 // Listen for whether our opener gets destroyed. 1112 // Listen for whether our opener gets destroyed.
1111 if (opener_) 1113 if (opener_)
1112 AddDestructionObserver(opener_); 1114 AddDestructionObserver(opener_);
1113 1115
1114 registrar_.Add(this, 1116 registrar_.Add(this,
1115 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 1117 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
1116 NotificationService::AllBrowserContextsAndSources()); 1118 NotificationService::AllBrowserContextsAndSources());
1117 #if defined(OS_ANDROID) 1119 #if defined(OS_ANDROID)
1118 java_bridge_dispatcher_host_manager_.reset(
1119 new JavaBridgeDispatcherHostManager(this));
1120 date_time_chooser_.reset(new DateTimeChooserAndroid()); 1120 date_time_chooser_.reset(new DateTimeChooserAndroid());
1121 #endif 1121 #endif
1122 } 1122 }
1123 1123
1124 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) { 1124 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) {
1125 RemoveDestructionObserver(web_contents); 1125 RemoveDestructionObserver(web_contents);
1126 1126
1127 // Clear the opener if it has been closed. 1127 // Clear the opener if it has been closed.
1128 if (web_contents == opener_) { 1128 if (web_contents == opener_) {
1129 opener_ = NULL; 1129 opener_ = NULL;
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this), 2660 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this),
2661 GetRenderViewHost(), 2661 GetRenderViewHost(),
2662 value.dialog_type, 2662 value.dialog_type,
2663 value.dialog_value, 2663 value.dialog_value,
2664 value.minimum, 2664 value.minimum,
2665 value.maximum, 2665 value.maximum,
2666 value.step, 2666 value.step,
2667 value.suggestions); 2667 value.suggestions);
2668 } 2668 }
2669 2669
2670 void WebContentsImpl::OnJavaBridgeGetChannelHandle(IPC::Message* reply_msg) {
2671 java_bridge_dispatcher_host_manager_->OnGetChannelHandle(
2672 render_frame_message_source_, reply_msg);
2673 }
2674
2675 #endif 2670 #endif
2676 2671
2677 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, 2672 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id,
2678 const base::FilePath& path, 2673 const base::FilePath& path,
2679 bool is_hung) { 2674 bool is_hung) {
2680 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); 2675 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1);
2681 2676
2682 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2677 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2683 PluginHungStatusChanged(plugin_child_id, path, is_hung)); 2678 PluginHungStatusChanged(plugin_child_id, path, is_hung));
2684 } 2679 }
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3924 3919
3925 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3920 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3926 if (!delegate_) 3921 if (!delegate_)
3927 return; 3922 return;
3928 const gfx::Size new_size = GetPreferredSize(); 3923 const gfx::Size new_size = GetPreferredSize();
3929 if (new_size != old_size) 3924 if (new_size != old_size)
3930 delegate_->UpdatePreferredSize(this, new_size); 3925 delegate_->UpdatePreferredSize(this, new_size);
3931 } 3926 }
3932 3927
3933 } // namespace content 3928 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698