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

Unified Diff: content/browser/renderer_host/text_input_client_mac.mm

Issue 2422973003: Fix TextInputClientMac related crashes of Fullscreen RenderWidget (Closed)
Patch Set: Rebased Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/text_input_client_mac.mm
diff --git a/content/browser/renderer_host/text_input_client_mac.mm b/content/browser/renderer_host/text_input_client_mac.mm
index 74f3dc2d74209d5d65a92b80757ea6086d73d724..999adaffd30d84f565318275181947b70574b61c 100644
--- a/content/browser/renderer_host/text_input_client_mac.mm
+++ b/content/browser/renderer_host/text_input_client_mac.mm
@@ -8,11 +8,33 @@
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
+#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/text_input_client_messages.h"
namespace content {
+namespace {
+
+// TODO(ekaramad): TextInputClientObserver, the renderer side of
+// TextInputClientMac for each RenderWidgetHost, expects to have a
+// WebFrameWidget to use for handling these IPCs. However, for fullscreen flash,
+// we end up with a PepperWidget. For those scenarios, do not send the IPCs. We
+// need to figure out what features are properly supported and perhaps send the
+// IPC to the parent widget of the plugin (https://crbug.com/663384).
+bool SendMessageToRenderWidget(RenderWidgetHostImpl* widget,
+ IPC::Message* message) {
+ if (!widget->delegate() ||
+ widget == widget->delegate()->GetFullscreenRenderWidgetHost()) {
+ delete message;
+ return false;
+ }
+
+ DCHECK_EQ(widget->GetRoutingID(), message->routing_id());
+ return widget->Send(message);
+}
+}
+
// The amount of time in milliseconds that the browser process will wait for a
// response from the renderer.
// TODO(rsesek): Using the histogram data, find the best upper-bound for this
@@ -44,7 +66,8 @@ void TextInputClientMac::GetStringAtPoint(
DCHECK(replyForPointHandler_.get() == nil);
replyForPointHandler_.reset(reply_handler, base::scoped_policy::RETAIN);
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
- rwhi->Send(new TextInputClientMsg_StringAtPoint(rwhi->GetRoutingID(), point));
+ SendMessageToRenderWidget(
+ rwhi, new TextInputClientMsg_StringAtPoint(rwhi->GetRoutingID(), point));
}
void TextInputClientMac::GetStringAtPointReply(NSAttributedString* string,
@@ -62,8 +85,8 @@ void TextInputClientMac::GetStringFromRange(
DCHECK(replyForRangeHandler_.get() == nil);
replyForRangeHandler_.reset(reply_handler, base::scoped_policy::RETAIN);
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
- rwhi->Send(new TextInputClientMsg_StringForRange(rwhi->GetRoutingID(),
- gfx::Range(range)));
+ SendMessageToRenderWidget(rwhi, new TextInputClientMsg_StringForRange(
+ rwhi->GetRoutingID(), gfx::Range(range)));
}
void TextInputClientMac::GetStringFromRangeReply(NSAttributedString* string,
@@ -80,8 +103,11 @@ NSUInteger TextInputClientMac::GetCharacterIndexAtPoint(RenderWidgetHost* rwh,
BeforeRequest();
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
- rwhi->Send(new TextInputClientMsg_CharacterIndexForPoint(rwhi->GetRoutingID(),
- point));
+ if (!SendMessageToRenderWidget(rwhi,
+ new TextInputClientMsg_CharacterIndexForPoint(
+ rwhi->GetRoutingID(), point)))
+ return NSNotFound;
+
// http://crbug.com/121917
base::ThreadRestrictions::ScopedAllowWait allow_wait;
condition_.TimedWait(base::TimeDelta::FromMilliseconds(kWaitTimeout));
@@ -100,9 +126,11 @@ NSRect TextInputClientMac::GetFirstRectForRange(RenderWidgetHost* rwh,
BeforeRequest();
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
- rwhi->Send(
- new TextInputClientMsg_FirstRectForCharacterRange(rwhi->GetRoutingID(),
- gfx::Range(range)));
+ if (!SendMessageToRenderWidget(
+ rwhi, new TextInputClientMsg_FirstRectForCharacterRange(
+ rwhi->GetRoutingID(), gfx::Range(range))))
+ return NSRect();
+
// http://crbug.com/121917
base::ThreadRestrictions::ScopedAllowWait allow_wait;
condition_.TimedWait(base::TimeDelta::FromMilliseconds(kWaitTimeout));
« no previous file with comments | « content/browser/renderer_host/render_widget_host_delegate.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698