| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/spellcheck_host.h" | 5 #include "chrome/browser/spellcheck_host.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // Stored in UTF-8. | 248 // Stored in UTF-8. |
| 249 std::string word_to_add(word + "\n"); | 249 std::string word_to_add(word + "\n"); |
| 250 FILE* f = file_util::OpenFile(custom_dictionary_file_, "a+"); | 250 FILE* f = file_util::OpenFile(custom_dictionary_file_, "a+"); |
| 251 if (f != NULL) | 251 if (f != NULL) |
| 252 fputs(word_to_add.c_str(), f); | 252 fputs(word_to_add.c_str(), f); |
| 253 file_util::CloseFile(f); | 253 file_util::CloseFile(f); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void SpellCheckHost::OnURLFetchComplete(const URLFetcher* source, | 256 void SpellCheckHost::OnURLFetchComplete(const URLFetcher* source, |
| 257 const GURL& url, | 257 const GURL& url, |
| 258 const URLRequestStatus& status, | 258 const net::URLRequestStatus& status, |
| 259 int response_code, | 259 int response_code, |
| 260 const ResponseCookies& cookies, | 260 const ResponseCookies& cookies, |
| 261 const std::string& data) { | 261 const std::string& data) { |
| 262 DCHECK(source); | 262 DCHECK(source); |
| 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 264 fetcher_.reset(); | 264 fetcher_.reset(); |
| 265 | 265 |
| 266 if ((response_code / 100) != 2) { | 266 if ((response_code / 100) != 2) { |
| 267 // Initialize will not try to download the file a second time. | 267 // Initialize will not try to download the file a second time. |
| 268 LOG(ERROR) << "Failure to download dictionary."; | 268 LOG(ERROR) << "Failure to download dictionary."; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 320 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 321 NewRunnableMethod(this, | 321 NewRunnableMethod(this, |
| 322 &SpellCheckHost::InformObserverOfInitialization)); | 322 &SpellCheckHost::InformObserverOfInitialization)); |
| 323 return; | 323 return; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 | 326 |
| 327 data_.clear(); | 327 data_.clear(); |
| 328 Initialize(); | 328 Initialize(); |
| 329 } | 329 } |
| OLD | NEW |