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 "chrome/browser/spellchecker/spelling_service_client.h" | 5 #include "chrome/browser/spellchecker/spelling_service_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/json/string_escape.h" | 12 #include "base/json/string_escape.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/spellcheck_common.h" | |
21 #include "chrome/common/spellcheck_result.h" | |
22 #include "components/data_use_measurement/core/data_use_user_data.h" | 20 #include "components/data_use_measurement/core/data_use_user_data.h" |
23 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/spellcheck/common/spellcheck_common.h" |
| 23 #include "components/spellcheck/common/spellcheck_result.h" |
24 #include "components/user_prefs/user_prefs.h" | 24 #include "components/user_prefs/user_prefs.h" |
25 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
26 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
27 #include "google_apis/google_api_keys.h" | 27 #include "google_apis/google_api_keys.h" |
28 #include "net/base/load_flags.h" | 28 #include "net/base/load_flags.h" |
29 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 const PrefService* pref = user_prefs::UserPrefs::Get(context); | 68 const PrefService* pref = user_prefs::UserPrefs::Get(context); |
69 DCHECK(pref); | 69 DCHECK(pref); |
70 | 70 |
71 std::string dictionary; | 71 std::string dictionary; |
72 pref->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &dictionary); | 72 pref->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &dictionary); |
73 | 73 |
74 std::string language_code; | 74 std::string language_code; |
75 std::string country_code; | 75 std::string country_code; |
76 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( | 76 spellcheck::GetISOLanguageCountryCodeFromLocale(dictionary, &language_code, |
77 dictionary, &language_code, &country_code); | 77 &country_code); |
78 | 78 |
79 // Replace typographical apostrophes with typewriter apostrophes, so that | 79 // Replace typographical apostrophes with typewriter apostrophes, so that |
80 // server word breaker behaves correctly. | 80 // server word breaker behaves correctly. |
81 const base::char16 kApostrophe = 0x27; | 81 const base::char16 kApostrophe = 0x27; |
82 const base::char16 kRightSingleQuotationMark = 0x2019; | 82 const base::char16 kRightSingleQuotationMark = 0x2019; |
83 base::string16 text_copy = text; | 83 base::string16 text_copy = text; |
84 std::replace(text_copy.begin(), text_copy.end(), kRightSingleQuotationMark, | 84 std::replace(text_copy.begin(), text_copy.end(), kRightSingleQuotationMark, |
85 kApostrophe); | 85 kApostrophe); |
86 | 86 |
87 // Format the JSON request to be sent to the Spelling service. | 87 // Format the JSON request to be sent to the Spelling service. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 // The callback may release the last (transitive) dependency on |this|. It | 274 // The callback may release the last (transitive) dependency on |this|. It |
275 // MUST be the last function called. | 275 // MUST be the last function called. |
276 callback_data->callback.Run(success, callback_data->text, results); | 276 callback_data->callback.Run(success, callback_data->text, results); |
277 } | 277 } |
278 | 278 |
279 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( | 279 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( |
280 const GURL& url) { | 280 const GURL& url) { |
281 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); | 281 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); |
282 } | 282 } |
OLD | NEW |