| 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/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 size_t begin = 0; | 34 size_t begin = 0; |
| 35 size_t end; | 35 size_t end; |
| 36 while (1) { | 36 while (1) { |
| 37 end = acceptLanguages.find(',', begin); | 37 end = acceptLanguages.find(',', begin); |
| 38 if (end > begin) { | 38 if (end > begin) { |
| 39 // Guard against a malformed value with multiple "," in a row. | 39 // Guard against a malformed value with multiple "," in a row. |
| 40 string16 acceptLang = acceptLanguages.substr(begin, end - begin); | 40 string16 acceptLang = acceptLanguages.substr(begin, end - begin); |
| 41 static_cast<ListValue*>(result_.get())-> | 41 static_cast<ListValue*>(result_.get())-> |
| 42 Append(Value::CreateStringValue(acceptLang)); | 42 Append(base::StringValue::New(acceptLang)); |
| 43 } | 43 } |
| 44 begin = end + 1; | 44 begin = end + 1; |
| 45 // 'begin >= acceptLanguages.length()' to guard against a value | 45 // 'begin >= acceptLanguages.length()' to guard against a value |
| 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 |