| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 5 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 24 #include "components/spellcheck/browser/feedback_sender.h" | 24 #include "components/spellcheck/browser/feedback_sender.h" |
| 25 #include "components/spellcheck/browser/pref_names.h" | 25 #include "components/spellcheck/browser/pref_names.h" |
| 26 #include "components/spellcheck/browser/spellcheck_host_metrics.h" | 26 #include "components/spellcheck/browser/spellcheck_host_metrics.h" |
| 27 #include "components/spellcheck/browser/spellcheck_platform.h" | 27 #include "components/spellcheck/browser/spellcheck_platform.h" |
| 28 #include "components/spellcheck/browser/spelling_service_client.h" | 28 #include "components/spellcheck/browser/spelling_service_client.h" |
| 29 #include "components/spellcheck/common/spellcheck_common.h" | 29 #include "components/spellcheck/common/spellcheck_common.h" |
| 30 #include "components/spellcheck/common/spellcheck_result.h" | 30 #include "components/spellcheck/common/spellcheck_result.h" |
| 31 #include "components/spellcheck/spellcheck_build_features.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/render_widget_host.h" | 33 #include "content/public/browser/render_widget_host.h" |
| 33 #include "content/public/browser/render_widget_host_view.h" | 34 #include "content/public/browser/render_widget_host_view.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/common/context_menu_params.h" | 36 #include "content/public/common/context_menu_params.h" |
| 36 #include "extensions/browser/view_type_utils.h" | 37 #include "extensions/browser/view_type_utils.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 38 #include "ui/gfx/geometry/rect.h" | 39 #include "ui/gfx/geometry/rect.h" |
| 39 | 40 |
| 40 using content::BrowserThread; | 41 using content::BrowserThread; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 content::BrowserContext* browser_context = proxy_->GetBrowserContext(); | 265 content::BrowserContext* browser_context = proxy_->GetBrowserContext(); |
| 265 if (browser_context) { | 266 if (browser_context) { |
| 266 SpellcheckService* spellcheck = | 267 SpellcheckService* spellcheck = |
| 267 SpellcheckServiceFactory::GetForContext(browser_context); | 268 SpellcheckServiceFactory::GetForContext(browser_context); |
| 268 if (spellcheck) { | 269 if (spellcheck) { |
| 269 spellcheck->GetCustomDictionary()->AddWord(base::UTF16ToUTF8( | 270 spellcheck->GetCustomDictionary()->AddWord(base::UTF16ToUTF8( |
| 270 misspelled_word_)); | 271 misspelled_word_)); |
| 271 spellcheck->GetFeedbackSender()->AddedToDictionary(misspelling_hash_); | 272 spellcheck->GetFeedbackSender()->AddedToDictionary(misspelling_hash_); |
| 272 } | 273 } |
| 273 } | 274 } |
| 274 #if defined(USE_BROWSER_SPELLCHECKER) | 275 #if BUILDFLAG(USE_BROWSER_SPELLCHECKER) |
| 275 spellcheck_platform::AddWord(misspelled_word_); | 276 spellcheck_platform::AddWord(misspelled_word_); |
| 276 #endif | 277 #endif |
| 277 } | 278 } |
| 278 | 279 |
| 279 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); | 280 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); |
| 280 | 281 |
| 281 // The spelling service can be toggled by the user only if it is not managed. | 282 // The spelling service can be toggled by the user only if it is not managed. |
| 282 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && | 283 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && |
| 283 integrate_spelling_service_.IsUserModifiable()) { | 284 integrate_spelling_service_.IsUserModifiable()) { |
| 284 // When a user enables the "Ask Google for spelling suggestions" item, we | 285 // When a user enables the "Ask Google for spelling suggestions" item, we |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // Append '.' characters to the end of "Checking". | 361 // Append '.' characters to the end of "Checking". |
| 361 loading_frame_ = (loading_frame_ + 1) & 3; | 362 loading_frame_ = (loading_frame_ + 1) & 3; |
| 362 base::string16 loading_message = | 363 base::string16 loading_message = |
| 363 loading_message_ + base::string16(loading_frame_,'.'); | 364 loading_message_ + base::string16(loading_frame_,'.'); |
| 364 | 365 |
| 365 // Update the menu item with the text. We disable this item to prevent users | 366 // Update the menu item with the text. We disable this item to prevent users |
| 366 // from selecting it. | 367 // from selecting it. |
| 367 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 368 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
| 368 loading_message); | 369 loading_message); |
| 369 } | 370 } |
| OLD | NEW |