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

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

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/spellcheck_host_impl.h" 5 #include "chrome/browser/spellchecker/spellcheck_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 static const char kDownloadServerUrl[] = 297 static const char kDownloadServerUrl[] =
298 "http://cache.pack.google.com/edgedl/chrome/dict/"; 298 "http://cache.pack.google.com/edgedl/chrome/dict/";
299 std::string bdict_file = bdict_file_path_.BaseName().MaybeAsASCII(); 299 std::string bdict_file = bdict_file_path_.BaseName().MaybeAsASCII();
300 if (bdict_file.empty()) { 300 if (bdict_file.empty()) {
301 NOTREACHED(); 301 NOTREACHED();
302 return; 302 return;
303 } 303 }
304 GURL url = GURL(std::string(kDownloadServerUrl) + 304 GURL url = GURL(std::string(kDownloadServerUrl) +
305 StringToLowerASCII(bdict_file)); 305 StringToLowerASCII(bdict_file));
306 fetcher_.reset(new URLFetcher(url, URLFetcher::GET, this)); 306 fetcher_.reset(new URLFetcher(url, URLFetcher::GET, this));
307 fetcher_->set_request_context(request_context_getter_); 307 fetcher_->SetRequestContext(request_context_getter_);
308 tried_to_download_ = true; 308 tried_to_download_ = true;
309 fetcher_->Start(); 309 fetcher_->Start();
310 request_context_getter_ = NULL; 310 request_context_getter_ = NULL;
311 } 311 }
312 312
313 void SpellCheckHostImpl::WriteWordToCustomDictionary(const std::string& word) { 313 void SpellCheckHostImpl::WriteWordToCustomDictionary(const std::string& word) {
314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
315 315
316 // Stored in UTF-8. 316 // Stored in UTF-8.
317 std::string word_to_add(word + "\n"); 317 std::string word_to_add(word + "\n");
318 FILE* f = file_util::OpenFile(custom_dictionary_file_, "a+"); 318 FILE* f = file_util::OpenFile(custom_dictionary_file_, "a+");
319 if (f) 319 if (f)
320 fputs(word_to_add.c_str(), f); 320 fputs(word_to_add.c_str(), f);
321 file_util::CloseFile(f); 321 file_util::CloseFile(f);
322 } 322 }
323 323
324 void SpellCheckHostImpl::OnURLFetchComplete(const URLFetcher* source) { 324 void SpellCheckHostImpl::OnURLFetchComplete(const content::URLFetcher* source) {
325 DCHECK(source); 325 DCHECK(source);
326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
327 scoped_ptr<URLFetcher> fetcher_destructor(fetcher_.release()); 327 scoped_ptr<content::URLFetcher> fetcher_destructor(fetcher_.release());
328 328
329 if ((source->response_code() / 100) != 2) { 329 if ((source->GetResponseCode() / 100) != 2) {
330 // Initialize will not try to download the file a second time. 330 // Initialize will not try to download the file a second time.
331 LOG(ERROR) << "Failure to download dictionary."; 331 LOG(ERROR) << "Failure to download dictionary.";
332 InitializeOnFileThread(); 332 InitializeOnFileThread();
333 return; 333 return;
334 } 334 }
335 335
336 // Basic sanity check on the dictionary. 336 // Basic sanity check on the dictionary.
337 // There's the small chance that we might see a 200 status code for a body 337 // There's the small chance that we might see a 200 status code for a body
338 // that represents some form of failure. 338 // that represents some form of failure.
339 std::string data; 339 std::string data;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 return file_; 431 return file_;
432 } 432 }
433 433
434 const std::string& SpellCheckHostImpl::GetLanguage() const { 434 const std::string& SpellCheckHostImpl::GetLanguage() const {
435 return language_; 435 return language_;
436 } 436 }
437 437
438 bool SpellCheckHostImpl::IsUsingPlatformChecker() const { 438 bool SpellCheckHostImpl::IsUsingPlatformChecker() const {
439 return use_platform_spellchecker_; 439 return use_platform_spellchecker_;
440 } 440 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_host_impl.h ('k') | chrome/browser/sync/glue/http_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698