| 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/extensions/api/i18n/i18n_api.h" | 5 #include "chrome/browser/extensions/api/i18n/i18n_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/extensions/api/i18n.h" | 16 #include "chrome/common/extensions/api/i18n.h" |
| 17 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 | 18 |
| 20 namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages; | 19 namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages; |
| 21 | 20 |
| 22 namespace extensions { | 21 namespace extensions { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // Errors. | 25 // Errors. |
| 27 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; | 26 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 53 | 52 |
| 54 if (languages.empty()) { | 53 if (languages.empty()) { |
| 55 error_ = kEmptyAcceptLanguagesError; | 54 error_ = kEmptyAcceptLanguagesError; |
| 56 return false; | 55 return false; |
| 57 } | 56 } |
| 58 | 57 |
| 59 results_ = GetAcceptLanguages::Results::Create(languages); | 58 results_ = GetAcceptLanguages::Results::Create(languages); |
| 60 return true; | 59 return true; |
| 61 } | 60 } |
| 62 | 61 |
| 63 I18nAPI::I18nAPI(Profile* profile) { | |
| 64 (new DefaultLocaleHandler)->Register(); | |
| 65 } | |
| 66 | |
| 67 I18nAPI::~I18nAPI() { | |
| 68 } | |
| 69 | |
| 70 static base::LazyInstance<ProfileKeyedAPIFactory<I18nAPI> > | |
| 71 g_factory = LAZY_INSTANCE_INITIALIZER; | |
| 72 | |
| 73 // static | |
| 74 ProfileKeyedAPIFactory<I18nAPI>* I18nAPI::GetFactoryInstance() { | |
| 75 return &g_factory.Get(); | |
| 76 } | |
| 77 | |
| 78 } // namespace extensions | 62 } // namespace extensions |
| OLD | NEW |