| 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 "components/spellcheck/renderer/spellcheck_provider.h" | 5 #include "components/spellcheck/renderer/spellcheck_provider.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "components/spellcheck/common/spellcheck_messages.h" | 8 #include "components/spellcheck/common/spellcheck_messages.h" |
| 9 #include "components/spellcheck/common/spellcheck_result.h" | 9 #include "components/spellcheck/common/spellcheck_result.h" |
| 10 #include "components/spellcheck/renderer/spellcheck.h" | 10 #include "components/spellcheck/renderer/spellcheck.h" |
| 11 #include "components/spellcheck/renderer/spellcheck_language.h" | 11 #include "components/spellcheck/renderer/spellcheck_language.h" |
| 12 #include "components/spellcheck/spellcheck_build_features.h" | 12 #include "components/spellcheck/spellcheck_build_features.h" |
| 13 #include "content/public/renderer/render_frame.h" |
| 13 #include "content/public/renderer/render_view.h" | 14 #include "content/public/renderer/render_view.h" |
| 14 #include "third_party/WebKit/public/platform/WebVector.h" | 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 15 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
| 16 #include "third_party/WebKit/public/web/WebElement.h" | 17 #include "third_party/WebKit/public/web/WebElement.h" |
| 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 18 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 19 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
| 19 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 20 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 20 #include "third_party/WebKit/public/web/WebTextDecorationType.h" | 21 #include "third_party/WebKit/public/web/WebTextDecorationType.h" |
| 21 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
| 22 | 23 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 int(SpellCheckResult::GRAMMAR), "mismatching enums"); | 35 int(SpellCheckResult::GRAMMAR), "mismatching enums"); |
| 35 | 36 |
| 36 SpellCheckProvider::SpellCheckProvider( | 37 SpellCheckProvider::SpellCheckProvider( |
| 37 content::RenderView* render_view, | 38 content::RenderView* render_view, |
| 38 SpellCheck* spellcheck) | 39 SpellCheck* spellcheck) |
| 39 : content::RenderViewObserver(render_view), | 40 : content::RenderViewObserver(render_view), |
| 40 content::RenderViewObserverTracker<SpellCheckProvider>(render_view), | 41 content::RenderViewObserverTracker<SpellCheckProvider>(render_view), |
| 41 spellcheck_(spellcheck) { | 42 spellcheck_(spellcheck) { |
| 42 DCHECK(spellcheck_); | 43 DCHECK(spellcheck_); |
| 43 if (render_view) { // NULL in unit tests. | 44 if (render_view) { // NULL in unit tests. |
| 44 render_view->GetWebView()->setTextCheckClient(this); | 45 // For a main frame of a view, RenderFrameCreated is called earlier than |
| 46 // RenderViewCreated. This workaround ensures that WebTextCheckClient is |
| 47 // still set for any main frame. |
| 48 // TODO(xiaocheng): Remove this workaround once SpellCheckProvider becomes |
| 49 // a RenderFrameObserver. |
| 50 if (content::RenderFrame* main_frame = render_view->GetMainRenderFrame()) |
| 51 main_frame->GetWebFrame()->setTextCheckClient(this); |
| 45 EnableSpellcheck(spellcheck_->IsSpellcheckEnabled()); | 52 EnableSpellcheck(spellcheck_->IsSpellcheckEnabled()); |
| 46 } | 53 } |
| 47 } | 54 } |
| 48 | 55 |
| 49 SpellCheckProvider::~SpellCheckProvider() { | 56 SpellCheckProvider::~SpellCheckProvider() { |
| 50 } | 57 } |
| 51 | 58 |
| 52 void SpellCheckProvider::RequestTextChecking( | 59 void SpellCheckProvider::RequestTextChecking( |
| 53 const base::string16& text, | 60 const base::string16& text, |
| 54 WebTextCheckingCompletion* completion) { | 61 WebTextCheckingCompletion* completion) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 completion->didFinishCheckingText(results); | 284 completion->didFinishCheckingText(results); |
| 278 return true; | 285 return true; |
| 279 } | 286 } |
| 280 | 287 |
| 281 return false; | 288 return false; |
| 282 } | 289 } |
| 283 | 290 |
| 284 void SpellCheckProvider::OnDestruct() { | 291 void SpellCheckProvider::OnDestruct() { |
| 285 delete this; | 292 delete this; |
| 286 } | 293 } |
| OLD | NEW |