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/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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 21 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
22 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 22 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/spellcheck_common.h" | 26 #include "chrome/common/spellcheck_common.h" |
27 #include "chrome/common/spellcheck_messages.h" | 27 #include "chrome/common/spellcheck_messages.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
30 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/common/url_fetcher.h" | |
32 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
33 #include "net/base/load_flags.h" | 32 #include "net/base/load_flags.h" |
| 33 #include "net/url_request/url_fetcher.h" |
34 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
35 #include "third_party/hunspell/google/bdict.h" | 35 #include "third_party/hunspell/google/bdict.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 | 37 |
38 using content::BrowserThread; | 38 using content::BrowserThread; |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 FilePath GetFirstChoiceFilePath(const std::string& language) { | 42 FilePath GetFirstChoiceFilePath(const std::string& language) { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // Determine URL of file to download. | 276 // Determine URL of file to download. |
277 static const char kDownloadServerUrl[] = | 277 static const char kDownloadServerUrl[] = |
278 "http://cache.pack.google.com/edgedl/chrome/dict/"; | 278 "http://cache.pack.google.com/edgedl/chrome/dict/"; |
279 std::string bdict_file = bdict_file_path_.BaseName().MaybeAsASCII(); | 279 std::string bdict_file = bdict_file_path_.BaseName().MaybeAsASCII(); |
280 if (bdict_file.empty()) { | 280 if (bdict_file.empty()) { |
281 NOTREACHED(); | 281 NOTREACHED(); |
282 return; | 282 return; |
283 } | 283 } |
284 GURL url = GURL(std::string(kDownloadServerUrl) + | 284 GURL url = GURL(std::string(kDownloadServerUrl) + |
285 StringToLowerASCII(bdict_file)); | 285 StringToLowerASCII(bdict_file)); |
286 fetcher_.reset(content::URLFetcher::Create(url, net::URLFetcher::GET, | 286 fetcher_.reset(net::URLFetcher::Create(url, net::URLFetcher::GET, |
287 weak_ptr_factory_.GetWeakPtr())); | 287 weak_ptr_factory_.GetWeakPtr())); |
288 fetcher_->SetRequestContext(request_context_getter_); | 288 fetcher_->SetRequestContext(request_context_getter_); |
289 fetcher_->SetLoadFlags( | 289 fetcher_->SetLoadFlags( |
290 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); | 290 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
291 tried_to_download_ = true; | 291 tried_to_download_ = true; |
292 fetcher_->Start(); | 292 fetcher_->Start(); |
293 request_context_getter_ = NULL; | 293 request_context_getter_ = NULL; |
294 } | 294 } |
295 | 295 |
296 void SpellCheckHostImpl::LoadCustomDictionary(CustomWordList* custom_words) { | 296 void SpellCheckHostImpl::LoadCustomDictionary(CustomWordList* custom_words) { |
297 if (!custom_words) | 297 if (!custom_words) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { | 452 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { |
453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
454 | 454 |
455 for (content::RenderProcessHost::iterator i( | 455 for (content::RenderProcessHost::iterator i( |
456 content::RenderProcessHost::AllHostsIterator()); | 456 content::RenderProcessHost::AllHostsIterator()); |
457 !i.IsAtEnd(); i.Advance()) { | 457 !i.IsAtEnd(); i.Advance()) { |
458 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); | 458 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); |
459 } | 459 } |
460 } | 460 } |
OLD | NEW |