| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/web_view/frame_connection.h" | 5 #include "components/web_view/frame_connection.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "components/clipboard/public/interfaces/clipboard.mojom.h" | 9 #include "components/clipboard/public/interfaces/clipboard.mojom.h" |
| 10 #include "components/mus/public/interfaces/gpu.mojom.h" | 10 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 11 #include "components/mus/public/interfaces/view_tree_host.mojom.h" | 11 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 12 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" | 12 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
| 13 #include "components/web_view/frame_tree.h" | 13 #include "components/web_view/frame_tree.h" |
| 14 #include "components/web_view/frame_utils.h" | 14 #include "components/web_view/frame_utils.h" |
| 15 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" | 15 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" |
| 16 #include "mojo/application/public/cpp/application_connection.h" | 16 #include "mojo/application/public/cpp/application_connection.h" |
| 17 #include "mojo/application/public/cpp/application_impl.h" | 17 #include "mojo/application/public/cpp/application_impl.h" |
| 18 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" | 18 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" |
| 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 20 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" | 20 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
| 21 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" | 21 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
| 22 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 22 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 23 | 23 |
| 24 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 24 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 25 #include "components/font_service/public/interfaces/font_service.mojom.h" | 25 #include "components/font_service/public/interfaces/font_service.mojom.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace web_view { | 28 namespace web_view { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Callback from when the content handler id is obtained. | 31 // Callback from when the content handler id is obtained. |
| 32 void OnGotContentHandlerForFrame( | 32 void OnGotContentHandlerForFrame( |
| 33 const uint32_t existing_content_handler_id, | 33 const uint32_t existing_content_handler_id, |
| 34 const FrameTreeDelegate::CanNavigateFrameCallback& callback, | 34 const FrameTreeDelegate::CanNavigateFrameCallback& callback, |
| 35 scoped_ptr<FrameConnection> connection) { | 35 scoped_ptr<FrameConnection> connection) { |
| 36 mojo::ViewTreeClientPtr view_tree_client; | 36 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 37 if (!AreAppIdsEqual(existing_content_handler_id, | 37 if (!AreAppIdsEqual(existing_content_handler_id, |
| 38 connection->GetContentHandlerID())) { | 38 connection->GetContentHandlerID())) { |
| 39 view_tree_client = connection->GetViewTreeClient(); | 39 window_tree_client = connection->GetWindowTreeClient(); |
| 40 } | 40 } |
| 41 FrameConnection* connection_ptr = connection.get(); | 41 FrameConnection* connection_ptr = connection.get(); |
| 42 callback.Run(connection_ptr->GetContentHandlerID(), | 42 callback.Run(connection_ptr->GetContentHandlerID(), |
| 43 connection_ptr->frame_client(), connection.Pass(), | 43 connection_ptr->frame_client(), connection.Pass(), |
| 44 view_tree_client.Pass()); | 44 window_tree_client.Pass()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 FrameConnection::FrameConnection() : application_connection_(nullptr) { | 49 FrameConnection::FrameConnection() : application_connection_(nullptr) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 FrameConnection::~FrameConnection() { | 52 FrameConnection::~FrameConnection() { |
| 53 } | 53 } |
| 54 | 54 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 mojo::Array<mojo::String> clipboard_interfaces; | 88 mojo::Array<mojo::String> clipboard_interfaces; |
| 89 clipboard_interfaces.push_back(mojo::Clipboard::Name_); | 89 clipboard_interfaces.push_back(mojo::Clipboard::Name_); |
| 90 filter->filter.insert("mojo:clipboard", clipboard_interfaces.Pass()); | 90 filter->filter.insert("mojo:clipboard", clipboard_interfaces.Pass()); |
| 91 | 91 |
| 92 mojo::Array<mojo::String> tracing_interfaces; | 92 mojo::Array<mojo::String> tracing_interfaces; |
| 93 tracing_interfaces.push_back(tracing::StartupPerformanceDataCollector::Name_); | 93 tracing_interfaces.push_back(tracing::StartupPerformanceDataCollector::Name_); |
| 94 filter->filter.insert("mojo:tracing", tracing_interfaces.Pass()); | 94 filter->filter.insert("mojo:tracing", tracing_interfaces.Pass()); |
| 95 | 95 |
| 96 mojo::Array<mojo::String> view_manager_interfaces; | 96 mojo::Array<mojo::String> view_manager_interfaces; |
| 97 view_manager_interfaces.push_back(mojo::Gpu::Name_); | 97 view_manager_interfaces.push_back(mus::mojom::Gpu::Name_); |
| 98 view_manager_interfaces.push_back(mojo::ViewTreeHostFactory::Name_); | 98 view_manager_interfaces.push_back(mus::mojom::WindowTreeHostFactory::Name_); |
| 99 filter->filter.insert("mojo:mus", view_manager_interfaces.Pass()); | 99 filter->filter.insert("mojo:mus", view_manager_interfaces.Pass()); |
| 100 | 100 |
| 101 mojo::Array<mojo::String> test_runner_interfaces; | 101 mojo::Array<mojo::String> test_runner_interfaces; |
| 102 test_runner_interfaces.push_back(LayoutTestRunner::Name_); | 102 test_runner_interfaces.push_back(LayoutTestRunner::Name_); |
| 103 filter->filter.insert("mojo:web_view_test_runner", | 103 filter->filter.insert("mojo:web_view_test_runner", |
| 104 test_runner_interfaces.Pass()); | 104 test_runner_interfaces.Pass()); |
| 105 | 105 |
| 106 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 106 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 107 mojo::Array<mojo::String> font_service_interfaces; | 107 mojo::Array<mojo::String> font_service_interfaces; |
| 108 font_service_interfaces.push_back(font_service::FontService::Name_); | 108 font_service_interfaces.push_back(font_service::FontService::Name_); |
| 109 filter->filter.insert("mojo:font_service", font_service_interfaces.Pass()); | 109 filter->filter.insert("mojo:font_service", font_service_interfaces.Pass()); |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 application_connection_ = app->ConnectToApplicationWithCapabilityFilter( | 112 application_connection_ = app->ConnectToApplicationWithCapabilityFilter( |
| 113 request.Pass(), filter.Pass()); | 113 request.Pass(), filter.Pass()); |
| 114 application_connection_->ConnectToService(&frame_client_); | 114 application_connection_->ConnectToService(&frame_client_); |
| 115 application_connection_->AddContentHandlerIDCallback(on_got_id_callback); | 115 application_connection_->AddContentHandlerIDCallback(on_got_id_callback); |
| 116 } | 116 } |
| 117 | 117 |
| 118 mojo::ViewTreeClientPtr FrameConnection::GetViewTreeClient() { | 118 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() { |
| 119 DCHECK(application_connection_); | 119 DCHECK(application_connection_); |
| 120 mojo::ViewTreeClientPtr view_tree_client; | 120 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 121 application_connection_->ConnectToService(&view_tree_client); | 121 application_connection_->ConnectToService(&window_tree_client); |
| 122 return view_tree_client.Pass(); | 122 return window_tree_client.Pass(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 uint32_t FrameConnection::GetContentHandlerID() const { | 125 uint32_t FrameConnection::GetContentHandlerID() const { |
| 126 uint32_t content_handler_id = mojo::Shell::kInvalidContentHandlerID; | 126 uint32_t content_handler_id = mojo::Shell::kInvalidContentHandlerID; |
| 127 if (!application_connection_->GetContentHandlerID(&content_handler_id)) | 127 if (!application_connection_->GetContentHandlerID(&content_handler_id)) |
| 128 NOTREACHED(); | 128 NOTREACHED(); |
| 129 return content_handler_id; | 129 return content_handler_id; |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace web_view | 132 } // namespace web_view |
| OLD | NEW |