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

Side by Side Diff: chrome/browser/tab_contents/spelling_menu_observer.cc

Issue 10536141: Add SpellingServiceClient::IsAvailable(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/tab_contents/spelling_menu_observer.h" 5 #include "chrome/browser/tab_contents/spelling_menu_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Append Dictionary spell check suggestions. 52 // Append Dictionary spell check suggestions.
53 suggestions_ = params.dictionary_suggestions; 53 suggestions_ = params.dictionary_suggestions;
54 for (size_t i = 0; i < params.dictionary_suggestions.size() && 54 for (size_t i = 0; i < params.dictionary_suggestions.size() &&
55 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST; 55 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST;
56 ++i) { 56 ++i) {
57 proxy_->AddMenuItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), 57 proxy_->AddMenuItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i),
58 params.dictionary_suggestions[i]); 58 params.dictionary_suggestions[i]);
59 } 59 }
60 60
61 // Append a placeholder item for the suggestion from the Spelling serivce and 61 // Append a placeholder item for the suggestion from the Spelling serivce and
62 // send a request to the service if we have enabled the spellchecking and 62 // send a request to the service if we can retrieve suggestions from it.
63 // integrated the Spelling service. 63 if (SpellingServiceClient::IsAvailable(profile,
64 PrefService* pref = profile->GetPrefs(); 64 SpellingServiceClient::SUGGEST)) {
65 if (params.spellcheck_enabled &&
66 pref->GetBoolean(prefs::kEnableSpellCheck) &&
67 pref->GetBoolean(prefs::kSpellCheckUseSpellingService)) {
68 // Retrieve the misspelled word to be sent to the Spelling service. 65 // Retrieve the misspelled word to be sent to the Spelling service.
69 string16 text = params.misspelled_word; 66 string16 text = params.misspelled_word;
70 if (!text.empty()) { 67 if (!text.empty()) {
71 // Initialize variables used in OnURLFetchComplete(). We copy the input 68 // Initialize variables used in OnURLFetchComplete(). We copy the input
72 // text to the result text so we can replace its misspelled regions with 69 // text to the result text so we can replace its misspelled regions with
73 // suggestions. 70 // suggestions.
74 loading_frame_ = 0; 71 loading_frame_ = 0;
75 succeeded_ = false; 72 succeeded_ = false;
76 result_ = text; 73 result_ = text;
77 74
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 loading_frame_ = (loading_frame_ + 1) & 3; 287 loading_frame_ = (loading_frame_ + 1) & 3;
291 string16 loading_message = loading_message_; 288 string16 loading_message = loading_message_;
292 for (int i = 0; i < loading_frame_; ++i) 289 for (int i = 0; i < loading_frame_; ++i)
293 loading_message.push_back('.'); 290 loading_message.push_back('.');
294 291
295 // Update the menu item with the text. We disable this item to prevent users 292 // Update the menu item with the text. We disable this item to prevent users
296 // from selecting it. 293 // from selecting it.
297 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 294 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
298 loading_message); 295 loading_message);
299 } 296 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698