Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chrome/browser/translate/translate_manager.cc

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/translate/translate_manager.h" 5 #include "chrome/browser/translate/translate_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return; 213 return;
214 } 214 }
215 static const size_t kLanguageListCallbackNameLength = 215 static const size_t kLanguageListCallbackNameLength =
216 strlen(kLanguageListCallbackName); 216 strlen(kLanguageListCallbackName);
217 std::string languages_json = language_list.substr( 217 std::string languages_json = language_list.substr(
218 kLanguageListCallbackNameLength, 218 kLanguageListCallbackNameLength,
219 language_list.size() - kLanguageListCallbackNameLength - 1); 219 language_list.size() - kLanguageListCallbackNameLength - 1);
220 // JSON doesn't support single quotes though this is what is used on the 220 // JSON doesn't support single quotes though this is what is used on the
221 // translate server so we must replace them with double quotes. 221 // translate server so we must replace them with double quotes.
222 ReplaceSubstringsAfterOffset(&languages_json, 0, "'", "\""); 222 ReplaceSubstringsAfterOffset(&languages_json, 0, "'", "\"");
223 scoped_ptr<Value> json_value(base::JSONReader::Read(languages_json, true)); 223 scoped_ptr<Value> json_value(
224 base::JSONReader::Read(languages_json, base::JSON_ALLOW_TRAILING_COMMAS));
224 if (json_value == NULL || !json_value->IsType(Value::TYPE_DICTIONARY)) { 225 if (json_value == NULL || !json_value->IsType(Value::TYPE_DICTIONARY)) {
225 NOTREACHED(); 226 NOTREACHED();
226 return; 227 return;
227 } 228 }
228 // The first level dictionary contains two sub-dict, one for source languages 229 // The first level dictionary contains two sub-dict, one for source languages
229 // and the other for target languages, we want to use the target languages. 230 // and the other for target languages, we want to use the target languages.
230 DictionaryValue* language_dict = 231 DictionaryValue* language_dict =
231 static_cast<DictionaryValue*>(json_value.get()); 232 static_cast<DictionaryValue*>(json_value.get());
232 DictionaryValue* target_languages = NULL; 233 DictionaryValue* target_languages = NULL;
233 if (!language_dict->GetDictionary(kTargetLanguagesKey, &target_languages) || 234 if (!language_dict->GetDictionary(kTargetLanguagesKey, &target_languages) ||
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); 899 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper();
899 900
900 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { 901 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) {
901 TranslateInfoBarDelegate* delegate = 902 TranslateInfoBarDelegate* delegate =
902 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); 903 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
903 if (delegate) 904 if (delegate)
904 return delegate; 905 return delegate;
905 } 906 }
906 return NULL; 907 return NULL;
907 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698