| 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 "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/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 std::string request = base::StringPrintf(kSpellingRequest, | 87 std::string request = base::StringPrintf(kSpellingRequest, |
| 88 encoded_text.c_str(), | 88 encoded_text.c_str(), |
| 89 language, country); | 89 language, country); |
| 90 | 90 |
| 91 static const char kSpellingServiceURL[] = SPELLING_SERVICE_URL; | 91 static const char kSpellingServiceURL[] = SPELLING_SERVICE_URL; |
| 92 GURL url = GURL(kSpellingServiceURL); | 92 GURL url = GURL(kSpellingServiceURL); |
| 93 fetcher_.reset(content::URLFetcher::Create( | 93 fetcher_.reset(content::URLFetcher::Create( |
| 94 url, content::URLFetcher::POST, this)); | 94 url, content::URLFetcher::POST, this)); |
| 95 fetcher_->SetRequestContext(context); | 95 fetcher_->SetRequestContext(context); |
| 96 fetcher_->SetUploadData("application/json", request); | 96 fetcher_->SetUploadData("application/json", request); |
| 97 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 97 fetcher_->SetLoadFlags( |
| 98 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
| 98 fetcher_->Start(); | 99 fetcher_->Start(); |
| 99 tag_ = tag; | 100 tag_ = tag; |
| 100 callback_ = callback; | 101 callback_ = callback; |
| 101 return true; | 102 return true; |
| 102 } | 103 } |
| 103 | 104 |
| 104 void SpellingServiceClient::OnURLFetchComplete( | 105 void SpellingServiceClient::OnURLFetchComplete( |
| 105 const content::URLFetcher* source) { | 106 const content::URLFetcher* source) { |
| 106 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 107 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 107 scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release()); | 108 scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 if (!suggestions->GetDictionary(0, &suggestion) || | 184 if (!suggestions->GetDictionary(0, &suggestion) || |
| 184 !suggestion->GetString("suggestion", &replacement)) { | 185 !suggestion->GetString("suggestion", &replacement)) { |
| 185 return false; | 186 return false; |
| 186 } | 187 } |
| 187 SpellCheckResult result( | 188 SpellCheckResult result( |
| 188 SpellCheckResult::SPELLING, start, length, replacement); | 189 SpellCheckResult::SPELLING, start, length, replacement); |
| 189 results->push_back(result); | 190 results->push_back(result); |
| 190 } | 191 } |
| 191 return true; | 192 return true; |
| 192 } | 193 } |
| OLD | NEW |