| 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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/spellchecker/spellcheck_host.h" | 10 #include "chrome/browser/spellchecker/spellcheck_host.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // If we are already loading the spellchecker, and this is just a hint to | 38 // If we are already loading the spellchecker, and this is just a hint to |
| 39 // load the spellchecker, do nothing. | 39 // load the spellchecker, do nothing. |
| 40 if (!force && host_.get()) | 40 if (!force && host_.get()) |
| 41 return REINITIALIZE_DID_NOTHING; | 41 return REINITIALIZE_DID_NOTHING; |
| 42 | 42 |
| 43 host_ready_ = false; | 43 host_ready_ = false; |
| 44 | 44 |
| 45 bool host_deleted = false; | 45 bool host_deleted = false; |
| 46 if (host_.get()) { | 46 if (host_.get()) { |
| 47 host_->UnsetProfile(); | 47 host_->UnsetProfile(); |
| 48 host_ = NULL; | 48 host_.reset(); |
| 49 host_deleted = true; | 49 host_deleted = true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 if (enable) { | 52 if (enable) { |
| 53 // Retrieve the (perhaps updated recently) dictionary name from preferences. | 53 // Retrieve the (perhaps updated recently) dictionary name from preferences. |
| 54 host_ = CreateHost(this, language, request_context, metrics_.get()); | 54 host_.reset(CreateHost(this, language, request_context, metrics_.get())); |
| 55 return REINITIALIZE_CREATED_HOST; | 55 return REINITIALIZE_CREATED_HOST; |
| 56 } | 56 } |
| 57 | 57 |
| 58 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING; | 58 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING; |
| 59 } | 59 } |
| 60 | 60 |
| 61 SpellCheckHost* SpellCheckProfile::CreateHost( | 61 SpellCheckHost* SpellCheckProfile::CreateHost( |
| 62 SpellCheckProfileProvider* provider, | 62 SpellCheckProfileProvider* provider, |
| 63 const std::string& language, | 63 const std::string& language, |
| 64 net::URLRequestContextGetter* request_context, | 64 net::URLRequestContextGetter* request_context, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 91 return custom_words_.get() ? *custom_words_ : g_empty_list.Get(); | 91 return custom_words_.get() ? *custom_words_ : g_empty_list.Get(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SpellCheckProfile::CustomWordAddedLocally(const std::string& word) { | 94 void SpellCheckProfile::CustomWordAddedLocally(const std::string& word) { |
| 95 if (!custom_words_.get()) | 95 if (!custom_words_.get()) |
| 96 custom_words_.reset(new CustomWordList()); | 96 custom_words_.reset(new CustomWordList()); |
| 97 custom_words_->push_back(word); | 97 custom_words_->push_back(word); |
| 98 if (metrics_.get()) | 98 if (metrics_.get()) |
| 99 metrics_->RecordCustomWordCountStats(custom_words_->size()); | 99 metrics_->RecordCustomWordCountStats(custom_words_->size()); |
| 100 } | 100 } |
| OLD | NEW |