| OLD | NEW |
| 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 "sky/viewer/internals.h" | 5 #include "sky/viewer/internals.h" |
| 6 | 6 |
| 7 #include "mojo/edk/js/core.h" | 7 #include "mojo/edk/js/core.h" |
| 8 #include "mojo/edk/js/handle.h" | 8 #include "mojo/edk/js/handle.h" |
| 9 #include "mojo/edk/js/support.h" | 9 #include "mojo/edk/js/support.h" |
| 10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 v8::Handle<v8::Object> object = internals.ToV8().As<v8::Object>(); | 27 v8::Handle<v8::Object> object = internals.ToV8().As<v8::Object>(); |
| 28 object->Set(gin::StringToV8(isolate, "core"), | 28 object->Set(gin::StringToV8(isolate, "core"), |
| 29 mojo::js::Core::GetModule(isolate)); | 29 mojo::js::Core::GetModule(isolate)); |
| 30 object->Set(gin::StringToV8(isolate, "support"), | 30 object->Set(gin::StringToV8(isolate, "support"), |
| 31 mojo::js::Support::GetModule(isolate)); | 31 mojo::js::Support::GetModule(isolate)); |
| 32 return internals; | 32 return internals; |
| 33 } | 33 } |
| 34 | 34 |
| 35 Internals::Internals(DocumentView* document_view) | 35 Internals::Internals(DocumentView* document_view) |
| 36 : document_view_(document_view->GetWeakPtr()) { | 36 : document_view_(document_view->GetWeakPtr()) { |
| 37 mojo::ConnectToService(document_view->imported_services(), &test_observer_); | 37 mojo::ConnectToService(document_view->imported_services(), &test_harness_); |
| 38 } | 38 } |
| 39 | 39 |
| 40 Internals::~Internals() { | 40 Internals::~Internals() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 gin::ObjectTemplateBuilder Internals::GetObjectTemplateBuilder( | 43 gin::ObjectTemplateBuilder Internals::GetObjectTemplateBuilder( |
| 44 v8::Isolate* isolate) { | 44 v8::Isolate* isolate) { |
| 45 return Wrappable<Internals>::GetObjectTemplateBuilder(isolate) | 45 return Wrappable<Internals>::GetObjectTemplateBuilder(isolate) |
| 46 .SetMethod("renderTreeAsText", &Internals::RenderTreeAsText) | 46 .SetMethod("renderTreeAsText", &Internals::RenderTreeAsText) |
| 47 .SetMethod("contentAsText", &Internals::ContentAsText) | 47 .SetMethod("contentAsText", &Internals::ContentAsText) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 1024*1024).utf8(); | 63 1024*1024).utf8(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 std::string Internals::ContentAsMarkup() { | 66 std::string Internals::ContentAsMarkup() { |
| 67 if (!document_view_) | 67 if (!document_view_) |
| 68 return std::string(); | 68 return std::string(); |
| 69 return document_view_->web_view()->mainFrame()->contentAsMarkup().utf8(); | 69 return document_view_->web_view()->mainFrame()->contentAsMarkup().utf8(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void Internals::NotifyTestComplete(const std::string& test_result) { | 72 void Internals::NotifyTestComplete(const std::string& test_result) { |
| 73 test_observer_->OnTestComplete(test_result); | 73 test_harness_->OnTestComplete(test_result); |
| 74 } | 74 } |
| 75 | 75 |
| 76 mojo::Handle Internals::ConnectToService( | 76 mojo::Handle Internals::ConnectToService( |
| 77 const std::string& application_url, const std::string& interface_name) { | 77 const std::string& application_url, const std::string& interface_name) { |
| 78 if (!document_view_) | 78 if (!document_view_) |
| 79 return mojo::Handle(); | 79 return mojo::Handle(); |
| 80 | 80 |
| 81 mojo::ServiceProviderPtr service_provider; | 81 mojo::ServiceProviderPtr service_provider; |
| 82 document_view_->shell()->ConnectToApplication( | 82 document_view_->shell()->ConnectToApplication( |
| 83 application_url, mojo::GetProxy(&service_provider)); | 83 application_url, mojo::GetProxy(&service_provider)); |
| 84 | 84 |
| 85 mojo::MessagePipe pipe; | 85 mojo::MessagePipe pipe; |
| 86 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); | 86 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); |
| 87 return pipe.handle0.release(); | 87 return pipe.handle0.release(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace sky | 90 } // namespace sky |
| OLD | NEW |