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 "components/translate/content/renderer/translate_helper.h" | 5 #include "components/translate/content/renderer/translate_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 303 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
304 WebVector<v8::Local<v8::Value> > results; | 304 WebVector<v8::Local<v8::Value> > results; |
305 WebScriptSource source = WebScriptSource(ASCIIToUTF16(script)); | 305 WebScriptSource source = WebScriptSource(ASCIIToUTF16(script)); |
306 main_frame->executeScriptInIsolatedWorld( | 306 main_frame->executeScriptInIsolatedWorld( |
307 world_id_, &source, 1, extension_group_, &results); | 307 world_id_, &source, 1, extension_group_, &results); |
308 if (results.size() != 1 || results[0].IsEmpty() || !results[0]->IsString()) { | 308 if (results.size() != 1 || results[0].IsEmpty() || !results[0]->IsString()) { |
309 NOTREACHED(); | 309 NOTREACHED(); |
310 return std::string(); | 310 return std::string(); |
311 } | 311 } |
312 | 312 |
313 v8::Local<v8::String> v8_str = results[0]->ToString(); | 313 v8::Local<v8::String> v8_str = results[0].As<v8::String>(); |
314 int length = v8_str->Utf8Length() + 1; | 314 int length = v8_str->Utf8Length() + 1; |
315 scoped_ptr<char[]> str(new char[length]); | 315 scoped_ptr<char[]> str(new char[length]); |
316 v8_str->WriteUtf8(str.get(), length); | 316 v8_str->WriteUtf8(str.get(), length); |
317 return std::string(str.get()); | 317 return std::string(str.get()); |
318 } | 318 } |
319 | 319 |
320 double TranslateHelper::ExecuteScriptAndGetDoubleResult( | 320 double TranslateHelper::ExecuteScriptAndGetDoubleResult( |
321 const std::string& script) { | 321 const std::string& script) { |
322 WebFrame* main_frame = GetMainFrame(); | 322 WebFrame* main_frame = GetMainFrame(); |
323 if (!main_frame) | 323 if (!main_frame) |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 // this, everything should start being ON_TIME. This should never run more | 647 // this, everything should start being ON_TIME. This should never run more |
648 // than twice in a page load, under any conditions. | 648 // than twice in a page load, under any conditions. |
649 // Also note that language detection is triggered off of a delay AFTER the | 649 // Also note that language detection is triggered off of a delay AFTER the |
650 // page load completed event has fired, making this very much off the critical | 650 // page load completed event has fired, making this very much off the critical |
651 // path. | 651 // path. |
652 content::RenderThread::Get()->UpdateHistograms( | 652 content::RenderThread::Get()->UpdateHistograms( |
653 content::kHistogramSynchronizerReservedSequenceNumber); | 653 content::kHistogramSynchronizerReservedSequenceNumber); |
654 } | 654 } |
655 | 655 |
656 } // namespace translate | 656 } // namespace translate |
OLD | NEW |