| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "components/clipboard/public/interfaces/clipboard.mojom.h" | 12 #include "components/clipboard/public/interfaces/clipboard.mojom.h" |
| 13 #include "components/mus/public/interfaces/display.mojom.h" | 13 #include "components/mus/public/interfaces/display.mojom.h" |
| 14 #include "components/mus/public/interfaces/gpu.mojom.h" | 14 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 16 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" | 16 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
| 17 #include "components/web_view/frame_tree.h" | 17 #include "components/web_view/frame_tree.h" |
| 18 #include "components/web_view/frame_utils.h" | 18 #include "components/web_view/frame_utils.h" |
| 19 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" | 19 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" |
| 20 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" | 20 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h" |
| 21 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 21 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 22 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" | 22 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
| 23 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" | 23 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
| 24 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 24 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 25 #include "mojo/shell/public/cpp/application_connection.h" | 25 #include "mojo/shell/public/cpp/connection.h" |
| 26 #include "mojo/shell/public/cpp/shell.h" | 26 #include "mojo/shell/public/cpp/shell.h" |
| 27 | 27 |
| 28 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 28 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 29 #include "components/font_service/public/interfaces/font_service.mojom.h" | 29 #include "components/font_service/public/interfaces/font_service.mojom.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace web_view { | 32 namespace web_view { |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Callback from when the content handler id is obtained. | 35 // Callback from when the content handler id is obtained. |
| 36 void OnGotContentHandlerForFrame( | 36 void OnGotContentHandlerForFrame( |
| 37 const uint32_t existing_content_handler_id, | 37 const uint32_t existing_content_handler_id, |
| 38 const FrameTreeDelegate::CanNavigateFrameCallback& callback, | 38 const FrameTreeDelegate::CanNavigateFrameCallback& callback, |
| 39 scoped_ptr<FrameConnection> connection) { | 39 scoped_ptr<FrameConnection> connection) { |
| 40 mus::mojom::WindowTreeClientPtr window_tree_client; | 40 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 41 if (!AreAppIdsEqual(existing_content_handler_id, | 41 if (!AreAppIdsEqual(existing_content_handler_id, |
| 42 connection->GetContentHandlerID())) { | 42 connection->GetContentHandlerID())) { |
| 43 window_tree_client = connection->GetWindowTreeClient(); | 43 window_tree_client = connection->GetWindowTreeClient(); |
| 44 } | 44 } |
| 45 FrameConnection* connection_ptr = connection.get(); | 45 FrameConnection* connection_ptr = connection.get(); |
| 46 callback.Run(connection_ptr->GetContentHandlerID(), | 46 callback.Run(connection_ptr->GetContentHandlerID(), |
| 47 connection_ptr->frame_client(), std::move(connection), | 47 connection_ptr->frame_client(), std::move(connection), |
| 48 std::move(window_tree_client)); | 48 std::move(window_tree_client)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 FrameConnection::FrameConnection() : application_connection_(nullptr) { | 53 FrameConnection::FrameConnection() : connection_(nullptr) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 FrameConnection::~FrameConnection() { | 56 FrameConnection::~FrameConnection() { |
| 57 } | 57 } |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 void FrameConnection::CreateConnectionForCanNavigateFrame( | 60 void FrameConnection::CreateConnectionForCanNavigateFrame( |
| 61 mojo::Shell* shell, | 61 mojo::Shell* shell, |
| 62 Frame* frame, | 62 Frame* frame, |
| 63 mojo::URLRequestPtr request, | 63 mojo::URLRequestPtr request, |
| 64 const FrameTreeDelegate::CanNavigateFrameCallback& callback) { | 64 const FrameTreeDelegate::CanNavigateFrameCallback& callback) { |
| 65 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 65 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
| 66 FrameConnection* connection = frame_connection.get(); | 66 FrameConnection* connection = frame_connection.get(); |
| 67 connection->Init(shell, std::move(request), | 67 connection->Init(shell, std::move(request), |
| 68 base::Bind(&OnGotContentHandlerForFrame, frame->app_id(), | 68 base::Bind(&OnGotContentHandlerForFrame, frame->app_id(), |
| 69 callback, base::Passed(&frame_connection))); | 69 callback, base::Passed(&frame_connection))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void FrameConnection::Init(mojo::Shell* shell, | 72 void FrameConnection::Init(mojo::Shell* shell, |
| 73 mojo::URLRequestPtr request, | 73 mojo::URLRequestPtr request, |
| 74 const base::Closure& on_got_id_callback) { | 74 const base::Closure& on_got_id_callback) { |
| 75 DCHECK(!application_connection_); | 75 DCHECK(!connection_); |
| 76 | 76 |
| 77 mojo::shell::mojom::CapabilityFilterPtr filter( | 77 mojo::shell::mojom::CapabilityFilterPtr filter( |
| 78 mojo::shell::mojom::CapabilityFilter::New()); | 78 mojo::shell::mojom::CapabilityFilter::New()); |
| 79 mojo::Array<mojo::String> resource_provider_interfaces; | 79 mojo::Array<mojo::String> resource_provider_interfaces; |
| 80 resource_provider_interfaces.push_back( | 80 resource_provider_interfaces.push_back( |
| 81 resource_provider::ResourceProvider::Name_); | 81 resource_provider::ResourceProvider::Name_); |
| 82 filter->filter.insert("mojo:resource_provider", | 82 filter->filter.insert("mojo:resource_provider", |
| 83 std::move(resource_provider_interfaces)); | 83 std::move(resource_provider_interfaces)); |
| 84 | 84 |
| 85 mojo::Array<mojo::String> network_service_interfaces; | 85 mojo::Array<mojo::String> network_service_interfaces; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 112 | 112 |
| 113 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 113 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 114 mojo::Array<mojo::String> font_service_interfaces; | 114 mojo::Array<mojo::String> font_service_interfaces; |
| 115 font_service_interfaces.push_back(font_service::FontService::Name_); | 115 font_service_interfaces.push_back(font_service::FontService::Name_); |
| 116 filter->filter.insert("mojo:font_service", | 116 filter->filter.insert("mojo:font_service", |
| 117 std::move(font_service_interfaces)); | 117 std::move(font_service_interfaces)); |
| 118 #endif | 118 #endif |
| 119 | 119 |
| 120 mojo::Shell::ConnectParams params(std::move(request)); | 120 mojo::Shell::ConnectParams params(std::move(request)); |
| 121 params.set_filter(std::move(filter)); | 121 params.set_filter(std::move(filter)); |
| 122 application_connection_ = shell->ConnectToApplication(¶ms); | 122 connection_ = shell->ConnectToApplication(¶ms); |
| 123 application_connection_->ConnectToService(&frame_client_); | 123 connection_->ConnectToService(&frame_client_); |
| 124 application_connection_->AddRemoteIDCallback(on_got_id_callback); | 124 connection_->AddRemoteIDCallback(on_got_id_callback); |
| 125 } | 125 } |
| 126 | 126 |
| 127 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() { | 127 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() { |
| 128 DCHECK(application_connection_); | 128 DCHECK(connection_); |
| 129 mus::mojom::WindowTreeClientPtr window_tree_client; | 129 mus::mojom::WindowTreeClientPtr window_tree_client; |
| 130 application_connection_->ConnectToService(&window_tree_client); | 130 connection_->ConnectToService(&window_tree_client); |
| 131 return window_tree_client; | 131 return window_tree_client; |
| 132 } | 132 } |
| 133 | 133 |
| 134 uint32_t FrameConnection::GetContentHandlerID() const { | 134 uint32_t FrameConnection::GetContentHandlerID() const { |
| 135 uint32_t content_handler_id = | 135 uint32_t content_handler_id = |
| 136 mojo::shell::mojom::Shell::kInvalidApplicationID; | 136 mojo::shell::mojom::Shell::kInvalidApplicationID; |
| 137 if (!application_connection_->GetRemoteContentHandlerID(&content_handler_id)) | 137 if (!connection_->GetRemoteContentHandlerID(&content_handler_id)) |
| 138 NOTREACHED(); | 138 NOTREACHED(); |
| 139 return content_handler_id; | 139 return content_handler_id; |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace web_view | 142 } // namespace web_view |
| OLD | NEW |