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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 1156473007: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed some bugs and handled the spelling service. Created 5 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
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/spellchecker/spelling_service_client.h" 5 #include "chrome/browser/spellchecker/spelling_service_client.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/string_escape.h" 8 #include "base/json/string_escape.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text); 98 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text);
99 fetcher->Start(); 99 fetcher->Start();
100 return true; 100 return true;
101 } 101 }
102 102
103 bool SpellingServiceClient::IsAvailable( 103 bool SpellingServiceClient::IsAvailable(
104 content::BrowserContext* context, 104 content::BrowserContext* context,
105 ServiceType type) { 105 ServiceType type) {
106 const PrefService* pref = user_prefs::UserPrefs::Get(context); 106 const PrefService* pref = user_prefs::UserPrefs::Get(context);
107 DCHECK(pref); 107 DCHECK(pref);
108 // If prefs don't allow spellchecking or if the context is off the record, 108 // If prefs don't allow spellchecking, if the context is off the record, or if
109 // the spelling service should be unavailable. 109 // multilingual spellchecking is enabled the spelling service should be
110 // unavailable.
110 if (!pref->GetBoolean(prefs::kEnableContinuousSpellcheck) || 111 if (!pref->GetBoolean(prefs::kEnableContinuousSpellcheck) ||
111 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService) || 112 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService) ||
112 context->IsOffTheRecord()) 113 context->IsOffTheRecord() ||
114 chrome::spellcheck_common::IsMultilingualSpellcheckEnabled())
113 return false; 115 return false;
114 116
115 // If the locale for spelling has not been set, the user has not decided to 117 // If the locale for spelling has not been set, the user has not decided to
116 // use spellcheck so we don't do anything remote (suggest or spelling). 118 // use spellcheck so we don't do anything remote (suggest or spelling).
117 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); 119 std::string locale = pref->GetString(prefs::kSpellCheckDictionary);
118 if (locale.empty()) 120 if (locale.empty())
119 return false; 121 return false;
120 122
121 // Finally, if all options are available, we only enable only SUGGEST 123 // Finally, if all options are available, we only enable only SUGGEST
122 // if SPELLCHECK is not available for our language because SPELLCHECK results 124 // if SPELLCHECK is not available for our language because SPELLCHECK results
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 252
251 // The callback may release the last (transitive) dependency on |this|. It 253 // The callback may release the last (transitive) dependency on |this|. It
252 // MUST be the last function called. 254 // MUST be the last function called.
253 callback_data->callback.Run(success, callback_data->text, results); 255 callback_data->callback.Run(success, callback_data->text, results);
254 } 256 }
255 257
256 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( 258 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher(
257 const GURL& url) { 259 const GURL& url) {
258 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); 260 return net::URLFetcher::Create(url, net::URLFetcher::POST, this);
259 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698