| 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 27 matching lines...) Expand all Loading... |
| 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) |
| 48 .SetMethod("contentAsMarkup", &Internals::ContentAsMarkup) | |
| 49 .SetMethod("notifyTestComplete", &Internals::NotifyTestComplete) | 48 .SetMethod("notifyTestComplete", &Internals::NotifyTestComplete) |
| 50 .SetMethod("connectToService", &Internals::ConnectToService); | 49 .SetMethod("connectToService", &Internals::ConnectToService); |
| 51 } | 50 } |
| 52 | 51 |
| 53 std::string Internals::RenderTreeAsText() { | 52 std::string Internals::RenderTreeAsText() { |
| 54 if (!document_view_) | 53 if (!document_view_) |
| 55 return std::string(); | 54 return std::string(); |
| 56 return document_view_->web_view()->mainFrame()->renderTreeAsText().utf8(); | 55 return document_view_->web_view()->mainFrame()->renderTreeAsText().utf8(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 std::string Internals::ContentAsText() { | 58 std::string Internals::ContentAsText() { |
| 60 if (!document_view_) | 59 if (!document_view_) |
| 61 return std::string(); | 60 return std::string(); |
| 62 return document_view_->web_view()->mainFrame()->contentAsText( | 61 return document_view_->web_view()->mainFrame()->contentAsText( |
| 63 1024*1024).utf8(); | 62 1024*1024).utf8(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 std::string Internals::ContentAsMarkup() { | |
| 67 if (!document_view_) | |
| 68 return std::string(); | |
| 69 return document_view_->web_view()->mainFrame()->contentAsMarkup().utf8(); | |
| 70 } | |
| 71 | |
| 72 void Internals::NotifyTestComplete(const std::string& test_result) { | 65 void Internals::NotifyTestComplete(const std::string& test_result) { |
| 73 test_harness_->OnTestComplete(test_result); | 66 test_harness_->OnTestComplete(test_result); |
| 74 } | 67 } |
| 75 | 68 |
| 76 mojo::Handle Internals::ConnectToService( | 69 mojo::Handle Internals::ConnectToService( |
| 77 const std::string& application_url, const std::string& interface_name) { | 70 const std::string& application_url, const std::string& interface_name) { |
| 78 if (!document_view_) | 71 if (!document_view_) |
| 79 return mojo::Handle(); | 72 return mojo::Handle(); |
| 80 | 73 |
| 81 mojo::ServiceProviderPtr service_provider; | 74 mojo::ServiceProviderPtr service_provider; |
| 82 document_view_->shell()->ConnectToApplication( | 75 document_view_->shell()->ConnectToApplication( |
| 83 application_url, mojo::GetProxy(&service_provider)); | 76 application_url, mojo::GetProxy(&service_provider)); |
| 84 | 77 |
| 85 mojo::MessagePipe pipe; | 78 mojo::MessagePipe pipe; |
| 86 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); | 79 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); |
| 87 return pipe.handle0.release(); | 80 return pipe.handle0.release(); |
| 88 } | 81 } |
| 89 | 82 |
| 90 } // namespace sky | 83 } // namespace sky |
| OLD | NEW |