| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_i18n_api.h" | 5 #include "chrome/browser/extensions/extension_i18n_api.h" |
| 6 | 6 |
| 7 #include "base/string_piece.h" | 7 #include "base/string_piece.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 | 12 |
| 13 // Errors. | 13 // Errors. |
| 14 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; | 14 static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; |
| 15 | 15 |
| 16 bool GetAcceptLanguagesFunction::RunImpl() { | 16 bool GetAcceptLanguagesFunction::RunImpl() { |
| 17 string16 acceptLanguages = | 17 string16 acceptLanguages = |
| 18 UTF8ToUTF16(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 18 UTF8ToUTF16(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 19 // Currently, there are 2 ways to set browser's accept-languages: through UI | 19 // Currently, there are 2 ways to set browser's accept-languages: through UI |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 // ending with ','. | 46 // ending with ','. |
| 47 if (end == string16::npos || begin >= acceptLanguages.length()) | 47 if (end == string16::npos || begin >= acceptLanguages.length()) |
| 48 break; | 48 break; |
| 49 } | 49 } |
| 50 if (static_cast<ListValue*>(result_.get())->GetSize() == 0) { | 50 if (static_cast<ListValue*>(result_.get())->GetSize() == 0) { |
| 51 error_ = kEmptyAcceptLanguagesError; | 51 error_ = kEmptyAcceptLanguagesError; |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| OLD | NEW |