Move WebTextCheckClient reference from WebViewImpl to WebLocalFrameImpl

This is Patch 5 of 6 for making SpellCheckProvider a RenderFrameObserver, so
that spellcheck can work in OOPIF. Full design: https://goo.gl/VfCENk

This patch moves the Blink-side reference to WebTextCheckClient from
WebViewImpl to WebLocalFrameImpl, as a preparation for changing
SpellCheckProvider from RenderViewObserver to RenderFrameObserver.

Currently, SpellCheckProvider is still view-based, and all WebLocalFrames of
the same view are holding references to the same SpellCheckProvider. Follow
up patch will change that.

For layout tests, by design there should be only one mock spell checker
instance. This patch also ensures that this instance is used by all
WebLocalFrames.

BUG=638361

Review-Url: https://codereview.chromium.org/2797073002
Cr-Commit-Position: refs/heads/master@{#462538}
diff --git a/content/shell/renderer/layout_test/layout_test_render_frame_observer.cc b/content/shell/renderer/layout_test/layout_test_render_frame_observer.cc
index 4d7acff..59518d0 100644
--- a/content/shell/renderer/layout_test/layout_test_render_frame_observer.cc
+++ b/content/shell/renderer/layout_test/layout_test_render_frame_observer.cc
@@ -21,11 +21,14 @@
 LayoutTestRenderFrameObserver::LayoutTestRenderFrameObserver(
     RenderFrame* render_frame)
     : RenderFrameObserver(render_frame), binding_(this) {
-  render_frame->GetWebFrame()->setContentSettingsClient(
+  test_runner::WebTestRunner* test_runner =
       LayoutTestRenderThreadObserver::GetInstance()
           ->test_interfaces()
-          ->TestRunner()
-          ->GetWebContentSettings());
+          ->TestRunner();
+  render_frame->GetWebFrame()->setContentSettingsClient(
+      test_runner->GetWebContentSettings());
+  render_frame->GetWebFrame()->setTextCheckClient(
+      test_runner->GetWebTextCheckClient());
   render_frame->GetAssociatedInterfaceRegistry()->AddInterface(base::Bind(
       &LayoutTestRenderFrameObserver::BindRequest, base::Unretained(this)));
 }
diff --git a/content/shell/test_runner/test_runner.cc b/content/shell/test_runner/test_runner.cc
index 5ae3f3c5..23b19b3 100644
--- a/content/shell/test_runner/test_runner.cc
+++ b/content/shell/test_runner/test_runner.cc
@@ -1893,8 +1893,11 @@
   return mock_content_settings_client_.get();
 }
 
+WebTextCheckClient* TestRunner::GetWebTextCheckClient() const {
+  return spellcheck_.get();
+}
+
 void TestRunner::InitializeWebViewWithMocks(blink::WebView* web_view) {
-  web_view->setTextCheckClient(spellcheck_.get());
   web_view->setCredentialManagerClient(credential_manager_client_.get());
 }
 
diff --git a/content/shell/test_runner/test_runner.h b/content/shell/test_runner/test_runner.h
index 0cdf5fb..62a7ea8 100644
--- a/content/shell/test_runner/test_runner.h
+++ b/content/shell/test_runner/test_runner.h
@@ -100,6 +100,7 @@
   bool HasCustomTextDump(std::string* custom_text_dump) const override;
   bool ShouldDumpBackForwardList() const override;
   blink::WebContentSettingsClient* GetWebContentSettings() const override;
+  blink::WebTextCheckClient* GetWebTextCheckClient() const override;
   void InitializeWebViewWithMocks(blink::WebView* web_view) override;
   void SetFocus(blink::WebView* web_view, bool focus) override;
 
diff --git a/content/shell/test_runner/web_test_runner.h b/content/shell/test_runner/web_test_runner.h
index 3deb890..5dd449c4 100644
--- a/content/shell/test_runner/web_test_runner.h
+++ b/content/shell/test_runner/web_test_runner.h
@@ -19,6 +19,7 @@
 namespace blink {
 class WebContentSettingsClient;
 class WebLocalFrame;
+class WebTextCheckClient;
 class WebView;
 }
 
@@ -30,6 +31,10 @@
   // embedder should use this for all WebViews it creates.
   virtual blink::WebContentSettingsClient* GetWebContentSettings() const = 0;
 
+  // Returns a mock WebTextCheckClient that is used for layout tests. An
+  // embedder should use this for all WebLocalFrames it creates.
+  virtual blink::WebTextCheckClient* GetWebTextCheckClient() const = 0;
+
   // After WebTestDelegate::TestFinished was invoked, the following methods
   // can be used to determine what kind of dump the main WebViewTestProxy can
   // provide.