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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "build/build_config.h" | 11 #include "build/build_config.h" |
10 #include "components/clipboard/public/interfaces/clipboard.mojom.h" | 12 #include "components/clipboard/public/interfaces/clipboard.mojom.h" |
11 #include "components/mus/public/interfaces/gpu.mojom.h" | 13 #include "components/mus/public/interfaces/gpu.mojom.h" |
12 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
13 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" | 15 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
14 #include "components/web_view/frame_tree.h" | 16 #include "components/web_view/frame_tree.h" |
15 #include "components/web_view/frame_utils.h" | 17 #include "components/web_view/frame_utils.h" |
16 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" | 18 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" |
(...skipping 17 matching lines...) Expand all Loading... |
34 const uint32_t existing_content_handler_id, | 36 const uint32_t existing_content_handler_id, |
35 const FrameTreeDelegate::CanNavigateFrameCallback& callback, | 37 const FrameTreeDelegate::CanNavigateFrameCallback& callback, |
36 scoped_ptr<FrameConnection> connection) { | 38 scoped_ptr<FrameConnection> connection) { |
37 mus::mojom::WindowTreeClientPtr window_tree_client; | 39 mus::mojom::WindowTreeClientPtr window_tree_client; |
38 if (!AreAppIdsEqual(existing_content_handler_id, | 40 if (!AreAppIdsEqual(existing_content_handler_id, |
39 connection->GetContentHandlerID())) { | 41 connection->GetContentHandlerID())) { |
40 window_tree_client = connection->GetWindowTreeClient(); | 42 window_tree_client = connection->GetWindowTreeClient(); |
41 } | 43 } |
42 FrameConnection* connection_ptr = connection.get(); | 44 FrameConnection* connection_ptr = connection.get(); |
43 callback.Run(connection_ptr->GetContentHandlerID(), | 45 callback.Run(connection_ptr->GetContentHandlerID(), |
44 connection_ptr->frame_client(), connection.Pass(), | 46 connection_ptr->frame_client(), std::move(connection), |
45 window_tree_client.Pass()); | 47 std::move(window_tree_client)); |
46 } | 48 } |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 FrameConnection::FrameConnection() : application_connection_(nullptr) { | 52 FrameConnection::FrameConnection() : application_connection_(nullptr) { |
51 } | 53 } |
52 | 54 |
53 FrameConnection::~FrameConnection() { | 55 FrameConnection::~FrameConnection() { |
54 } | 56 } |
55 | 57 |
56 // static | 58 // static |
57 void FrameConnection::CreateConnectionForCanNavigateFrame( | 59 void FrameConnection::CreateConnectionForCanNavigateFrame( |
58 mojo::ApplicationImpl* app, | 60 mojo::ApplicationImpl* app, |
59 Frame* frame, | 61 Frame* frame, |
60 mojo::URLRequestPtr request, | 62 mojo::URLRequestPtr request, |
61 const FrameTreeDelegate::CanNavigateFrameCallback& callback) { | 63 const FrameTreeDelegate::CanNavigateFrameCallback& callback) { |
62 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 64 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
63 FrameConnection* connection = frame_connection.get(); | 65 FrameConnection* connection = frame_connection.get(); |
64 connection->Init(app, request.Pass(), | 66 connection->Init(app, std::move(request), |
65 base::Bind(&OnGotContentHandlerForFrame, frame->app_id(), | 67 base::Bind(&OnGotContentHandlerForFrame, frame->app_id(), |
66 callback, base::Passed(&frame_connection))); | 68 callback, base::Passed(&frame_connection))); |
67 } | 69 } |
68 | 70 |
69 void FrameConnection::Init(mojo::ApplicationImpl* app, | 71 void FrameConnection::Init(mojo::ApplicationImpl* app, |
70 mojo::URLRequestPtr request, | 72 mojo::URLRequestPtr request, |
71 const base::Closure& on_got_id_callback) { | 73 const base::Closure& on_got_id_callback) { |
72 DCHECK(!application_connection_); | 74 DCHECK(!application_connection_); |
73 | 75 |
74 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New()); | 76 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New()); |
75 mojo::Array<mojo::String> resource_provider_interfaces; | 77 mojo::Array<mojo::String> resource_provider_interfaces; |
76 resource_provider_interfaces.push_back( | 78 resource_provider_interfaces.push_back( |
77 resource_provider::ResourceProvider::Name_); | 79 resource_provider::ResourceProvider::Name_); |
78 filter->filter.insert("mojo:resource_provider", | 80 filter->filter.insert("mojo:resource_provider", |
79 resource_provider_interfaces.Pass()); | 81 std::move(resource_provider_interfaces)); |
80 | 82 |
81 mojo::Array<mojo::String> network_service_interfaces; | 83 mojo::Array<mojo::String> network_service_interfaces; |
82 network_service_interfaces.push_back(mojo::CookieStore::Name_); | 84 network_service_interfaces.push_back(mojo::CookieStore::Name_); |
83 network_service_interfaces.push_back(mojo::NetworkService::Name_); | 85 network_service_interfaces.push_back(mojo::NetworkService::Name_); |
84 network_service_interfaces.push_back(mojo::URLLoaderFactory::Name_); | 86 network_service_interfaces.push_back(mojo::URLLoaderFactory::Name_); |
85 network_service_interfaces.push_back(mojo::WebSocketFactory::Name_); | 87 network_service_interfaces.push_back(mojo::WebSocketFactory::Name_); |
86 filter->filter.insert("mojo:network_service", | 88 filter->filter.insert("mojo:network_service", |
87 network_service_interfaces.Pass()); | 89 std::move(network_service_interfaces)); |
88 | 90 |
89 mojo::Array<mojo::String> clipboard_interfaces; | 91 mojo::Array<mojo::String> clipboard_interfaces; |
90 clipboard_interfaces.push_back(mojo::Clipboard::Name_); | 92 clipboard_interfaces.push_back(mojo::Clipboard::Name_); |
91 filter->filter.insert("mojo:clipboard", clipboard_interfaces.Pass()); | 93 filter->filter.insert("mojo:clipboard", std::move(clipboard_interfaces)); |
92 | 94 |
93 mojo::Array<mojo::String> tracing_interfaces; | 95 mojo::Array<mojo::String> tracing_interfaces; |
94 tracing_interfaces.push_back(tracing::StartupPerformanceDataCollector::Name_); | 96 tracing_interfaces.push_back(tracing::StartupPerformanceDataCollector::Name_); |
95 tracing_interfaces.push_back(tracing::TraceCollector::Name_); | 97 tracing_interfaces.push_back(tracing::TraceCollector::Name_); |
96 filter->filter.insert("mojo:tracing", tracing_interfaces.Pass()); | 98 filter->filter.insert("mojo:tracing", std::move(tracing_interfaces)); |
97 | 99 |
98 mojo::Array<mojo::String> window_manager_interfaces; | 100 mojo::Array<mojo::String> window_manager_interfaces; |
99 window_manager_interfaces.push_back(mus::mojom::Gpu::Name_); | 101 window_manager_interfaces.push_back(mus::mojom::Gpu::Name_); |
100 window_manager_interfaces.push_back(mus::mojom::WindowTreeHostFactory::Name_); | 102 window_manager_interfaces.push_back(mus::mojom::WindowTreeHostFactory::Name_); |
101 filter->filter.insert("mojo:mus", window_manager_interfaces.Pass()); | 103 filter->filter.insert("mojo:mus", std::move(window_manager_interfaces)); |
102 | 104 |
103 mojo::Array<mojo::String> test_runner_interfaces; | 105 mojo::Array<mojo::String> test_runner_interfaces; |
104 test_runner_interfaces.push_back(LayoutTestRunner::Name_); | 106 test_runner_interfaces.push_back(LayoutTestRunner::Name_); |
105 filter->filter.insert("mojo:web_view_test_runner", | 107 filter->filter.insert("mojo:web_view_test_runner", |
106 test_runner_interfaces.Pass()); | 108 std::move(test_runner_interfaces)); |
107 | 109 |
108 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 110 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
109 mojo::Array<mojo::String> font_service_interfaces; | 111 mojo::Array<mojo::String> font_service_interfaces; |
110 font_service_interfaces.push_back(font_service::FontService::Name_); | 112 font_service_interfaces.push_back(font_service::FontService::Name_); |
111 filter->filter.insert("mojo:font_service", font_service_interfaces.Pass()); | 113 filter->filter.insert("mojo:font_service", |
| 114 std::move(font_service_interfaces)); |
112 #endif | 115 #endif |
113 | 116 |
114 mojo::ApplicationImpl::ConnectParams params(request.Pass()); | 117 mojo::ApplicationImpl::ConnectParams params(std::move(request)); |
115 params.set_filter(filter.Pass()); | 118 params.set_filter(std::move(filter)); |
116 application_connection_ = app->ConnectToApplication(¶ms); | 119 application_connection_ = app->ConnectToApplication(¶ms); |
117 application_connection_->ConnectToService(&frame_client_); | 120 application_connection_->ConnectToService(&frame_client_); |
118 application_connection_->AddContentHandlerIDCallback(on_got_id_callback); | 121 application_connection_->AddContentHandlerIDCallback(on_got_id_callback); |
119 } | 122 } |
120 | 123 |
121 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() { | 124 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() { |
122 DCHECK(application_connection_); | 125 DCHECK(application_connection_); |
123 mus::mojom::WindowTreeClientPtr window_tree_client; | 126 mus::mojom::WindowTreeClientPtr window_tree_client; |
124 application_connection_->ConnectToService(&window_tree_client); | 127 application_connection_->ConnectToService(&window_tree_client); |
125 return window_tree_client.Pass(); | 128 return window_tree_client; |
126 } | 129 } |
127 | 130 |
128 uint32_t FrameConnection::GetContentHandlerID() const { | 131 uint32_t FrameConnection::GetContentHandlerID() const { |
129 uint32_t content_handler_id = mojo::Shell::kInvalidContentHandlerID; | 132 uint32_t content_handler_id = mojo::Shell::kInvalidContentHandlerID; |
130 if (!application_connection_->GetContentHandlerID(&content_handler_id)) | 133 if (!application_connection_->GetContentHandlerID(&content_handler_id)) |
131 NOTREACHED(); | 134 NOTREACHED(); |
132 return content_handler_id; | 135 return content_handler_id; |
133 } | 136 } |
134 | 137 |
135 } // namespace web_view | 138 } // namespace web_view |
OLD | NEW |