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

Side by Side Diff: extensions/renderer/i18n_custom_bindings.cc

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: rebase Created 3 years, 6 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
OLDNEW
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 "extensions/renderer/i18n_custom_bindings.h" 5 #include "extensions/renderer/i18n_custom_bindings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 dict_value.SetBoolean("isReliable", is_reliable); 97 dict_value.SetBoolean("isReliable", is_reliable);
98 std::unique_ptr<base::ListValue> languages_list(new base::ListValue()); 98 std::unique_ptr<base::ListValue> languages_list(new base::ListValue());
99 for (const auto& language : languages) 99 for (const auto& language : languages)
100 languages_list->Append(language->ToDictionary()); 100 languages_list->Append(language->ToDictionary());
101 dict_value.Set("languages", std::move(languages_list)); 101 dict_value.Set("languages", std::move(languages_list));
102 102
103 v8::Local<v8::Context> v8_context = context->v8_context(); 103 v8::Local<v8::Context> v8_context = context->v8_context();
104 v8::Isolate* isolate = v8_context->GetIsolate(); 104 v8::Isolate* isolate = v8_context->GetIsolate();
105 v8::EscapableHandleScope handle_scope(isolate); 105 v8::EscapableHandleScope handle_scope(isolate);
106 106
107 std::unique_ptr<content::V8ValueConverter> converter( 107 v8::Local<v8::Value> result =
108 content::V8ValueConverter::create()); 108 content::V8ValueConverter::Create()->ToV8Value(&dict_value, v8_context);
109 v8::Local<v8::Value> result = converter->ToV8Value(&dict_value, v8_context);
110 return handle_scope.Escape(result); 109 return handle_scope.Escape(result);
111 } 110 }
112 111
113 #if BUILDFLAG(CLD_VERSION) == 2 112 #if BUILDFLAG(CLD_VERSION) == 2
114 void InitDetectedLanguages( 113 void InitDetectedLanguages(
115 CLD2::Language* languages, 114 CLD2::Language* languages,
116 int* percents, 115 int* percents,
117 std::vector<std::unique_ptr<DetectedLanguage>>* detected_languages) { 116 std::vector<std::unique_ptr<DetectedLanguage>>* detected_languages) {
118 for (int i = 0; i < kCldNumLangs; i++) { 117 for (int i = 0; i < kCldNumLangs; i++) {
119 std::string language_code; 118 std::string language_code;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // Populate LanguageDetectionResult with prediction reliability, languages, 329 // Populate LanguageDetectionResult with prediction reliability, languages,
331 // and the corresponding percentages. 330 // and the corresponding percentages.
332 InitDetectedLanguages(lang_results, &result); 331 InitDetectedLanguages(lang_results, &result);
333 args.GetReturnValue().Set(result.ToValue(context())); 332 args.GetReturnValue().Set(result.ToValue(context()));
334 #else 333 #else
335 # error "CLD_VERSION must be 2 or 3" 334 # error "CLD_VERSION must be 2 or 3"
336 #endif 335 #endif
337 } 336 }
338 337
339 } // namespace extensions 338 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698