| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/browser/translate_prefs.h" | 5 #include "components/translate/core/browser/translate_prefs.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 base::Time now = base::Time::Now(); | 271 base::Time now = base::Time::Now(); |
| 272 prefs_->SetDouble(kPrefTranslateLastDeniedTime, now.ToJsTime()); | 272 prefs_->SetDouble(kPrefTranslateLastDeniedTime, now.ToJsTime()); |
| 273 if (now - last_closed_time <= base::TimeDelta::FromDays(1)) | 273 if (now - last_closed_time <= base::TimeDelta::FromDays(1)) |
| 274 prefs_->SetBoolean(kPrefTranslateTooOftenDenied, true); | 274 prefs_->SetBoolean(kPrefTranslateTooOftenDenied, true); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool TranslatePrefs::IsTooOftenDenied() const { | 277 bool TranslatePrefs::IsTooOftenDenied() const { |
| 278 return prefs_->GetBoolean(kPrefTranslateTooOftenDenied); | 278 return prefs_->GetBoolean(kPrefTranslateTooOftenDenied); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void TranslatePrefs::ResetDenialState() { |
| 282 prefs_->SetDouble(kPrefTranslateLastDeniedTime, 0); |
| 283 prefs_->SetBoolean(kPrefTranslateTooOftenDenied, false); |
| 284 } |
| 285 |
| 281 void TranslatePrefs::GetLanguageList(std::vector<std::string>* languages) { | 286 void TranslatePrefs::GetLanguageList(std::vector<std::string>* languages) { |
| 282 DCHECK(languages); | 287 DCHECK(languages); |
| 283 DCHECK(languages->empty()); | 288 DCHECK(languages->empty()); |
| 284 | 289 |
| 285 #if defined(OS_CHROMEOS) | 290 #if defined(OS_CHROMEOS) |
| 286 const char* key = preferred_languages_pref_.c_str(); | 291 const char* key = preferred_languages_pref_.c_str(); |
| 287 #else | 292 #else |
| 288 const char* key = accept_languages_pref_.c_str(); | 293 const char* key = accept_languages_pref_.c_str(); |
| 289 #endif | 294 #endif |
| 290 | 295 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 565 |
| 561 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { | 566 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { |
| 562 const base::ListValue* blacklist = prefs_->GetList(pref_id); | 567 const base::ListValue* blacklist = prefs_->GetList(pref_id); |
| 563 return (blacklist == NULL || blacklist->empty()); | 568 return (blacklist == NULL || blacklist->empty()); |
| 564 } | 569 } |
| 565 | 570 |
| 566 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { | 571 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { |
| 567 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id); | 572 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id); |
| 568 return (dict == NULL || dict->empty()); | 573 return (dict == NULL || dict->empty()); |
| 569 } | 574 } |
| OLD | NEW |