| OLD | NEW |
| 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_profile.h" | 5 #include "chrome/browser/spellchecker/spellcheck_profile.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // If we are already loading the spellchecker, and this is just a hint to | 43 // If we are already loading the spellchecker, and this is just a hint to |
| 44 // load the spellchecker, do nothing. | 44 // load the spellchecker, do nothing. |
| 45 if (!force && host_.get()) | 45 if (!force && host_.get()) |
| 46 return REINITIALIZE_DID_NOTHING; | 46 return REINITIALIZE_DID_NOTHING; |
| 47 | 47 |
| 48 host_ready_ = false; | 48 host_ready_ = false; |
| 49 | 49 |
| 50 bool host_deleted = false; | 50 bool host_deleted = false; |
| 51 if (host_.get()) { | 51 if (host_.get()) { |
| 52 host_->UnsetProfile(); | 52 host_->UnsetProfile(); |
| 53 host_ = NULL; | 53 host_.reset(); |
| 54 host_deleted = true; | 54 host_deleted = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 if (enable) { | 57 if (enable) { |
| 58 // Retrieve the (perhaps updated recently) dictionary name from preferences. | 58 // Retrieve the (perhaps updated recently) dictionary name from preferences. |
| 59 host_ = CreateHost(this, language, request_context, metrics_.get()); | 59 host_.reset(CreateHost(this, language, request_context, metrics_.get())); |
| 60 return REINITIALIZE_CREATED_HOST; | 60 return REINITIALIZE_CREATED_HOST; |
| 61 } | 61 } |
| 62 | 62 |
| 63 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING; | 63 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING; |
| 64 } | 64 } |
| 65 | 65 |
| 66 SpellCheckHost* SpellCheckProfile::CreateHost( | 66 SpellCheckHost* SpellCheckProfile::CreateHost( |
| 67 SpellCheckProfileProvider* provider, | 67 SpellCheckProfileProvider* provider, |
| 68 const std::string& language, | 68 const std::string& language, |
| 69 net::URLRequestContextGetter* request_context, | 69 net::URLRequestContextGetter* request_context, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 const FilePath& SpellCheckProfile::GetCustomDictionaryPath() { | 140 const FilePath& SpellCheckProfile::GetCustomDictionaryPath() { |
| 141 if (!custom_dictionary_path_.get()) { | 141 if (!custom_dictionary_path_.get()) { |
| 142 custom_dictionary_path_.reset( | 142 custom_dictionary_path_.reset( |
| 143 new FilePath(profile_dir_.Append(chrome::kCustomDictionaryFileName))); | 143 new FilePath(profile_dir_.Append(chrome::kCustomDictionaryFileName))); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return *custom_dictionary_path_; | 146 return *custom_dictionary_path_; |
| 147 } | 147 } |
| OLD | NEW |